forked from cartsnitch/cartsnitch
feat: add utility functions with unit tests
Add formatCurrency, formatDate, and storeSlugs utilities in src/utils/ with 21 vitest unit tests covering standard and edge cases. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
export const STORE_SLUGS: Record<string, { name: string; color: string; icon: string }> = {
|
||||
meijer: { name: 'Meijer', color: '#e31837', icon: '/icons/stores/meijer.svg' },
|
||||
kroger: { name: 'Kroger', color: '#0033a0', icon: '/icons/stores/kroger.svg' },
|
||||
target: { name: 'Target', color: '#cc0000', icon: '/icons/stores/target.svg' },
|
||||
};
|
||||
|
||||
export function getStore(slug: string) {
|
||||
return STORE_SLUGS[slug.toLowerCase()] ?? null;
|
||||
}
|
||||
|
||||
export function getStoreName(slug: string): string {
|
||||
return getStore(slug)?.name ?? slug;
|
||||
}
|
||||
Reference in New Issue
Block a user