uveden umjetni delay
This commit is contained in:
@@ -8,6 +8,7 @@ import { withUser } from '@/app/lib/auth';
|
|||||||
import { AuthenticatedUser } from '../types/next-auth';
|
import { AuthenticatedUser } from '../types/next-auth';
|
||||||
import { gotoHome } from './navigationActions';
|
import { gotoHome } from './navigationActions';
|
||||||
import { Noto_Sans_Tamil_Supplement } from 'next/font/google';
|
import { Noto_Sans_Tamil_Supplement } from 'next/font/google';
|
||||||
|
import { asyncTimeout } from '../asyncTimeout';
|
||||||
|
|
||||||
export type State = {
|
export type State = {
|
||||||
errors?: {
|
errors?: {
|
||||||
@@ -81,6 +82,8 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await asyncTimeout(1000);
|
||||||
|
|
||||||
if(yearMonth) await gotoHome(yearMonth);
|
if(yearMonth) await gotoHome(yearMonth);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -109,6 +112,8 @@ export const fetchAllLocations = withUser(async (user:AuthenticatedUser, year:nu
|
|||||||
})
|
})
|
||||||
.toArray();
|
.toArray();
|
||||||
|
|
||||||
|
await asyncTimeout(1000);
|
||||||
|
|
||||||
return(locations);
|
return(locations);
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -126,6 +131,8 @@ export const fetchLocationById = withUser(async (user:AuthenticatedUser, locatio
|
|||||||
return(null);
|
return(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await asyncTimeout(1000);
|
||||||
|
|
||||||
return(billLocation);
|
return(billLocation);
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -138,5 +145,7 @@ export const deleteLocationById = withUser(async (user:AuthenticatedUser, locati
|
|||||||
// find a location with the given locationID
|
// find a location with the given locationID
|
||||||
const post = await dbClient.collection<BillingLocation>("lokacije").deleteOne({ _id: locationID, userId });
|
const post = await dbClient.collection<BillingLocation>("lokacije").deleteOne({ _id: locationID, userId });
|
||||||
|
|
||||||
|
await asyncTimeout(1000);
|
||||||
|
|
||||||
await gotoHome(yearMonth)
|
await gotoHome(yearMonth)
|
||||||
})
|
})
|
||||||
2
app/lib/asyncTimeout.ts
Normal file
2
app/lib/asyncTimeout.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
export const asyncTimeout = (ms: number = 1000) => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
Reference in New Issue
Block a user