From 5fee0440c2e103979977214eb4f004d13c50e64b Mon Sep 17 00:00:00 2001 From: Peter Smit Date: Fri, 5 Sep 2025 12:55:05 +0200 Subject: [PATCH] Add main currency code for groups feedback (#329) Clarify group currency field description Use default currency code instead of symbol Hide currency symbol field when using a non-custom Currency Run prettier Update currency data Update package-lock.json --- .env.example | 2 +- messages/en-US.json | 3 +- package-lock.json | 120 +++ .../expenses/create-from-receipt-button.tsx | 7 +- src/components/group-form.tsx | 11 +- src/lib/currency-data.json | 816 ++++++++++++++++++ src/lib/env.ts | 2 +- src/lib/utils.ts | 6 +- 8 files changed, 958 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index b4e87f5..6002a9b 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ POSTGRES_PRISMA_URL=postgresql://postgres:1234@localhost POSTGRES_URL_NON_POOLING=postgresql://postgres:1234@localhost -NEXT_PUBLIC_DEFAULT_CURRENCY_SYMBOL="" \ No newline at end of file +NEXT_PUBLIC_DEFAULT_CURRENCY_CODE="" \ No newline at end of file diff --git a/messages/en-US.json b/messages/en-US.json index 52b37a3..f5ded7c 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -98,7 +98,8 @@ }, "CurrencyCodeField": { "label": "Main currency", - "description": "All amounts and balances will be in this currency. Changing this will NOT convert expenses already entered.", + "createDescription": "All amounts and balances will be in this currency.", + "editDescription": "All amounts and balances will be in this currency. Changing this will NOT convert expenses already entered, except when the currency has different \"minor units\" than the current one (e.g. changing from US Dollar to Japanese Yen)", "customOption": "Custom" }, "Participants": { diff --git a/package-lock.json b/package-lock.json index ca9c2d1..21b75a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5274,6 +5274,126 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@next/swc-darwin-arm64": { + "version": "14.2.28", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.28.tgz", + "integrity": "sha512-kzGChl9setxYWpk3H6fTZXXPFFjg7urptLq5o5ZgYezCrqlemKttwMT5iFyx/p1e/JeglTwDFRtb923gTJ3R1w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "14.2.28", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.28.tgz", + "integrity": "sha512-z6FXYHDJlFOzVEOiiJ/4NG8aLCeayZdcRSMjPDysW297Up6r22xw6Ea9AOwQqbNsth8JNgIK8EkWz2IDwaLQcw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.2.28", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.28.tgz", + "integrity": "sha512-9ARHLEQXhAilNJ7rgQX8xs9aH3yJSj888ssSjJLeldiZKR4D7N08MfMqljk77fAwZsWwsrp8ohHsMvurvv9liQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.2.28", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.28.tgz", + "integrity": "sha512-p6gvatI1nX41KCizEe6JkF0FS/cEEF0u23vKDpl+WhPe/fCTBeGkEBh7iW2cUM0rvquPVwPWdiUR6Ebr/kQWxQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.2.28", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.28.tgz", + "integrity": "sha512-nsiSnz2wO6GwMAX2o0iucONlVL7dNgKUqt/mDTATGO2NY59EO/ZKnKEr80BJFhuA5UC1KZOMblJHWZoqIJddpA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.2.28", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.28.tgz", + "integrity": "sha512-+IuGQKoI3abrXFqx7GtlvNOpeExUH1mTIqCrh1LGFf8DnlUcTmOOCApEnPJUSLrSbzOdsF2ho2KhnQoO0I1RDw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.2.28", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.28.tgz", + "integrity": "sha512-l61WZ3nevt4BAnGksUVFKy2uJP5DPz2E0Ma/Oklvo3sGj9sw3q7vBWONFRgz+ICiHpW5mV+mBrkB3XEubMrKaA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.2.28", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.28.tgz", + "integrity": "sha512-+Kcp1T3jHZnJ9v9VTJ/yf1t/xmtFAc/Sge4v7mVc1z+NYfYzisi8kJ9AsY8itbgq+WgEwMtOpiLLJsUy2qnXZw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@next/swc-win32-x64-msvc": { "version": "14.2.28", "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.28.tgz", diff --git a/src/app/groups/[groupId]/expenses/create-from-receipt-button.tsx b/src/app/groups/[groupId]/expenses/create-from-receipt-button.tsx index 4e06c71..53a6d72 100644 --- a/src/app/groups/[groupId]/expenses/create-from-receipt-button.tsx +++ b/src/app/groups/[groupId]/expenses/create-from-receipt-button.tsx @@ -26,7 +26,12 @@ import { import { ToastAction } from '@/components/ui/toast' import { useToast } from '@/components/ui/use-toast' import { useMediaQuery } from '@/lib/hooks' -import { formatCurrency, formatDate, formatFileSize, getCurrencyFromGroup } from '@/lib/utils' +import { + formatCurrency, + formatDate, + formatFileSize, + getCurrencyFromGroup, +} from '@/lib/utils' import { trpc } from '@/trpc/client' import { ChevronRight, FileQuestion, Loader2, Receipt } from 'lucide-react' import { useLocale, useTranslations } from 'next-intl' diff --git a/src/components/group-form.tsx b/src/components/group-form.tsx index 5cf2410..ea3235e 100644 --- a/src/components/group-form.tsx +++ b/src/components/group-form.tsx @@ -72,7 +72,7 @@ export function GroupForm({ : { name: '', information: '', - currency: process.env.NEXT_PUBLIC_DEFAULT_CURRENCY_SYMBOL || '', + currencyCode: process.env.NEXT_PUBLIC_DEFAULT_CURRENCY_CODE || 'USD', // TODO: If NEXT_PUBLIC_DEFAULT_CURRENCY_CODE, is not set, determine the default currency code based on locale participants: [ { name: t('Participants.John') }, { name: t('Participants.Jane') }, @@ -176,7 +176,11 @@ export function GroupForm({ isLoading={false} /> - {t('CurrencyCodeField.description')} + {t( + group + ? 'CurrencyCodeField.editDescription' + : 'CurrencyCodeField.createDescription', + )} @@ -187,13 +191,12 @@ export function GroupForm({ control={form.control} name="currency" render={({ field }) => ( - +