feat(v4): Update Inbox view card design (#10599)
This commit is contained in:
@@ -66,3 +66,32 @@ export const snoozedReopenTime = snoozedUntil => {
|
||||
}
|
||||
return snoozedUntil ? format(date, 'd MMM, h.mmaaa') : null;
|
||||
};
|
||||
|
||||
export const snoozedReopenTimeToTimestamp = snoozedUntil => {
|
||||
return snoozedUntil ? getUnixTime(new Date(snoozedUntil)) : null;
|
||||
};
|
||||
export const shortenSnoozeTime = snoozedUntil => {
|
||||
if (!snoozedUntil) {
|
||||
return null;
|
||||
}
|
||||
const unitMap = {
|
||||
minutes: 'm',
|
||||
minute: 'm',
|
||||
hours: 'h',
|
||||
hour: 'h',
|
||||
days: 'd',
|
||||
day: 'd',
|
||||
months: 'mo',
|
||||
month: 'mo',
|
||||
years: 'y',
|
||||
year: 'y',
|
||||
};
|
||||
const shortenTime = snoozedUntil
|
||||
.replace(/^in\s+/i, '')
|
||||
.replace(
|
||||
/\s(minute|hour|day|month|year)s?\b/gi,
|
||||
(match, unit) => unitMap[unit.toLowerCase()] || match
|
||||
);
|
||||
|
||||
return shortenTime;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,8 @@ import {
|
||||
findStartOfNextMonth,
|
||||
findNextDay,
|
||||
setHoursToNine,
|
||||
snoozedReopenTimeToTimestamp,
|
||||
shortenSnoozeTime,
|
||||
} from '../snoozeHelpers';
|
||||
|
||||
describe('#Snooze Helpers', () => {
|
||||
@@ -107,4 +109,45 @@ describe('#Snooze Helpers', () => {
|
||||
expect(findNextDay(today)).toEqual(nextDay);
|
||||
});
|
||||
});
|
||||
|
||||
describe('snoozedReopenTimeToTimestamp', () => {
|
||||
it('should return timestamp if snoozedUntil is not nil', () => {
|
||||
expect(snoozedReopenTimeToTimestamp('2023-06-07T09:00:00.000Z')).toEqual(
|
||||
1686128400
|
||||
);
|
||||
});
|
||||
it('should return nil if snoozedUntil is nil', () => {
|
||||
expect(snoozedReopenTimeToTimestamp(null)).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('shortenSnoozeTime', () => {
|
||||
it('should return shortened time if snoozedUntil is not nil and day is passed', () => {
|
||||
expect(shortenSnoozeTime('1 day')).toEqual('1d');
|
||||
});
|
||||
|
||||
it('should return shortened time if snoozedUntil is not nil and month is passed', () => {
|
||||
expect(shortenSnoozeTime('1 month')).toEqual('1mo');
|
||||
});
|
||||
|
||||
it('should return shortened time if snoozedUntil is not nil and year is passed', () => {
|
||||
expect(shortenSnoozeTime('1 year')).toEqual('1y');
|
||||
});
|
||||
|
||||
it('should return shortened time if snoozedUntil is not nil and hour is passed', () => {
|
||||
expect(shortenSnoozeTime('1 hour')).toEqual('1h');
|
||||
});
|
||||
|
||||
it('should return shortened time if snoozedUntil is not nil and minutes is passed', () => {
|
||||
expect(shortenSnoozeTime('1 minutes')).toEqual('1m');
|
||||
});
|
||||
|
||||
it('should return shortened time if snoozedUntil is not nil and in is passed', () => {
|
||||
expect(shortenSnoozeTime('in 1 hour')).toEqual('1h');
|
||||
});
|
||||
|
||||
it('should return nil if snoozedUntil is nil', () => {
|
||||
expect(shortenSnoozeTime(null)).toEqual(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user