From 0896b16ad14bffdae0ffb8245597dea082e8f4d3 Mon Sep 17 00:00:00 2001 From: Pontus Abrahamsson Date: Mon, 13 Nov 2023 17:59:29 +0100 Subject: [PATCH] Revalidate --- apps/dashboard/src/app/api/revalidate/route.ts | 5 ----- apps/dashboard/src/jobs/transactions.ts | 16 +++++++++++++--- apps/dashboard/src/styles/globals.css | 1 - 3 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 apps/dashboard/src/app/api/revalidate/route.ts diff --git a/apps/dashboard/src/app/api/revalidate/route.ts b/apps/dashboard/src/app/api/revalidate/route.ts deleted file mode 100644 index 7f809ddb31..0000000000 --- a/apps/dashboard/src/app/api/revalidate/route.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { NextResponse } from "next/server"; - -export async function GET() { - return NextResponse.json({ ok: true }); -} diff --git a/apps/dashboard/src/jobs/transactions.ts b/apps/dashboard/src/jobs/transactions.ts index 6f6d7e5022..07e2f9689f 100644 --- a/apps/dashboard/src/jobs/transactions.ts +++ b/apps/dashboard/src/jobs/transactions.ts @@ -4,6 +4,7 @@ import { Database } from "@midday/supabase/src/types"; import { eventTrigger } from "@trigger.dev/sdk"; import { Supabase, SupabaseManagement } from "@trigger.dev/supabase"; import { capitalCase } from "change-case"; +import { revalidateTag } from "next/cache"; import { z } from "zod"; const mapTransactionMethod = (method: string) => { @@ -61,7 +62,6 @@ client.defineJob({ id: "bank-account-created", name: "Bank Account Created", version: "1.0.0", - enabled: false, trigger: supabaseTriggers.onInserted({ table: "bank_accounts", }), @@ -92,7 +92,6 @@ client.defineJob({ name: "Transactions - Latest Transactions", version: "1.0.0", trigger: dynamicSchedule, - enabled: false, integrations: { supabase }, run: async (_, io, ctx) => { const { data } = await io.supabase.client @@ -127,6 +126,12 @@ client.defineJob({ ) .select(); + if (transactionsData?.length && transactionsData.length > 0) { + revalidateTag(`transactions_${data?.team_id}`); + revalidateTag(`spending_${data?.team_id}`); + revalidateTag(`metrics_${data?.team_id}`); + } + if (error) { await io.logger.error(JSON.stringify(error, null, 2)); } @@ -139,7 +144,6 @@ client.defineJob({ id: "transactions-initial-sync", name: "Transactions - Initial", version: "1.0.0", - enabled: false, trigger: eventTrigger({ name: "transactions.initial.sync", schema: z.object({ @@ -168,6 +172,12 @@ client.defineJob({ ) .select(); + if (transactionsData?.length && transactionsData.length > 0) { + revalidateTag(`transactions_${teamId}`); + revalidateTag(`spending_${teamId}`); + revalidateTag(`metrics_${teamId}`); + } + if (error) { await io.logger.error(JSON.stringify(error, null, 2)); } diff --git a/apps/dashboard/src/styles/globals.css b/apps/dashboard/src/styles/globals.css index c9e841e6d6..4f653a479e 100644 --- a/apps/dashboard/src/styles/globals.css +++ b/apps/dashboard/src/styles/globals.css @@ -1,7 +1,6 @@ html, body { height: 100%; - overscroll-behavior: none; } *:focus {