-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
174 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use server"; | ||
|
||
import { env } from "@/env.mjs"; | ||
import { createClient } from "@midday/supabase/server"; | ||
import { action } from "./safe-action"; | ||
import { sendFeedbackSchema } from "./schema"; | ||
|
||
const baseUrl = "https://api.resend.com"; | ||
|
||
export const sendFeebackAction = action( | ||
sendFeedbackSchema, | ||
async ({ feedback }) => { | ||
const supabase = createClient(); | ||
const { | ||
data: { session }, | ||
} = await supabase.auth.getSession(); | ||
|
||
const res = await fetch(`${baseUrl}/email`, { | ||
method: "POST", | ||
cache: "no-cache", | ||
headers: { | ||
Authorization: `Bearer ${env.RESEND_API_KEY}`, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
from: "feedback@midday.ai", | ||
to: "pontus@lostisland.co", | ||
subject: "Feedback", | ||
text: `${feedback} \nName: ${session?.user?.user_metadata?.name} \nEmail: ${session?.user?.email}`, | ||
}), | ||
}); | ||
|
||
const json = await res.json(); | ||
|
||
return json; | ||
} | ||
); |
23 changes: 23 additions & 0 deletions
23
apps/dashboard/src/actions/update-similar-transactions-action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use server"; | ||
|
||
import { getUser } from "@midday/supabase/cached-queries"; | ||
import { updateSimilarTransactions } from "@midday/supabase/mutations"; | ||
import { createClient } from "@midday/supabase/server"; | ||
import { revalidateTag } from "next/cache"; | ||
import { action } from "./safe-action"; | ||
import { updateSimilarTransactionsSchema } from "./schema"; | ||
|
||
export const updateSimilarTransactionsAction = action( | ||
updateSimilarTransactionsSchema, | ||
async ({ id }) => { | ||
const supabase = createClient(); | ||
const user = await getUser(); | ||
const teamId = user.data.team_id; | ||
|
||
await updateSimilarTransactions(supabase, id); | ||
|
||
revalidateTag(`transactions_${teamId}`); | ||
revalidateTag(`spending_${teamId}`); | ||
revalidateTag(`metrics_${teamId}`); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use server"; | ||
|
||
import { getUser } from "@midday/supabase/cached-queries"; | ||
import { | ||
createEnrichmentTransaction, | ||
updateTransaction, | ||
} from "@midday/supabase/mutations"; | ||
import { createClient } from "@midday/supabase/server"; | ||
import { revalidateTag } from "next/cache"; | ||
import { action } from "./safe-action"; | ||
import { updateTransactionSchema } from "./schema"; | ||
|
||
export const updateTransactionAction = action( | ||
updateTransactionSchema, | ||
async ({ id, ...payload }) => { | ||
const supabase = createClient(); | ||
const user = await getUser(); | ||
const teamId = user.data.team_id; | ||
const { data } = await updateTransaction(supabase, id, payload); | ||
|
||
// Add category to global enrichment_transactions | ||
if (data?.category) { | ||
createEnrichmentTransaction(supabase, { | ||
name: data.name, | ||
category: data.category, | ||
}); | ||
} | ||
|
||
revalidateTag(`transactions_${teamId}`); | ||
revalidateTag(`spending_${teamId}`); | ||
revalidateTag(`metrics_${teamId}`); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.