uveden umjetni delay

This commit is contained in:
2024-02-06 09:56:43 +01:00
parent 0ce7b11c3c
commit 7f08349688
2 changed files with 11 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ 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 { asyncTimeout } from '../asyncTimeout';
export type State = {
errors?: {
@@ -81,6 +82,8 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
});
}
await asyncTimeout(1000);
if(yearMonth) await gotoHome(yearMonth);
return {
@@ -109,6 +112,8 @@ export const fetchAllLocations = withUser(async (user:AuthenticatedUser, year:nu
})
.toArray();
await asyncTimeout(1000);
return(locations);
})
@@ -126,6 +131,8 @@ export const fetchLocationById = withUser(async (user:AuthenticatedUser, locatio
return(null);
}
await asyncTimeout(1000);
return(billLocation);
})
@@ -138,5 +145,7 @@ export const deleteLocationById = withUser(async (user:AuthenticatedUser, locati
// find a location with the given locationID
const post = await dbClient.collection<BillingLocation>("lokacije").deleteOne({ _id: locationID, userId });
await asyncTimeout(1000);
await gotoHome(yearMonth)
})

2
app/lib/asyncTimeout.ts Normal file
View File

@@ -0,0 +1,2 @@
export const asyncTimeout = (ms: number = 1000) => new Promise(resolve => setTimeout(resolve, ms));