diff --git a/apps/dashboard/src/actions/change-country-code-action.ts b/apps/dashboard/src/actions/change-country-code-action.ts new file mode 100644 index 000000000..60f9fd823 --- /dev/null +++ b/apps/dashboard/src/actions/change-country-code-action.ts @@ -0,0 +1,15 @@ +"use server"; + +import { Cookies } from "@/utils/constants"; +import { cookies } from "next/headers"; +import { z } from "zod"; +import { action } from "./safe-action"; + +export const changeCountryCodeAction = action(z.string(), async (value) => { + cookies().set({ + name: Cookies.CountryCode, + value, + }); + + return value; +}); diff --git a/apps/dashboard/src/app/[locale]/(app)/@dashboard/(root)/layout.tsx b/apps/dashboard/src/app/[locale]/(app)/@dashboard/(root)/layout.tsx index 0a82290aa..f722b4814 100644 --- a/apps/dashboard/src/app/[locale]/(app)/@dashboard/(root)/layout.tsx +++ b/apps/dashboard/src/app/[locale]/(app)/@dashboard/(root)/layout.tsx @@ -20,7 +20,10 @@ export default async function Layout({ children: React.ReactNode; }) { const user = await getUser(); - const countryCode = getCountryCode(); + const countryCode = cookies().has(Cookies.CountryCode) + ? cookies().get(Cookies.CountryCode)?.value + : getCountryCode(); + const isEU = isEUCountry(countryCode); const mobileOverlay = cookies().has(Cookies.MobileOverlay); diff --git a/apps/dashboard/src/components/country-selector.tsx b/apps/dashboard/src/components/country-selector.tsx index 84d5e3894..c437a545f 100644 --- a/apps/dashboard/src/components/country-selector.tsx +++ b/apps/dashboard/src/components/country-selector.tsx @@ -48,7 +48,7 @@ export function CountrySelector({ defaultValue, onSelect }) { - + No country found. {Object.values(countries).map((country) => ( diff --git a/apps/dashboard/src/components/modals/connect-gocardless-modal.tsx b/apps/dashboard/src/components/modals/connect-gocardless-modal.tsx index 7cd7a6331..a6a160dc4 100644 --- a/apps/dashboard/src/components/modals/connect-gocardless-modal.tsx +++ b/apps/dashboard/src/components/modals/connect-gocardless-modal.tsx @@ -2,6 +2,7 @@ import { createEndUserAgreementAction } from "@/actions/banks/create-end-user-agreement-action"; import { getBanks } from "@/actions/banks/get-banks"; +import { changeCountryCodeAction } from "@/actions/change-country-code-action"; import { Button } from "@midday/ui/button"; import { Dialog, @@ -102,6 +103,10 @@ export function ConnectGoCardLessModal({ countryCode: initialCountryCode }) { const [results, setResults] = useState([]); const [filteredResults, setFilteredResults] = useState([]); + const changeCountryCode = useAction(changeCountryCodeAction, { + onSuccess: (value) => setCountryCode(value), + }); + const createEndUserAgreement = useAction(createEndUserAgreementAction); const [step, setStep] = useQueryState("step"); @@ -177,7 +182,7 @@ export function ConnectGoCardLessModal({ countryCode: initialCountryCode }) { diff --git a/apps/dashboard/src/components/modals/select-bank-accounts.tsx b/apps/dashboard/src/components/modals/select-bank-accounts.tsx index aa591f660..23d0e00a5 100644 --- a/apps/dashboard/src/components/modals/select-bank-accounts.tsx +++ b/apps/dashboard/src/components/modals/select-bank-accounts.tsx @@ -139,12 +139,12 @@ export function SelectBankAccountsModal({ countryCode }: Props) { accessToken: token, enrollmentId: enrollment_id, accounts: data.map((account) => ({ - account_id: account.id, - bank_name: account.institution.name, - currency: account.currency, name: account.name, institution_id: account.institution.id, logo_url: account.institution?.logo, + account_id: account.id, + bank_name: account.institution.name, + currency: account.currency, enabled: false, })), }); diff --git a/apps/dashboard/src/utils/constants.ts b/apps/dashboard/src/utils/constants.ts index 19ef72625..55f162173 100644 --- a/apps/dashboard/src/utils/constants.ts +++ b/apps/dashboard/src/utils/constants.ts @@ -11,4 +11,5 @@ export const Cookies = { TrackingConsent: "tracking-consent", ChartCurrency: "chart-currency", InboxOrder: "inbox-order", + CountryCode: "country-code", }; diff --git a/packages/ui/src/components/dialog.tsx b/packages/ui/src/components/dialog.tsx index 62d2f50f9..a4e0cef8b 100644 --- a/packages/ui/src/components/dialog.tsx +++ b/packages/ui/src/components/dialog.tsx @@ -35,7 +35,7 @@ const DialogContent = React.forwardRef< -
- {children} -
+
{children}
{!hideClose && ( diff --git a/packages/ui/src/components/input.tsx b/packages/ui/src/components/input.tsx index 6d8d18e69..300d4b18c 100644 --- a/packages/ui/src/components/input.tsx +++ b/packages/ui/src/components/input.tsx @@ -10,7 +10,7 @@ const Input = React.forwardRef(