@autobusal/utilities 1.1.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/date.tsx +22 -0
- package/index.ts +5 -3
- package/package.json +1 -1
- package/users.tsx +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are documented here. This project follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## 1.3.0
|
|
6
|
+
|
|
7
|
+
`getDayParts` — the same short date as `getFormattedShort`, but in its parts.
|
|
8
|
+
One string cannot be shortened by CSS, and the seven-day strip needs to drop
|
|
9
|
+
the month on a narrow screen so seven days fit without a scroller.
|
|
10
|
+
|
|
11
|
+
## [1.2.0] - 2026-07-25
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `GetChannelStatus(t)`: shared disabled/dedicated/main select values for
|
|
16
|
+
the Telegram and WhatsApp admin settings tabs (and any future per-label
|
|
17
|
+
messaging channel).
|
|
18
|
+
|
|
5
19
|
## [1.1.2] - 2026-07-24
|
|
6
20
|
|
|
7
21
|
### Added
|
package/date.tsx
CHANGED
|
@@ -27,6 +27,28 @@ export const getFormattedShort = (date: Date, t: TFunction<'generate'>): string
|
|
|
27
27
|
return `${ t(display.weekday, { ns: 'common' }) }, ${ display.day } ${ t(display.month, { ns: 'common' }).substring(0, 3) }`;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The same short date, but in parts.
|
|
32
|
+
*
|
|
33
|
+
* Edited: Ferjolt Ozuni - Date: 2026-08-03
|
|
34
|
+
*
|
|
35
|
+
* getFormattedShort returns one string, so a caller that needs to drop the
|
|
36
|
+
* month on a narrow screen cannot - CSS can hide an element but it cannot
|
|
37
|
+
* shorten a sentence. The seven-day strip needs exactly that: "Sat, 01 Aug"
|
|
38
|
+
* seven times does not fit a phone, "Sat 01" does.
|
|
39
|
+
*/
|
|
40
|
+
export const getDayParts = (date: Date, t: TFunction<'generate'>): { weekday: string, day: string, month: string } => {
|
|
41
|
+
const day = date.getDate();
|
|
42
|
+
const month = date.toLocaleString('default', { month: 'long' });
|
|
43
|
+
const weekday = date.toLocaleString('default', { weekday: 'short' });
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
weekday: t(`data.days.${ weekday.toLowerCase() }`, { ns: 'common' }),
|
|
47
|
+
day: day < 10 ? `0${ day }` : String(day),
|
|
48
|
+
month: t(`data.months.${ month.toLowerCase() }`, { ns: 'common' }).substring(0, 3)
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
30
52
|
export const differenceYears = (date: Date): number => {
|
|
31
53
|
const milliseconds = Date.now() - date.getTime();
|
|
32
54
|
|
package/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createDate, prepareDate, getFormattedShort, differenceYears, futureDate } from './date';
|
|
1
|
+
import { createDate, prepareDate, getFormattedShort, getDayParts, differenceYears, futureDate } from './date';
|
|
2
2
|
import { Validate, Display } from './form';
|
|
3
3
|
import { error, notify, success } from './notify';
|
|
4
4
|
import { getAllowed, getLanguages, getPayments } from './options';
|
|
5
5
|
import { getSex, getOptionsSex } from './passengers';
|
|
6
|
-
import { GetStatus, GetEnvironment, DisplayStatus } from './users';
|
|
6
|
+
import { GetStatus, GetEnvironment, GetChannelStatus, DisplayStatus } from './users';
|
|
7
7
|
import { getRandomNumber } from './numbers';
|
|
8
8
|
import { getParams } from './manage';
|
|
9
9
|
import { sanitizeHtml } from './sanitize';
|
|
@@ -18,6 +18,7 @@ export {
|
|
|
18
18
|
createDate,
|
|
19
19
|
prepareDate,
|
|
20
20
|
getFormattedShort,
|
|
21
|
+
getDayParts,
|
|
21
22
|
differenceYears,
|
|
22
23
|
DisplayStatus,
|
|
23
24
|
futureDate,
|
|
@@ -29,5 +30,6 @@ export {
|
|
|
29
30
|
getRandomNumber,
|
|
30
31
|
getSex,
|
|
31
32
|
GetStatus,
|
|
32
|
-
GetEnvironment
|
|
33
|
+
GetEnvironment,
|
|
34
|
+
GetChannelStatus
|
|
33
35
|
};
|
package/package.json
CHANGED
package/users.tsx
CHANGED
|
@@ -35,6 +35,25 @@ export const GetEnvironment = (t: TFunction<'common'>) => ([
|
|
|
35
35
|
}
|
|
36
36
|
]);
|
|
37
37
|
|
|
38
|
+
// Edited: Ferjolt Ozuni - Date: 2026-07-25
|
|
39
|
+
// Shared by the Telegram and WhatsApp admin settings tabs (and any future
|
|
40
|
+
// per-label messaging channel): disabled, this label's own credentials, or
|
|
41
|
+
// routed through the main label's - same three-state model Raiffeisen's
|
|
42
|
+
// payment domain toggle uses (that one has no "disabled" option since a
|
|
43
|
+
// separate Available toggle covers on/off there).
|
|
44
|
+
export const GetChannelStatus = (t: TFunction<'common'>) => ([
|
|
45
|
+
{
|
|
46
|
+
id: 'disabled',
|
|
47
|
+
name: t('admin_label.manage.channel_status.disabled', { ns: 'common' })
|
|
48
|
+
}, {
|
|
49
|
+
id: 'dedicated',
|
|
50
|
+
name: t('admin_label.manage.channel_status.dedicated', { ns: 'common' })
|
|
51
|
+
}, {
|
|
52
|
+
id: 'main',
|
|
53
|
+
name: t('admin_label.manage.channel_status.main', { ns: 'common' })
|
|
54
|
+
}
|
|
55
|
+
]);
|
|
56
|
+
|
|
38
57
|
const Status = styled.span<{ $type: string }>`
|
|
39
58
|
display: inline-block;
|
|
40
59
|
padding: 3px 5px;
|