za actions dodan "noStore"

This commit is contained in:
2024-02-06 14:17:12 +01:00
parent cf97b3d4b5
commit f0581eb533
2 changed files with 14 additions and 1 deletions

View File

@@ -7,7 +7,7 @@ import { ObjectId } from 'mongodb';
import { withUser } from '@/app/lib/auth';
import { AuthenticatedUser } from '../types/next-auth';
import { gotoHome } from './navigationActions';
import { Noto_Sans_Tamil_Supplement } from 'next/font/google';
import { unstable_noStore as noStore } from 'next/cache';
import { asyncTimeout } from '../asyncTimeout';
export type State = {
@@ -35,6 +35,8 @@ const UpdateLocation = FormSchema.omit({ _id: true });
*/
export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locationId: string | undefined, yearMonth: YearMonth | undefined, prevState:State, formData: FormData) => {
noStore();
const validatedFields = UpdateLocation.safeParse({
locationName: formData.get('locationName'),
locationNotes: formData.get('locationNotes'),
@@ -95,6 +97,8 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
export const fetchAllLocations = withUser(async (user:AuthenticatedUser, year:number) => {
noStore();
const dbClient = await getDbClient();
const { id: userId } = user;
@@ -119,6 +123,8 @@ export const fetchAllLocations = withUser(async (user:AuthenticatedUser, year:nu
export const fetchLocationById = withUser(async (user:AuthenticatedUser, locationID:string) => {
noStore();
const dbClient = await getDbClient();
const { id: userId } = user;
@@ -138,6 +144,8 @@ export const fetchLocationById = withUser(async (user:AuthenticatedUser, locatio
export const deleteLocationById = withUser(async (user:AuthenticatedUser, locationID:string, yearMonth:YearMonth) => {
noStore();
const dbClient = await getDbClient();
const { id: userId } = user;