update set delay loading skeleton on master data
This commit is contained in:
@ -27,8 +27,8 @@ import {
|
||||
import { doSaveLogActivity } from '@/actions/GlobalActions';
|
||||
|
||||
interface SucosProps {
|
||||
sucos_id: number;
|
||||
sucos_name: string;
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const API_URL = apiConfig.service_master_data;
|
||||
@ -181,7 +181,7 @@ const AddDialog = () => {
|
||||
className="input col-span-5 text-left"
|
||||
style={{ color: 'inherit' }}
|
||||
>
|
||||
{sucos.find((suco) => suco.sucos_id === formField.sucosId)?.sucos_name ||
|
||||
{sucos.find((suco) => suco.id === formField.sucosId)?.name ||
|
||||
'Select Sucos'}
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
@ -196,17 +196,17 @@ const AddDialog = () => {
|
||||
<CommandGroup>
|
||||
{sucos.map((suco) => (
|
||||
<CommandItem
|
||||
key={suco.sucos_id}
|
||||
value={suco.sucos_name}
|
||||
key={suco.id}
|
||||
value={suco.name}
|
||||
onSelect={() => {
|
||||
setFormField({
|
||||
...formField,
|
||||
sucosId: suco.sucos_id
|
||||
sucosId: suco.id
|
||||
});
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
{suco.sucos_name}
|
||||
{suco.name}
|
||||
</CommandItem>
|
||||
))}
|
||||
</CommandGroup>
|
||||
|
||||
@ -4,7 +4,14 @@ import { Alert, useDataGrid } from '@/components';
|
||||
import { useCallApi } from '@/hooks';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { toast } from 'sonner';
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader } from '@/components/ui/dialog';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from '@/components/ui/dialog';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { doSaveLogActivity } from '@/actions/GlobalActions';
|
||||
|
||||
@ -52,6 +59,8 @@ const DeleteDialog = () => {
|
||||
<Dialog open={showDeleteDialog} onOpenChange={(open) => handleDeleteDialog(open, null)}>
|
||||
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||
<DialogHeader className="p-0 border-0 block">
|
||||
<DialogTitle></DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
<Alert variant="warning">
|
||||
<h3 className="text-lg">Are you sure?</h3>
|
||||
<span className="text-sm">You will delete this data!</span>
|
||||
|
||||
@ -98,7 +98,7 @@ const EditDialog = () => {
|
||||
});
|
||||
|
||||
setSucos(response?.data.list);
|
||||
console.log(sucos);
|
||||
// console.log(sucos);
|
||||
} catch (error) {
|
||||
console.error('Error fetching Sucos', error);
|
||||
setAlert({ show: true, message: 'Failed to get Sucos. Please try again.' });
|
||||
@ -107,7 +107,10 @@ const EditDialog = () => {
|
||||
|
||||
const doFetchData = useCallback(async (id: string) => {
|
||||
setIsLoading(true);
|
||||
const response = await GetData(`${API_URL}/aldeias/getdata/${id}`, { id });
|
||||
|
||||
const minDelay = new Promise((resolve) => setTimeout(resolve, 300));
|
||||
const fetchData = GetData(`${API_URL}/aldeias/getdata/${id}`, { id });
|
||||
const [response] = await Promise.all([fetchData, minDelay]);
|
||||
|
||||
if (response?.status) {
|
||||
setFormField((prev) => ({
|
||||
@ -221,8 +224,8 @@ const EditDialog = () => {
|
||||
className="input col-span-5 text-left"
|
||||
style={{ color: 'inherit' }}
|
||||
>
|
||||
{sucos.find((suco) => suco.id === formField.sucosId)
|
||||
?.name || 'Select Sucos'}
|
||||
{sucos.find((suco) => suco.id === formField.sucosId)?.name ||
|
||||
'Select Sucos'}
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-[400px] p-0">
|
||||
|
||||
Reference in New Issue
Block a user