mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
Merge branch 'fix/adjustment-transfer-stock' into 'development'
[FIX/FE] Adjustment Transfer Stock's Issues and Purchase Table See merge request mbugroup/lti-web-client!262
This commit is contained in:
@@ -2,7 +2,7 @@ import ExpensesTable from '@/components/pages/expense/ExpensesTable';
|
|||||||
|
|
||||||
const Expense = () => {
|
const Expense = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full p-4 sm:p-0'>
|
||||||
<ExpensesTable />
|
<ExpensesTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import MovementTable from '@/components/pages/inventory/movement/MovementTable';
|
|||||||
|
|
||||||
const Movement = () => {
|
const Movement = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full p-4 sm:p-0'>
|
||||||
<MovementTable />
|
<MovementTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import RecordingTable from '@/components/pages/production/recording/RecordingTab
|
|||||||
|
|
||||||
const Recording = () => {
|
const Recording = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full p-4 sm:p-0'>
|
||||||
<RecordingTable />
|
<RecordingTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import PurchaseTable from '@/components/pages/purchase/PurchaseTable';
|
|||||||
|
|
||||||
const Purchase = () => {
|
const Purchase = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full p-4 sm:p-0'>
|
||||||
<PurchaseTable />
|
<PurchaseTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ type MovementFormSchemaType = {
|
|||||||
value: number;
|
value: number;
|
||||||
label: string;
|
label: string;
|
||||||
} | null;
|
} | null;
|
||||||
supplier_id: number;
|
supplier_id?: number | null;
|
||||||
products: {
|
products: {
|
||||||
product?: {
|
product?: {
|
||||||
value: number;
|
value: number;
|
||||||
@@ -69,7 +69,7 @@ export type DeliverySchema = {
|
|||||||
value: number;
|
value: number;
|
||||||
label: string;
|
label: string;
|
||||||
} | null;
|
} | null;
|
||||||
supplier_id: number;
|
supplier_id?: number | null;
|
||||||
products: {
|
products: {
|
||||||
product?: {
|
product?: {
|
||||||
value: number;
|
value: number;
|
||||||
@@ -151,9 +151,10 @@ const DeliveryObjectSchema: Yup.ObjectSchema<DeliverySchema> = Yup.object({
|
|||||||
label: Yup.string().required(),
|
label: Yup.string().required(),
|
||||||
}).nullable(),
|
}).nullable(),
|
||||||
supplier_id: Yup.number()
|
supplier_id: Yup.number()
|
||||||
.required('Supplier wajib diisi!')
|
.optional()
|
||||||
|
.nullable()
|
||||||
.min(1, 'Supplier wajib diisi!')
|
.min(1, 'Supplier wajib diisi!')
|
||||||
.typeError('Supplier wajib diisi!'),
|
.typeError('Supplier harus berupa angka!'),
|
||||||
products: Yup.array()
|
products: Yup.array()
|
||||||
.of(DeliveryProductObjectSchema)
|
.of(DeliveryProductObjectSchema)
|
||||||
.min(1, 'Minimal harus ada 1 produk!')
|
.min(1, 'Minimal harus ada 1 produk!')
|
||||||
|
|||||||
@@ -1494,7 +1494,7 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{formik.values.products?.map((product, idx) => (
|
{formik.values.products?.map((product, idx) => (
|
||||||
<tr key={`product-row-${idx}-${product.product_id}`}>
|
<tr key={`product-row-${idx}`}>
|
||||||
{type !== 'detail' && (
|
{type !== 'detail' && (
|
||||||
<td className='align-middle!'>
|
<td className='align-middle!'>
|
||||||
<CheckboxInput
|
<CheckboxInput
|
||||||
@@ -1665,15 +1665,7 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
|||||||
<span className='text-error'>*</span>
|
<span className='text-error'>*</span>
|
||||||
</span>
|
</span>
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>Supplier</th>
|
||||||
Supplier
|
|
||||||
<span
|
|
||||||
className='tooltip tooltip-error tooltip-bottom z-9999'
|
|
||||||
data-tip='required'
|
|
||||||
>
|
|
||||||
<span className='text-error'>*</span>
|
|
||||||
</span>
|
|
||||||
</th>
|
|
||||||
<th>
|
<th>
|
||||||
Plat Nomor
|
Plat Nomor
|
||||||
<span
|
<span
|
||||||
@@ -1716,9 +1708,7 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{formik.values.deliveries?.map((delivery, idx) => (
|
{formik.values.deliveries?.map((delivery, idx) => (
|
||||||
<tr
|
<tr key={`delivery-row-${idx}`}>
|
||||||
key={`delivery-row-${idx}-${delivery.supplier_id}-${delivery.vehicle_plate}`}
|
|
||||||
>
|
|
||||||
{type !== 'detail' && (
|
{type !== 'detail' && (
|
||||||
<td className='align-middle!'>
|
<td className='align-middle!'>
|
||||||
<CheckboxInput
|
<CheckboxInput
|
||||||
@@ -1787,7 +1777,6 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<SelectInput
|
<SelectInput
|
||||||
required
|
|
||||||
placeholder='Pilih supplier...'
|
placeholder='Pilih supplier...'
|
||||||
value={delivery.supplier}
|
value={delivery.supplier}
|
||||||
onChange={(val) =>
|
onChange={(val) =>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { ChangeEventHandler, useEffect, useState } from 'react';
|
import { ChangeEventHandler, useEffect, useRef, useState } from 'react';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table';
|
import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
@@ -22,6 +22,7 @@ import { ProductCategoryApi } from '@/services/api/master-data';
|
|||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { useTableFilter } from '@/services/hooks/useTableFilter';
|
import { useTableFilter } from '@/services/hooks/useTableFilter';
|
||||||
|
import { useUiStore } from '@/stores/ui/ui.store';
|
||||||
import { ROWS_OPTIONS } from '@/config/constant';
|
import { ROWS_OPTIONS } from '@/config/constant';
|
||||||
|
|
||||||
const RowOptionsMenu = ({
|
const RowOptionsMenu = ({
|
||||||
@@ -80,6 +81,9 @@ const RowOptionsMenu = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ProductCategoryTable = () => {
|
const ProductCategoryTable = () => {
|
||||||
|
const { searchValue, setSearchValue, resetSearchValue } = useUiStore();
|
||||||
|
const previousPathRef = useRef<string | null>(null);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
state: tableFilterState,
|
state: tableFilterState,
|
||||||
updateFilter,
|
updateFilter,
|
||||||
@@ -87,7 +91,7 @@ const ProductCategoryTable = () => {
|
|||||||
setPageSize,
|
setPageSize,
|
||||||
toQueryString: getTableFilterQueryString,
|
toQueryString: getTableFilterQueryString,
|
||||||
} = useTableFilter({
|
} = useTableFilter({
|
||||||
initial: { search: '', nameSort: '' },
|
initial: { search: searchValue, nameSort: '' },
|
||||||
paramMap: { page: 'page', pageSize: 'limit', nameSort: 'sort_name' },
|
paramMap: { page: 'page', pageSize: 'limit', nameSort: 'sort_name' },
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -188,6 +192,7 @@ const ProductCategoryTable = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const searchChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
|
const searchChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||||
|
setSearchValue(e.target.value);
|
||||||
updateFilter('search', e.target.value);
|
updateFilter('search', e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -196,6 +201,28 @@ const ProductCategoryTable = () => {
|
|||||||
setPageSize(newVal.value as number);
|
setPageSize(newVal.value as number);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Store current path on mount
|
||||||
|
previousPathRef.current = window.location.pathname;
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
const currentPath = window.location.pathname;
|
||||||
|
|
||||||
|
// if both paths are within /master-data/product-category module
|
||||||
|
const isCurrentPathProductCategory = currentPath.includes(
|
||||||
|
'/master-data/product-category'
|
||||||
|
);
|
||||||
|
const isPreviousPathProductCategory = previousPathRef.current?.includes(
|
||||||
|
'/master-data/product-category'
|
||||||
|
);
|
||||||
|
|
||||||
|
// reset if we outside product category module entirely
|
||||||
|
if (isPreviousPathProductCategory && !isCurrentPathProductCategory) {
|
||||||
|
resetSearchValue();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [resetSearchValue]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isNameSorted = sorting.find((sortItem) => sortItem.id === 'name');
|
const isNameSorted = sorting.find((sortItem) => sortItem.id === 'name');
|
||||||
if (!isNameSorted) {
|
if (!isNameSorted) {
|
||||||
|
|||||||
@@ -1395,8 +1395,8 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
|
|
||||||
if (hasSameDayRecording) {
|
if (hasSameDayRecording) {
|
||||||
toast.error(
|
toast.error(
|
||||||
`Recording untuk hari ${nextDayRecording.next_day} sudah ada.
|
`Recording untuk hari ke-${nextDayRecording.next_day} sudah ada datanya.
|
||||||
Tidak bisa membuat recording duplikat, mohon perbarui recording yang sudah ada terlebih dahulu.`
|
Tidak bisa membuat recording di hari yang sama dengan project flock yang sama, mohon perbarui recording yang sudah ada terlebih dahulu.`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import RowDropdownOptions from '@/components/table/RowDropdownOptions';
|
|||||||
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
|
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
|
||||||
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
|
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
|
||||||
import RequirePermission from '@/components/helper/RequirePermission';
|
import RequirePermission from '@/components/helper/RequirePermission';
|
||||||
|
import Badge from '@/components/Badge';
|
||||||
|
|
||||||
import { cn, formatDate } from '@/lib/helper';
|
import { cn, formatDate } from '@/lib/helper';
|
||||||
import { isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseSuccess } from '@/lib/api-helper';
|
||||||
@@ -153,6 +154,57 @@ const PurchaseTable = () => {
|
|||||||
return `${diffDays} hari`;
|
return `${diffDays} hari`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
header: 'Status Approval',
|
||||||
|
cell: (props) => {
|
||||||
|
const approval = props.row.original.latest_approval;
|
||||||
|
if (!approval) return '-';
|
||||||
|
|
||||||
|
const isRejected = approval.action === 'REJECTED';
|
||||||
|
|
||||||
|
let statusColor:
|
||||||
|
| 'warning'
|
||||||
|
| 'success'
|
||||||
|
| 'neutral'
|
||||||
|
| 'error'
|
||||||
|
| 'primary'
|
||||||
|
| 'info' = 'neutral';
|
||||||
|
|
||||||
|
switch (approval.step_number) {
|
||||||
|
case 1:
|
||||||
|
statusColor = 'neutral';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
statusColor = 'primary';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
statusColor = 'info';
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
statusColor = 'warning';
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
statusColor = 'success';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRejected) {
|
||||||
|
statusColor = 'error';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
variant='soft'
|
||||||
|
color={statusColor}
|
||||||
|
className={{
|
||||||
|
badge: 'whitespace-nowrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isRejected ? 'Ditolak' : approval.step_name}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
header: 'Aksi',
|
header: 'Aksi',
|
||||||
cell: (props) => {
|
cell: (props) => {
|
||||||
|
|||||||
@@ -605,7 +605,7 @@ const PurchaseOrderDetail = ({
|
|||||||
return (
|
return (
|
||||||
<section className='w-full'>
|
<section className='w-full'>
|
||||||
{/* Approval and Action Buttons */}
|
{/* Approval and Action Buttons */}
|
||||||
<div className='flex justify-between items-center w-full my-6'>
|
<div className='flex flex-col sm:flex-row sm:justify-between sm:items-center w-full mb-6 gap-4 sm:gap-0'>
|
||||||
<Button
|
<Button
|
||||||
href='/purchase'
|
href='/purchase'
|
||||||
variant='link'
|
variant='link'
|
||||||
@@ -630,7 +630,7 @@ const PurchaseOrderDetail = ({
|
|||||||
onClick={handleApprovalClick}
|
onClick={handleApprovalClick}
|
||||||
variant='outline'
|
variant='outline'
|
||||||
color='success'
|
color='success'
|
||||||
className='w-full sm:w-fit'
|
className='flex-1 sm:w-fit'
|
||||||
>
|
>
|
||||||
<Icon icon='material-symbols:check' width={24} height={24} />
|
<Icon icon='material-symbols:check' width={24} height={24} />
|
||||||
Approve
|
Approve
|
||||||
@@ -649,7 +649,7 @@ const PurchaseOrderDetail = ({
|
|||||||
<Button
|
<Button
|
||||||
variant='outline'
|
variant='outline'
|
||||||
color='error'
|
color='error'
|
||||||
className='w-full sm:w-fit'
|
className='flex-1 sm:w-fit'
|
||||||
onClick={handleRejectionClick}
|
onClick={handleRejectionClick}
|
||||||
>
|
>
|
||||||
<Icon icon='material-symbols:close' width={24} height={24} />
|
<Icon icon='material-symbols:close' width={24} height={24} />
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ export type CreateMovementPayloadData = {
|
|||||||
document_index?: number;
|
document_index?: number;
|
||||||
driver_name: string;
|
driver_name: string;
|
||||||
vehicle_plate: string;
|
vehicle_plate: string;
|
||||||
supplier_id: number;
|
supplier_id?: number | null;
|
||||||
products: {
|
products: {
|
||||||
product_id: number;
|
product_id: number;
|
||||||
product_qty: number;
|
product_qty: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user