44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
export const getFullUrl = (url?: string) => {
|
|
const BASE_URL = 'https://sg-delivery-api.convexsol.co';
|
|
if (!url) return '';
|
|
return url.startsWith('/') ? `${BASE_URL}${url}` : url;
|
|
};
|
|
|
|
export const formatTime = (dateString?: string) => {
|
|
if (!dateString) return '';
|
|
|
|
const dateObj = new Date(dateString);
|
|
|
|
// Example output: 11:57 AM
|
|
return dateObj.toLocaleTimeString('en-US', {
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
hour12: true,
|
|
});
|
|
};
|
|
|
|
export const formatDate = (dateString?: string) => {
|
|
if (!dateString) return '';
|
|
|
|
const dateObj = new Date(dateString);
|
|
|
|
// Example output: July 8, 2026
|
|
return dateObj.toLocaleDateString('en-US', {
|
|
month: 'long',
|
|
day: 'numeric',
|
|
year: 'numeric',
|
|
});
|
|
};
|
|
|
|
export const getCategoryEmoji = (name: string): string => {
|
|
const n = name.toLowerCase();
|
|
if (n.includes('food')) return '🍔';
|
|
if (n.includes('grocer')) return '🛒';
|
|
if (n.includes('pharma') || n.includes('medic')) return '💊';
|
|
if (n.includes('meat')) return '🥩';
|
|
if (n.includes('flower')) return '💐';
|
|
if (n.includes('electronic')) return '📱';
|
|
if (n.includes('cloth') || n.includes('fashion')) return '👗';
|
|
if (n.includes('bakery') || n.includes('cake')) return '🎂';
|
|
return '📦';
|
|
}; |