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 = () => {
|
||||
return (
|
||||
<section className='w-full p-4'>
|
||||
<section className='w-full p-4 sm:p-0'>
|
||||
<ExpensesTable />
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import MovementTable from '@/components/pages/inventory/movement/MovementTable';
|
||||
|
||||
const Movement = () => {
|
||||
return (
|
||||
<section className='w-full p-4'>
|
||||
<section className='w-full p-4 sm:p-0'>
|
||||
<MovementTable />
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import RecordingTable from '@/components/pages/production/recording/RecordingTab
|
||||
|
||||
const Recording = () => {
|
||||
return (
|
||||
<section className='w-full p-4'>
|
||||
<section className='w-full p-4 sm:p-0'>
|
||||
<RecordingTable />
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import PurchaseTable from '@/components/pages/purchase/PurchaseTable';
|
||||
|
||||
const Purchase = () => {
|
||||
return (
|
||||
<section className='w-full p-4'>
|
||||
<section className='w-full p-4 sm:p-0'>
|
||||
<PurchaseTable />
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -37,7 +37,7 @@ type MovementFormSchemaType = {
|
||||
value: number;
|
||||
label: string;
|
||||
} | null;
|
||||
supplier_id: number;
|
||||
supplier_id?: number | null;
|
||||
products: {
|
||||
product?: {
|
||||
value: number;
|
||||
@@ -69,7 +69,7 @@ export type DeliverySchema = {
|
||||
value: number;
|
||||
label: string;
|
||||
} | null;
|
||||
supplier_id: number;
|
||||
supplier_id?: number | null;
|
||||
products: {
|
||||
product?: {
|
||||
value: number;
|
||||
@@ -151,9 +151,10 @@ const DeliveryObjectSchema: Yup.ObjectSchema<DeliverySchema> = Yup.object({
|
||||
label: Yup.string().required(),
|
||||
}).nullable(),
|
||||
supplier_id: Yup.number()
|
||||
.required('Supplier wajib diisi!')
|
||||
.optional()
|
||||
.nullable()
|
||||
.min(1, 'Supplier wajib diisi!')
|
||||
.typeError('Supplier wajib diisi!'),
|
||||
.typeError('Supplier harus berupa angka!'),
|
||||
products: Yup.array()
|
||||
.of(DeliveryProductObjectSchema)
|
||||
.min(1, 'Minimal harus ada 1 produk!')
|
||||
|
||||
@@ -1494,7 +1494,7 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
</thead>
|
||||
<tbody>
|
||||
{formik.values.products?.map((product, idx) => (
|
||||
<tr key={`product-row-${idx}-${product.product_id}`}>
|
||||
<tr key={`product-row-${idx}`}>
|
||||
{type !== 'detail' && (
|
||||
<td className='align-middle!'>
|
||||
<CheckboxInput
|
||||
@@ -1665,15 +1665,7 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
<span className='text-error'>*</span>
|
||||
</span>
|
||||
</th>
|
||||
<th>
|
||||
Supplier
|
||||
<span
|
||||
className='tooltip tooltip-error tooltip-bottom z-9999'
|
||||
data-tip='required'
|
||||
>
|
||||
<span className='text-error'>*</span>
|
||||
</span>
|
||||
</th>
|
||||
<th>Supplier</th>
|
||||
<th>
|
||||
Plat Nomor
|
||||
<span
|
||||
@@ -1716,9 +1708,7 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
</thead>
|
||||
<tbody>
|
||||
{formik.values.deliveries?.map((delivery, idx) => (
|
||||
<tr
|
||||
key={`delivery-row-${idx}-${delivery.supplier_id}-${delivery.vehicle_plate}`}
|
||||
>
|
||||
<tr key={`delivery-row-${idx}`}>
|
||||
{type !== 'detail' && (
|
||||
<td className='align-middle!'>
|
||||
<CheckboxInput
|
||||
@@ -1787,7 +1777,6 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
</td>
|
||||
<td>
|
||||
<SelectInput
|
||||
required
|
||||
placeholder='Pilih supplier...'
|
||||
value={delivery.supplier}
|
||||
onChange={(val) =>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { ChangeEventHandler, useEffect, useState } from 'react';
|
||||
import { ChangeEventHandler, useEffect, useRef, useState } from 'react';
|
||||
import useSWR from 'swr';
|
||||
import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table';
|
||||
import toast from 'react-hot-toast';
|
||||
@@ -22,6 +22,7 @@ import { ProductCategoryApi } from '@/services/api/master-data';
|
||||
import { cn } from '@/lib/helper';
|
||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import { useTableFilter } from '@/services/hooks/useTableFilter';
|
||||
import { useUiStore } from '@/stores/ui/ui.store';
|
||||
import { ROWS_OPTIONS } from '@/config/constant';
|
||||
|
||||
const RowOptionsMenu = ({
|
||||
@@ -80,6 +81,9 @@ const RowOptionsMenu = ({
|
||||
};
|
||||
|
||||
const ProductCategoryTable = () => {
|
||||
const { searchValue, setSearchValue, resetSearchValue } = useUiStore();
|
||||
const previousPathRef = useRef<string | null>(null);
|
||||
|
||||
const {
|
||||
state: tableFilterState,
|
||||
updateFilter,
|
||||
@@ -87,7 +91,7 @@ const ProductCategoryTable = () => {
|
||||
setPageSize,
|
||||
toQueryString: getTableFilterQueryString,
|
||||
} = useTableFilter({
|
||||
initial: { search: '', nameSort: '' },
|
||||
initial: { search: searchValue, nameSort: '' },
|
||||
paramMap: { page: 'page', pageSize: 'limit', nameSort: 'sort_name' },
|
||||
});
|
||||
|
||||
@@ -188,6 +192,7 @@ const ProductCategoryTable = () => {
|
||||
};
|
||||
|
||||
const searchChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||
setSearchValue(e.target.value);
|
||||
updateFilter('search', e.target.value);
|
||||
};
|
||||
|
||||
@@ -196,6 +201,28 @@ const ProductCategoryTable = () => {
|
||||
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(() => {
|
||||
const isNameSorted = sorting.find((sortItem) => sortItem.id === 'name');
|
||||
if (!isNameSorted) {
|
||||
|
||||
@@ -1395,8 +1395,8 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
|
||||
if (hasSameDayRecording) {
|
||||
toast.error(
|
||||
`Recording untuk hari ${nextDayRecording.next_day} sudah ada.
|
||||
Tidak bisa membuat recording duplikat, mohon perbarui recording yang sudah ada terlebih dahulu.`
|
||||
`Recording untuk hari ke-${nextDayRecording.next_day} sudah ada datanya.
|
||||
Tidak bisa membuat recording di hari yang sama dengan project flock yang sama, mohon perbarui recording yang sudah ada terlebih dahulu.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import RowDropdownOptions from '@/components/table/RowDropdownOptions';
|
||||
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
|
||||
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
|
||||
import RequirePermission from '@/components/helper/RequirePermission';
|
||||
import Badge from '@/components/Badge';
|
||||
|
||||
import { cn, formatDate } from '@/lib/helper';
|
||||
import { isResponseSuccess } from '@/lib/api-helper';
|
||||
@@ -153,6 +154,57 @@ const PurchaseTable = () => {
|
||||
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',
|
||||
cell: (props) => {
|
||||
|
||||
@@ -605,7 +605,7 @@ const PurchaseOrderDetail = ({
|
||||
return (
|
||||
<section className='w-full'>
|
||||
{/* 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
|
||||
href='/purchase'
|
||||
variant='link'
|
||||
@@ -630,7 +630,7 @@ const PurchaseOrderDetail = ({
|
||||
onClick={handleApprovalClick}
|
||||
variant='outline'
|
||||
color='success'
|
||||
className='w-full sm:w-fit'
|
||||
className='flex-1 sm:w-fit'
|
||||
>
|
||||
<Icon icon='material-symbols:check' width={24} height={24} />
|
||||
Approve
|
||||
@@ -649,7 +649,7 @@ const PurchaseOrderDetail = ({
|
||||
<Button
|
||||
variant='outline'
|
||||
color='error'
|
||||
className='w-full sm:w-fit'
|
||||
className='flex-1 sm:w-fit'
|
||||
onClick={handleRejectionClick}
|
||||
>
|
||||
<Icon icon='material-symbols:close' width={24} height={24} />
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ export type CreateMovementPayloadData = {
|
||||
document_index?: number;
|
||||
driver_name: string;
|
||||
vehicle_plate: string;
|
||||
supplier_id: number;
|
||||
supplier_id?: number | null;
|
||||
products: {
|
||||
product_id: number;
|
||||
product_qty: number;
|
||||
|
||||
Reference in New Issue
Block a user