mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
refactor(FE): Add skeleton loaders for inventory tables
This commit is contained in:
@@ -13,6 +13,7 @@ import { InventoryAdjustmentApi } from '@/services/api/inventory';
|
|||||||
import { useTableFilter } from '@/services/hooks/useTableFilter';
|
import { useTableFilter } from '@/services/hooks/useTableFilter';
|
||||||
import { InventoryAdjustment } from '@/types/api/inventory/adjustment';
|
import { InventoryAdjustment } from '@/types/api/inventory/adjustment';
|
||||||
import StatusBadge from '@/components/helper/StatusBadge';
|
import StatusBadge from '@/components/helper/StatusBadge';
|
||||||
|
import InventoryAdjustmentTableSkeleton from '@/components/pages/inventory/adjustment/skeleton/InventoryAdjustmentTableSkeleton';
|
||||||
|
|
||||||
const InventoryAdjustmentTable = () => {
|
const InventoryAdjustmentTable = () => {
|
||||||
const {
|
const {
|
||||||
@@ -192,6 +193,26 @@ const InventoryAdjustmentTable = () => {
|
|||||||
|
|
||||||
{/* Table Section */}
|
{/* Table Section */}
|
||||||
<div className='flex flex-col mb-4'>
|
<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(inventoryAdjustments) ||
|
||||||
|
inventoryAdjustments.data?.length === 0 ? (
|
||||||
|
<div className='p-3'>
|
||||||
|
<InventoryAdjustmentTableSkeleton
|
||||||
|
columns={inventoryAdjustmentsColumns}
|
||||||
|
icon={
|
||||||
|
<Icon
|
||||||
|
icon='heroicons:document-text'
|
||||||
|
className='text-white'
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<Table<InventoryAdjustment>
|
<Table<InventoryAdjustment>
|
||||||
data={
|
data={
|
||||||
isResponseSuccess(inventoryAdjustments)
|
isResponseSuccess(inventoryAdjustments)
|
||||||
@@ -216,14 +237,11 @@ const InventoryAdjustmentTable = () => {
|
|||||||
sorting={sorting}
|
sorting={sorting}
|
||||||
setSorting={setSorting}
|
setSorting={setSorting}
|
||||||
className={{
|
className={{
|
||||||
containerClassName: cn('p-3 mb-0', {
|
containerClassName: cn('p-3 mb-0'),
|
||||||
'w-full':
|
|
||||||
isResponseSuccess(inventoryAdjustments) &&
|
|
||||||
inventoryAdjustments?.data?.length === 0,
|
|
||||||
}),
|
|
||||||
headerColumnClassName: 'text-nowrap',
|
headerColumnClassName: 'text-nowrap',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
import DataStateSkeleton from '@/components/helper/skeleton/DataStateSkeleton';
|
||||||
|
import Table from '@/components/Table';
|
||||||
|
import { InventoryAdjustment } from '@/types/api/inventory/adjustment';
|
||||||
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
|
|
||||||
|
const InventoryAdjustmentTableSkeleton = ({
|
||||||
|
columns,
|
||||||
|
icon,
|
||||||
|
title = 'No Data Available',
|
||||||
|
subtitle = 'There is no inventory adjustment data displayed. Enter inventory adjustment data to get started.',
|
||||||
|
}: {
|
||||||
|
columns: ColumnDef<InventoryAdjustment>[];
|
||||||
|
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 InventoryAdjustmentTableSkeleton;
|
||||||
@@ -16,6 +16,7 @@ import DebouncedTextInput from '@/components/input/DebouncedTextInput';
|
|||||||
import RequirePermission from '@/components/helper/RequirePermission';
|
import RequirePermission from '@/components/helper/RequirePermission';
|
||||||
import PopoverButton from '@/components/popover/PopoverButton';
|
import PopoverButton from '@/components/popover/PopoverButton';
|
||||||
import PopoverContent from '@/components/popover/PopoverContent';
|
import PopoverContent from '@/components/popover/PopoverContent';
|
||||||
|
import MovementTableSkeleton from '@/components/pages/inventory/movement/skeleton/MovementTableSkeleton';
|
||||||
|
|
||||||
const RowOptionsMenu = ({
|
const RowOptionsMenu = ({
|
||||||
popoverPosition = 'bottom',
|
popoverPosition = 'bottom',
|
||||||
@@ -198,6 +199,25 @@ const MovementTable = () => {
|
|||||||
|
|
||||||
{/* Table Section */}
|
{/* Table Section */}
|
||||||
<div className='flex flex-col mb-4'>
|
<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(movements) || movements.data?.length === 0 ? (
|
||||||
|
<div className='p-3'>
|
||||||
|
<MovementTableSkeleton
|
||||||
|
columns={movementColumns}
|
||||||
|
icon={
|
||||||
|
<Icon
|
||||||
|
icon='heroicons:document-text'
|
||||||
|
className='text-white'
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<Table<Movement>
|
<Table<Movement>
|
||||||
data={isResponseSuccess(movements) ? movements?.data : []}
|
data={isResponseSuccess(movements) ? movements?.data : []}
|
||||||
columns={movementColumns}
|
columns={movementColumns}
|
||||||
@@ -212,13 +232,11 @@ const MovementTable = () => {
|
|||||||
sorting={sorting}
|
sorting={sorting}
|
||||||
setSorting={setSorting}
|
setSorting={setSorting}
|
||||||
className={{
|
className={{
|
||||||
containerClassName: cn('p-3 mb-0', {
|
containerClassName: cn('p-3 mb-0'),
|
||||||
'w-full':
|
|
||||||
isResponseSuccess(movements) && movements?.data?.length === 0,
|
|
||||||
}),
|
|
||||||
headerColumnClassName: 'text-nowrap',
|
headerColumnClassName: 'text-nowrap',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import DataStateSkeleton from '@/components/helper/skeleton/DataStateSkeleton';
|
||||||
|
import Table from '@/components/Table';
|
||||||
|
import { Movement } from '@/types/api/inventory/movement';
|
||||||
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
|
|
||||||
|
const MovementTableSkeleton = ({
|
||||||
|
columns,
|
||||||
|
icon,
|
||||||
|
title = 'No Data Available',
|
||||||
|
subtitle = 'There is no movement data displayed. Enter movement data to get started.',
|
||||||
|
}: {
|
||||||
|
columns: ColumnDef<Movement>[];
|
||||||
|
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 MovementTableSkeleton;
|
||||||
@@ -15,6 +15,7 @@ import { ChangeEventHandler, useMemo, useState } from 'react';
|
|||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import PopoverButton from '@/components/popover/PopoverButton';
|
import PopoverButton from '@/components/popover/PopoverButton';
|
||||||
import PopoverContent from '@/components/popover/PopoverContent';
|
import PopoverContent from '@/components/popover/PopoverContent';
|
||||||
|
import InventoryProductTableSkeleton from '@/components/pages/inventory/product/skeleton/InventoryProductTableSkeleton';
|
||||||
|
|
||||||
const RowOptionsMenu = ({
|
const RowOptionsMenu = ({
|
||||||
popoverPosition = 'bottom',
|
popoverPosition = 'bottom',
|
||||||
@@ -206,9 +207,31 @@ const InventoryProductTable = () => {
|
|||||||
|
|
||||||
{/* Table Section */}
|
{/* Table Section */}
|
||||||
<div className='flex flex-col mb-4'>
|
<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(inventoryProducts) ||
|
||||||
|
inventoryProducts.data?.length === 0 ? (
|
||||||
|
<div className='p-3'>
|
||||||
|
<InventoryProductTableSkeleton
|
||||||
|
columns={columns}
|
||||||
|
icon={
|
||||||
|
<Icon
|
||||||
|
icon='heroicons:document-text'
|
||||||
|
className='text-white'
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<Table<InventoryProduct>
|
<Table<InventoryProduct>
|
||||||
data={
|
data={
|
||||||
isResponseSuccess(inventoryProducts) ? inventoryProducts?.data : []
|
isResponseSuccess(inventoryProducts)
|
||||||
|
? inventoryProducts?.data
|
||||||
|
: []
|
||||||
}
|
}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
pageSize={tableFilterState.pageSize}
|
pageSize={tableFilterState.pageSize}
|
||||||
@@ -228,14 +251,11 @@ const InventoryProductTable = () => {
|
|||||||
sorting={sorting}
|
sorting={sorting}
|
||||||
setSorting={setSorting}
|
setSorting={setSorting}
|
||||||
className={{
|
className={{
|
||||||
containerClassName: cn('p-3 mb-0', {
|
containerClassName: cn('p-3 mb-0'),
|
||||||
'w-full':
|
|
||||||
isResponseSuccess(inventoryProducts) &&
|
|
||||||
inventoryProducts?.data?.length === 0,
|
|
||||||
}),
|
|
||||||
headerColumnClassName: 'text-nowrap',
|
headerColumnClassName: 'text-nowrap',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import DataStateSkeleton from '@/components/helper/skeleton/DataStateSkeleton';
|
||||||
|
import Table from '@/components/Table';
|
||||||
|
import { InventoryProduct } from '@/types/api/inventory/product';
|
||||||
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
|
|
||||||
|
const InventoryProductTableSkeleton = ({
|
||||||
|
columns,
|
||||||
|
icon,
|
||||||
|
title = 'No Data Available',
|
||||||
|
subtitle = 'There is no inventory product data displayed. Enter inventory product data to get started.',
|
||||||
|
}: {
|
||||||
|
columns: ColumnDef<InventoryProduct>[];
|
||||||
|
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 InventoryProductTableSkeleton;
|
||||||
Reference in New Issue
Block a user