Merge branch 'fix/inventory-product' into 'development'

[FIX/FE] Inventory Product

See merge request mbugroup/lti-web-client!463
This commit is contained in:
Rivaldi A N S
2026-05-06 03:53:42 +00:00
3 changed files with 105 additions and 83 deletions
+1 -1
View File
@@ -226,7 +226,7 @@ const Pagination = ({
const PageInfo = () => ( const PageInfo = () => (
<span className='text-nowrap text-sm font-medium text-base-content/50'> <span className='text-nowrap text-sm font-medium text-base-content/50'>
Page {currentPage} of {totalPages} Total Item: {totalItems} | Page {currentPage} of {totalPages}
</span> </span>
); );
@@ -1,13 +1,76 @@
import Card from '@/components/Card'; import Card from '@/components/Card';
import Table from '@/components/Table'; import Table from '@/components/Table';
import { formatDate, formatNumber, formatTitleCase } from '@/lib/helper'; import { formatDate, formatNumber, formatTitleCase } from '@/lib/helper';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { StockLog } from '@/types/api/inventory/product'; import { StockLog } from '@/types/api/inventory/product';
import { ColumnDef } from '@tanstack/react-table';
const stockLogTableColumns: ColumnDef<StockLog>[] = [
{
header: 'ID',
accessorKey: 'id',
},
{
header: 'Tanggal',
accessorKey: 'created_at',
cell: (props) => {
return formatDate(props.row.original.created_at, 'DD-MMM-yyyy');
},
},
{
header: 'Gudang',
accessorKey: 'warehouse_name',
},
{
header: 'Stock Akhir',
accessorKey: 'stock',
cell: (props) => {
return formatNumber(props.row.original.stock);
},
},
{
header: 'Peningkatan',
accessorKey: 'increase',
cell: (props) => {
return formatNumber(props.row.original.increase);
},
},
{
header: 'Penurunan',
accessorKey: 'decrease',
cell: (props) => {
return formatNumber(props.row.original.decrease);
},
},
{
header: 'Jenis Transaksi',
accessorKey: 'loggable_type',
cell: (props) => {
return props.row.original.loggable_type
? formatTitleCase(props.row.original.loggable_type)
: '-';
},
},
{
header: 'Catatan',
accessorKey: 'notes',
cell: (props) => {
return props.row.original.notes ? props.row.original.notes : '-';
},
},
{
header: 'Oleh',
accessorKey: 'created_user.name',
},
];
const StockLogTable = ({ const StockLogTable = ({
stockLogs, stockLogs,
}: { }: {
stockLogs: (StockLog & { warehouse_name: string; warehouse_id: number })[]; stockLogs: (StockLog & { warehouse_name: string; warehouse_id: number })[];
}) => { }) => {
const { state: tableFilterState, setPage, setPageSize } = useTableFilter();
return ( return (
<Card <Card
title='Informasi Stock Produk' title='Informasi Stock Produk'
@@ -19,64 +82,12 @@ const StockLogTable = ({
> >
<Table<StockLog> <Table<StockLog>
data={stockLogs} data={stockLogs}
columns={[ columns={stockLogTableColumns}
{ page={tableFilterState.page ?? 0}
header: 'ID', pageSize={tableFilterState.pageSize}
accessorKey: 'id', onPageChange={setPage}
}, onPageSizeChange={setPageSize}
{ totalItems={stockLogs?.length ?? 0}
header: 'Tanggal',
accessorKey: 'created_at',
cell: (props) => {
return formatDate(props.row.original.created_at, 'DD-MMM-yyyy');
},
},
{
header: 'Gudang',
accessorKey: 'warehouse_name',
},
{
header: 'Stock Akhir',
accessorKey: 'stock',
cell: (props) => {
return formatNumber(props.row.original.stock);
},
},
{
header: 'Peningkatan',
accessorKey: 'increase',
cell: (props) => {
return formatNumber(props.row.original.increase);
},
},
{
header: 'Penurunan',
accessorKey: 'decrease',
cell: (props) => {
return formatNumber(props.row.original.decrease);
},
},
{
header: 'Jenis Transaksi',
accessorKey: 'loggable_type',
cell: (props) => {
return props.row.original.loggable_type
? formatTitleCase(props.row.original.loggable_type)
: '-';
},
},
{
header: 'Catatan',
accessorKey: 'notes',
cell: (props) => {
return props.row.original.notes ? props.row.original.notes : '-';
},
},
{
header: 'Oleh',
accessorKey: 'created_user.name',
},
]}
className={{ className={{
containerClassName: 'mt-6', containerClassName: 'mt-6',
tableWrapperClassName: 'overflow-x-auto min-h-full!', tableWrapperClassName: 'overflow-x-auto min-h-full!',
@@ -1,13 +1,42 @@
import Card from '@/components/Card'; import Card from '@/components/Card';
import Table from '@/components/Table'; import Table from '@/components/Table';
import { formatNumber } from '@/lib/helper'; import { formatNumber } from '@/lib/helper';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { ProductWarehouseStock } from '@/types/api/inventory/product'; import { ProductWarehouseStock } from '@/types/api/inventory/product';
import { ColumnDef } from '@tanstack/react-table';
const stockProductWarehouseTableColumns: ColumnDef<ProductWarehouseStock>[] = [
{
header: 'Nama Gudang',
accessorKey: 'warehouse_name',
},
{
header: 'Lokasi',
accessorKey: 'location',
cell: (props) => {
return props.row.original.location != null
? props.row.original.location.name
: '-';
},
},
{
header: 'Stok',
accessorFn(row) {
return row.current_stock;
},
cell: (props) => {
return formatNumber(props.row.original.current_stock);
},
},
];
const StockProductWarehouseTable = ({ const StockProductWarehouseTable = ({
productWarehouseStock, productWarehouseStock,
}: { }: {
productWarehouseStock?: ProductWarehouseStock[]; productWarehouseStock?: ProductWarehouseStock[];
}) => { }) => {
const { state: tableFilterState, setPage, setPageSize } = useTableFilter();
return ( return (
<Card <Card
title='Informasi Gudang' title='Informasi Gudang'
@@ -19,30 +48,12 @@ const StockProductWarehouseTable = ({
> >
<Table<ProductWarehouseStock> <Table<ProductWarehouseStock>
data={productWarehouseStock ?? []} data={productWarehouseStock ?? []}
columns={[ columns={stockProductWarehouseTableColumns}
{ pageSize={tableFilterState.pageSize}
header: 'Nama Gudang', page={tableFilterState.page ?? 0}
accessorKey: 'warehouse_name', totalItems={productWarehouseStock?.length ?? 0}
}, onPageChange={setPage}
{ onPageSizeChange={setPageSize}
header: 'Lokasi',
accessorKey: 'location',
cell: (props) => {
return props.row.original.location != null
? props.row.original.location.name
: '-';
},
},
{
header: 'Stok',
accessorFn(row) {
return row.current_stock;
},
cell: (props) => {
return formatNumber(props.row.original.current_stock);
},
},
]}
className={{ className={{
containerClassName: 'mt-6', containerClassName: 'mt-6',
tableWrapperClassName: 'overflow-x-auto min-h-full!', tableWrapperClassName: 'overflow-x-auto min-h-full!',