Skip to content

Commit

Permalink
feat: include currency_code of the account
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusantguerrero committed Nov 1, 2023
1 parent c3ebbbb commit 77463fd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function share(Request $request)
]);
},
'locale' => app()->getLocale(),
'settings' => $team ? $team->settings->mapWithKeys(fn ($setting) => [$setting['name'] => $setting['value']]) : [],
'accountDetailTypes' => AccountDetailType::all(),
'trialEndsAt' => $team ? $team->trial_ends_at : null,
'unreadNotifications' => function () use ($user) {
Expand Down
5 changes: 5 additions & 0 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ createInertiaApp({
legacy: false,
})

window.logerAppSettings = {
currency_code: props.initialPage.props.settings?.team_primary_currency_code ?? 'USD',
date_format: props.initialPage.props.settings?.team_date_format,
}

const t = (...param) => i18n.global.t(...param)
window.t = t

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
[field]: props.category.id,
source_category_id: data.source_category_id?.value,
'type': 'movement',
date: format(new Date(), 'yyyy-MM-dd')
date: format(startOfMonth(pageState?.dates?.endDate), 'yyyy-MM-dd')
})).post(`/budgets/${props.category.id}/months/${month}`, {
onSuccess() {
router.reload({
Expand Down
5 changes: 3 additions & 2 deletions resources/js/utils/formatMoney.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export const formatMoney = (value, symbol = "DOP") => {
export const formatMoney = (value, symbol = null) => {
const defaultSymbol = symbol ?? window?.logerAppSettings?.currency_code ?? 'DOP';
try {
return new Intl.NumberFormat("en-US", {
style: "currency",
currency: symbol,
currency: defaultSymbol,
currencyDisplay: "symbol"
}).format(Number(value) || 0);
} catch (err) {
Expand Down

0 comments on commit 77463fd

Please sign in to comment.