Skip to content

Commit

Permalink
Mfa
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 9, 2023
1 parent 5d721d7 commit e79b960
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 34 deletions.
1 change: 1 addition & 0 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ GOCARDLESS_SECRET_KEY=
KV_REST_API_URL=
KV_REST_API_TOKEN=
NOVU_API_KEY=
NEXT_PUBLIC_TRIGGER_API_KEY=
2 changes: 2 additions & 0 deletions apps/dashboard/src/app/[locale]/@dashboard/(root)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ExportStatus } from "@/components/export-status";
import { Header } from "@/components/header";
import { ConnectBankModal } from "@/components/modals/connect-bank-modal";
import { SelectAccountModal } from "@/components/modals/select-account-modal";
Expand All @@ -18,6 +19,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {

<ConnectBankModal countryCode={countryCode} />
<SelectAccountModal countryCode={countryCode} />
<ExportStatus />
</div>
);
}
4 changes: 2 additions & 2 deletions apps/dashboard/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createClient } from "@midday/supabase/server";
import { Provider } from "./provider";
import { Providers } from "./providers";

export default async function Layout({
dashboard,
Expand All @@ -16,5 +16,5 @@ export default async function Layout({
data: { session },
} = await supabase.auth.getSession();

return <Provider locale={locale}>{session ? dashboard : login}</Provider>;
return <Providers locale={locale}>{session ? dashboard : login}</Providers>;
}
13 changes: 0 additions & 13 deletions apps/dashboard/src/app/[locale]/provider.tsx

This file was deleted.

23 changes: 23 additions & 0 deletions apps/dashboard/src/app/[locale]/providers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client";

import { I18nProviderClient } from "@/locales/client";
import { TriggerProvider } from "@trigger.dev/react";
import { ReactNode } from "react";

type ProviderProps = {
locale: string;
children: ReactNode;
};

export function Providers({ locale, children }: ProviderProps) {
return (
<I18nProviderClient locale={locale}>
<TriggerProvider
publicApiKey={process.env.NEXT_PUBLIC_TRIGGER_API_KEY!}
apiUrl={process.env.NEXT_PUBLIC_TRIGGER_API_URL}
>
{children}
</TriggerProvider>
</I18nProviderClient>
);
}
30 changes: 30 additions & 0 deletions apps/dashboard/src/components/export-status.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use client";

import { useToast } from "@midday/ui/use-toast";
import { useEventRunDetails } from "@trigger.dev/react";
import { useEffect } from "react";

export function ExportStatus() {
const { toast } = useToast();
const { data, isLoading } = useEventRunDetails();

useEffect(() => {
toast({
variant: "progress",
title: "Exporting...",
description: "Your export is based on 46 transactions.",
});
}, [isLoading]);

useEffect(() => {
if (data?.status === "FAILURE") {
toast({
duration: 3500,
variant: "error",
title: "Something went wrong pleaase try again.",
});
}
}, [data]);

return null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,23 @@ import {
DialogHeader,
DialogTitle,
} from "@midday/ui/dialog";
import { useToast } from "@midday/ui/use-toast";
import { Loader2 } from "lucide-react";
import { useAction } from "next-safe-action/hook";
import { useSearchParams } from "next/navigation";
import { useEffect } from "react";

export function ExportTransactionsModal({ isOpen, setOpen }) {
const searchParams = useSearchParams();
const { execute, status, result } = useAction(exportTransactionsAction);
const filter = searchParams.get("filter");
const date = filter ? JSON.parse(filter)?.date : null;
const { toast } = useToast();
const { execute, status, result } = useAction(exportTransactionsAction);

useEffect(() => {
if (status === "hasSucceeded" && isOpen) {
setOpen(false);
}
}, [status]);

useEffect(() => {
if (result.data) {
toast({
duration: 6000,
title: "Exporting...",
description: "Your export is ready base on 46 transactions.",
// action: (
// <ToastAction altText="Yes" onClick={handleUpdateSimilar}>
// Yes
// </ToastAction>
// ),
});
}
}, [result]);

return (
<Dialog open={isOpen} onOpenChange={setOpen}>
<DialogContent>
Expand Down
2 changes: 2 additions & 0 deletions apps/dashboard/src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const env = createEnv({
NEXT_PUBLIC_SUPABASE_ANON_KEY: z.string(),
NEXT_PUBLIC_APPLICATION_IDENTIFIER: z.string(),
NEXT_PUBLIC_SUPABASE_ID: z.string(),
NEXT_PUBLIC_TRIGGER_API_KEY: z.string(),
},
/**
* Destructure all variables from `process.env` to make sure they aren't tree-shaken away.
Expand All @@ -49,6 +50,7 @@ export const env = createEnv({
KV_REST_API_TOKEN: process.env.KV_REST_API_TOKEN,
NEXT_PUBLIC_APPLICATION_IDENTIFIER:
process.env.NEXT_PUBLIC_APPLICATION_IDENTIFIER,
NEXT_PUBLIC_TRIGGER_API_KEY: process.env.NEXT_PUBLIC_TRIGGER_API_KEY,
},
skipValidation: !!process.env.CI || !!process.env.SKIP_ENV_VALIDATION,
});
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"@biomejs/biome": "1.4.1",
"@manypkg/cli": "^0.21.1",
"turbo": "^1.11.0",
"turbo": "^1.11.1",
"typescript": "^5.3.3"
},
"devDependencies": {
Expand Down

0 comments on commit e79b960

Please sign in to comment.