mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Add skeleton loaders for ProjectFlock and TransferToLaying
tables
This commit is contained in:
@@ -32,6 +32,7 @@ import StatusBadge from '@/components/helper/StatusBadge';
|
||||
import PopoverButton from '@/components/popover/PopoverButton';
|
||||
import PopoverContent from '@/components/popover/PopoverContent';
|
||||
import ProjectFlockConfirmationModal from './ProjectFlockConfirmationModal';
|
||||
import ProjectFlockTableSkeleton from '@/components/pages/production/project-flock/skeleton/ProjectFlockTableSkeleton';
|
||||
import { useProjectFlockStore } from '@/stores/production/project-flock/project-flock.store';
|
||||
import { ProjectFlockFormValues } from './form/ProjectFlockForm.schema';
|
||||
import { useChickinStore } from '@/stores/production/chickin/chickin.store';
|
||||
@@ -997,12 +998,37 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='flex flex-col mb-4'>
|
||||
{isLoading ? (
|
||||
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||
<span className='loading loading-spinner loading-xl' />
|
||||
</div>
|
||||
) : !isResponseSuccess(projectFlocks) ||
|
||||
projectFlocks.data?.length === 0 ? (
|
||||
<div className='p-3'>
|
||||
<ProjectFlockTableSkeleton
|
||||
columns={columns}
|
||||
icon={
|
||||
<Icon
|
||||
icon='heroicons:document-text'
|
||||
className='text-white'
|
||||
width={20}
|
||||
height={20}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<Table<ProjectFlock>
|
||||
data={isResponseSuccess(projectFlocks) ? projectFlocks?.data : []}
|
||||
data={
|
||||
isResponseSuccess(projectFlocks) ? projectFlocks?.data : []
|
||||
}
|
||||
columns={columns}
|
||||
pageSize={tableFilterState.pageSize}
|
||||
page={
|
||||
isResponseSuccess(projectFlocks) ? projectFlocks?.meta?.page : 0
|
||||
isResponseSuccess(projectFlocks)
|
||||
? projectFlocks?.meta?.page
|
||||
: 0
|
||||
}
|
||||
totalItems={
|
||||
isResponseSuccess(projectFlocks)
|
||||
@@ -1029,14 +1055,12 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
}}
|
||||
withCheckbox
|
||||
className={{
|
||||
containerClassName: cn('p-3', {
|
||||
'w-full mb-20':
|
||||
isResponseSuccess(projectFlocks) &&
|
||||
projectFlocks?.data?.length === 0,
|
||||
}),
|
||||
containerClassName: cn('p-3 mb-0'),
|
||||
headerColumnClassName: 'text-nowrap',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import DataStateSkeleton from '@/components/helper/skeleton/DataStateSkeleton';
|
||||
import Table from '@/components/Table';
|
||||
import { ProjectFlock } from '@/types/api/production/project-flock';
|
||||
import { ColumnDef } from '@tanstack/react-table';
|
||||
|
||||
const ProjectFlockTableSkeleton = ({
|
||||
columns,
|
||||
icon,
|
||||
title = 'No Data Available',
|
||||
subtitle = 'There is no project flock data displayed. Enter project flock data to get started.',
|
||||
}: {
|
||||
columns: ColumnDef<ProjectFlock>[];
|
||||
icon: React.ReactNode;
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
}) => {
|
||||
return (
|
||||
<div className='relative size-full'>
|
||||
<Table
|
||||
data={[]}
|
||||
columns={columns}
|
||||
isLoading={true}
|
||||
className={{
|
||||
skeletonCellClassName: 'animate-none w-full h-5 bg-base-content/4',
|
||||
headerColumnClassName: 'whitespace-nowrap',
|
||||
containerClassName: 'mb-0 overflow-hidden',
|
||||
tableWrapperClassName: 'overflow-hidden',
|
||||
}}
|
||||
/>
|
||||
<div className='absolute inset-0 flex items-center justify-center'>
|
||||
<DataStateSkeleton icon={icon} title={title} description={subtitle} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProjectFlockTableSkeleton;
|
||||
@@ -22,6 +22,7 @@ import Dropdown from '@/components/Dropdown';
|
||||
import StatusBadge from '@/components/helper/StatusBadge';
|
||||
import TransferToLayingFilterModal from '@/components/pages/production/transfer-to-laying/TransferToLayingFilterModal';
|
||||
import TransferToLayingConfirmationModal from '@/components/pages/production/transfer-to-laying/TransferToLayingConfirmationModal';
|
||||
import TransferToLayingTableSkeleton from '@/components/pages/production/transfer-to-laying/skeleton/TransferToLayingTableSkeleton';
|
||||
|
||||
import {
|
||||
TransferToLaying,
|
||||
@@ -596,9 +597,32 @@ const TransferToLayingsTable = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='flex flex-col mb-4'>
|
||||
{isLoading ? (
|
||||
<div className='w-full flex flex-row justify-center items-center p-4'>
|
||||
<span className='loading loading-spinner loading-xl' />
|
||||
</div>
|
||||
) : !isResponseSuccess(transferToLayings) ||
|
||||
transferToLayings.data?.length === 0 ? (
|
||||
<div className='p-3'>
|
||||
<TransferToLayingTableSkeleton
|
||||
columns={transferToLayingsColumns}
|
||||
icon={
|
||||
<Icon
|
||||
icon='heroicons:document-text'
|
||||
className='text-white'
|
||||
width={20}
|
||||
height={20}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<Table<TransferToLaying>
|
||||
data={
|
||||
isResponseSuccess(transferToLayings) ? transferToLayings?.data : []
|
||||
isResponseSuccess(transferToLayings)
|
||||
? transferToLayings?.data
|
||||
: []
|
||||
}
|
||||
columns={transferToLayingsColumns}
|
||||
pageSize={tableFilterState.pageSize}
|
||||
@@ -622,14 +646,12 @@ const TransferToLayingsTable = () => {
|
||||
enableRowSelection={tableEnableRowSelectionHandler}
|
||||
withCheckbox
|
||||
className={{
|
||||
containerClassName: cn('p-3', {
|
||||
'w-full mb-20':
|
||||
isResponseSuccess(transferToLayings) &&
|
||||
transferToLayings?.data?.length === 0,
|
||||
}),
|
||||
containerClassName: cn('p-3 mb-0'),
|
||||
headerColumnClassName: 'text-nowrap',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TransferToLayingFilterModal
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import DataStateSkeleton from '@/components/helper/skeleton/DataStateSkeleton';
|
||||
import Table from '@/components/Table';
|
||||
import { TransferToLaying } from '@/types/api/production/transfer-to-laying';
|
||||
import { ColumnDef } from '@tanstack/react-table';
|
||||
|
||||
const TransferToLayingTableSkeleton = ({
|
||||
columns,
|
||||
icon,
|
||||
title = 'No Data Available',
|
||||
subtitle = 'There is no transfer to laying data displayed. Enter transfer to laying data to get started.',
|
||||
}: {
|
||||
columns: ColumnDef<TransferToLaying>[];
|
||||
icon: React.ReactNode;
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
}) => {
|
||||
return (
|
||||
<div className='relative size-full'>
|
||||
<Table
|
||||
data={[]}
|
||||
columns={columns}
|
||||
isLoading={true}
|
||||
className={{
|
||||
skeletonCellClassName: 'animate-none w-full h-5 bg-base-content/4',
|
||||
headerColumnClassName: 'whitespace-nowrap',
|
||||
containerClassName: 'mb-0 overflow-hidden',
|
||||
tableWrapperClassName: 'overflow-hidden',
|
||||
}}
|
||||
/>
|
||||
<div className='absolute inset-0 flex items-center justify-center'>
|
||||
<DataStateSkeleton icon={icon} title={title} description={subtitle} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TransferToLayingTableSkeleton;
|
||||
Reference in New Issue
Block a user