Skip to content

Instantly share code, notes, and snippets.

View vim-diesel's full-sized avatar

Ian vim-diesel

  • Canada
View GitHub Profile
"use server";
import { AppError, PlainAppError } from "@/errors";
import { MonthlyCategoryDetails } from "@/types";
import { createServersideClient } from "@/utils/supabase/server";
import { revalidatePath } from "next/cache";
// Updates the assigned amount for a category in a monthly budget
export async function updateAssigned(
monthlyBudgetId: number,
@vim-diesel
vim-diesel / actions.ts
Created November 27, 2024 19:21
nextjs data fetching
"use server";
// fetch the data
export async function getData() {
const { data, error } = await supabase.
// fethces data from db
if (!error) {
return data
}
// ...
}
@vim-diesel
vim-diesel / actions.ts
Last active November 12, 2024 16:43
Testing a Server Action using Jest & Displaying a Table of Transactions
/* User can add a transaction row.
Date Handling: use only the date part of the ISO string to match
schema's timestamp without time zone.
We don't return the data inserted into the table, just null.
*/
// Inputs:
// budgetId - the ID of the budget to add the transaction to (number)