Files
private_image/frontend/src/utils/upload/resolveUploadBatchExpiresAt.ts
T
nobswebdev 805665745b Add batch upload configure modal and settings mapping utilities.
Users configure share mode, expiry, and max views before upload; batch summary confirms choices above the queue.
2026-10-22 03:14:02 +02:00

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();
};