30 lines
806 B
TypeScript
30 lines
806 B
TypeScript
import { ENV_CONSTANT } from '@/constants/secrect.constant';
|
|
import type { UploadVideo } from '@/types';
|
|
|
|
export function getUploadStatus(upload: UploadVideo) {
|
|
return upload.status?.status || 'unknown';
|
|
}
|
|
|
|
export function formatUploadedAt(value: string) {
|
|
const date = new Date(value);
|
|
if (Number.isNaN(date.getTime())) return '-';
|
|
|
|
return new Intl.DateTimeFormat('en-IN', {
|
|
day: '2-digit',
|
|
month: 'short',
|
|
year: 'numeric',
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
}).format(date);
|
|
}
|
|
|
|
export function resolveMediaUrl(url?: string | null) {
|
|
if (!url) return null;
|
|
if (/^https?:\/\//i.test(url)) return url;
|
|
|
|
const baseUrl = ENV_CONSTANT.BASE_API_URL?.replace(/\/$/, '');
|
|
const path = url.startsWith('/') ? url : `/${url}`;
|
|
return baseUrl ? `${baseUrl}${path}` : path;
|
|
}
|
|
|