mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
feat(FE): adding alert errors message for project flock and fixing bug approval status in chickin
This commit is contained in:
@@ -18,6 +18,7 @@ import { Icon } from '@iconify/react';
|
||||
import Badge from '@/components/Badge';
|
||||
import { CHICKINS_APPROVAL_LINE } from '@/config/approval-line';
|
||||
import RequirePermission from '@/components/helper/RequirePermission';
|
||||
import { BaseApproval } from '@/types/api/api-general';
|
||||
const ChickinFormKandang = ({
|
||||
formType = 'add',
|
||||
initialValues,
|
||||
@@ -33,11 +34,16 @@ const ChickinFormKandang = ({
|
||||
approvals,
|
||||
isLoading: approvalsLoading,
|
||||
refresh: refreshApprovals,
|
||||
rawDataApprovals,
|
||||
} = useApprovalSteps({
|
||||
latestApproval: initialValues?.chickin_approval,
|
||||
approvalLines: CHICKINS_APPROVAL_LINE,
|
||||
moduleName: 'CHICKINS',
|
||||
moduleId: initialValues?.id.toString() ?? '',
|
||||
params: {
|
||||
limit: 'limit',
|
||||
group_step_number: false,
|
||||
},
|
||||
});
|
||||
|
||||
const afterSubmitFormChickin = () => {
|
||||
@@ -180,6 +186,7 @@ const ChickinFormKandang = ({
|
||||
</div>
|
||||
{openChickin && (
|
||||
<ChickinLogsView
|
||||
rawDataApprovals={rawDataApprovals as BaseApproval[]}
|
||||
initialValues={initialValues}
|
||||
afterSubmit={afterSubmitFormChickin}
|
||||
/>
|
||||
|
||||
@@ -8,6 +8,7 @@ import PillBadge from '@/components/PillBadge';
|
||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import { formatDate, formatNumber } from '@/lib/helper';
|
||||
import { ChickinApi } from '@/services/api/production/chickin';
|
||||
import { BaseApproval } from '@/types/api/api-general';
|
||||
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
|
||||
import { Icon } from '@iconify/react';
|
||||
import { useState } from 'react';
|
||||
@@ -16,9 +17,11 @@ import toast from 'react-hot-toast';
|
||||
const ChickinLogsView = ({
|
||||
initialValues,
|
||||
afterSubmit,
|
||||
rawDataApprovals,
|
||||
}: {
|
||||
initialValues: ProjectFlockKandang;
|
||||
afterSubmit?: () => void;
|
||||
rawDataApprovals: BaseApproval[];
|
||||
}) => {
|
||||
const confirmModal = useModal();
|
||||
const [isApproveLoading, setIsApproveLoading] = useState(false);
|
||||
@@ -60,9 +63,15 @@ const ChickinLogsView = ({
|
||||
</div>
|
||||
) : (
|
||||
(initialValues?.chickins || []).map((chickin, index) => {
|
||||
const latestApproval = rawDataApprovals[0];
|
||||
const isApproved =
|
||||
initialValues.chickin_approval?.step_number === 2;
|
||||
const isPending = initialValues.chickin_approval?.step_number === 1;
|
||||
index == (initialValues?.chickins || []).length - 1
|
||||
? latestApproval?.step_number === 2
|
||||
: true;
|
||||
const isPending =
|
||||
index == (initialValues?.chickins || []).length - 1
|
||||
? latestApproval?.step_number === 1
|
||||
: false;
|
||||
const quantity = isApproved
|
||||
? chickin.usage_qty
|
||||
: isPending
|
||||
@@ -82,7 +91,7 @@ const ChickinLogsView = ({
|
||||
{/* Header with Status Badge */}
|
||||
<div className='flex flex-row justify-between items-center'>
|
||||
<div className='text-lg font-semibold'>
|
||||
Chick In #{index + 1}
|
||||
Chick In #{index + 1} - {latestApproval?.step_number}
|
||||
</div>
|
||||
<PillBadge
|
||||
content={
|
||||
|
||||
Reference in New Issue
Block a user