mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
fix(FE): revert RequireAuth component and closing logic
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
'use client';
|
||||
|
||||
import Button from '@/components/Button';
|
||||
import DrawerHeader from '@/components/helper/drawer/DrawerHeader';
|
||||
import Table from '@/components/Table';
|
||||
import Badge from '@/components/Badge';
|
||||
import { cn, formatDate, formatNumber, formatTitleCase } from '@/lib/helper';
|
||||
import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
|
||||
import { ProjectFlock } from '@/types/api/production/project-flock';
|
||||
import {
|
||||
ClosingExpense,
|
||||
ProjectFlockKandang,
|
||||
} from '@/types/api/production/project-flock-kandang';
|
||||
import { Purchase } from '@/types/api/purchase/purchase';
|
||||
import { Icon } from '@iconify/react';
|
||||
import useSWR from 'swr';
|
||||
import { ProjectFlockKandangApi } from '@/services/api/production/project-flock-kandang';
|
||||
@@ -19,6 +18,8 @@ import { useModal } from '@/components/Modal';
|
||||
import ConfirmationModal from '@/components/modal/ConfirmationModal';
|
||||
import { useMemo, useState } from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
|
||||
|
||||
const ProjectFlockClosingForm = ({
|
||||
projectFlock,
|
||||
@@ -27,8 +28,9 @@ const ProjectFlockClosingForm = ({
|
||||
projectFlock: ProjectFlock;
|
||||
projectFlockKandang: ProjectFlockKandang;
|
||||
}) => {
|
||||
const router = useRouter();
|
||||
const closeModal = useModal();
|
||||
const isCanClose = projectFlock.approval?.step_number <= 1;
|
||||
const isCanClose = projectFlock.approval?.step_number <= 2;
|
||||
const [isClosingLoading, setIsClosingLoading] = useState(false);
|
||||
|
||||
const { data: closingData, isLoading } = useSWR(
|
||||
@@ -48,6 +50,7 @@ const ProjectFlockClosingForm = ({
|
||||
|
||||
if (isResponseSuccess(deleteProjectFlockRes)) {
|
||||
toast.success(deleteProjectFlockRes?.message as string);
|
||||
router.push(`/production/project-flock`);
|
||||
}
|
||||
if (isResponseError(deleteProjectFlockRes)) {
|
||||
toast.error(deleteProjectFlockRes?.message as string);
|
||||
@@ -280,7 +283,7 @@ const ProjectFlockClosingForm = ({
|
||||
ref={closeModal.ref}
|
||||
type='error'
|
||||
text={
|
||||
projectFlock.approval?.step_number <= 1
|
||||
isCanClose
|
||||
? 'Apakah kamu yakin ingin mengakhiri project ini ? *Pastikan persediaan produk di gudang terkait sudah kosong, dan BOP sudah selesai'
|
||||
: 'Apakah kamu yakin ingin membuka kembali project ini ? *Project ini akan kembali ke status aktif'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user