Users configure share mode, expiry, and max views before upload; batch summary confirms choices above the queue.
21 lines
691 B
TypeScript
21 lines
691 B
TypeScript
import dayjs from 'dayjs';
|
|
import type { UploadExpiryPreset } from '@/types/upload/UploadExpiryPreset';
|
|
import type { UploadExpiryOffset } from '@/types/upload/UploadExpiryOffset';
|
|
|
|
const EXPIRY_OFFSET: Record<Exclude<UploadExpiryPreset, 'never'>, UploadExpiryOffset> = {
|
|
'1h': { amount: 1, unit: 'hour' },
|
|
'24h': { amount: 24, unit: 'hour' },
|
|
'7d': { amount: 7, unit: 'day' },
|
|
'30d': { amount: 30, unit: 'day' }
|
|
};
|
|
|
|
export const resolveUploadBatchExpiresAt = (preset: UploadExpiryPreset): string | null => {
|
|
if (preset === 'never') {
|
|
return null;
|
|
}
|
|
|
|
const { amount, unit } = EXPIRY_OFFSET[preset];
|
|
|
|
return dayjs().add(amount, unit).toISOString();
|
|
};
|