mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-06-15 04:51:42 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b4bd7605b | |||
| 9bd646294b | |||
| 366260608f |
@@ -847,8 +847,7 @@ const DeliveryOrderFormModal = ({}: { initialValues?: Marketing }) => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className='p-3 shadow-button-soft text-base-100 rounded-lg text-sm font-semibold'
|
className='p-3 shadow-button-soft text-base-100 rounded-lg text-sm font-semibold'
|
||||||
disabled={deliveryRejected || isLoading}
|
disabled={deliveryRejected}
|
||||||
isLoading={isLoading}
|
|
||||||
>
|
>
|
||||||
{marketing?.data?.latest_approval?.step_number === 1 &&
|
{marketing?.data?.latest_approval?.step_number === 1 &&
|
||||||
'Approve'}
|
'Approve'}
|
||||||
|
|||||||
@@ -2,17 +2,16 @@ import Alert from '@/components/Alert';
|
|||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import Card from '@/components/Card';
|
import Card from '@/components/Card';
|
||||||
import RequirePermission from '@/components/helper/RequirePermission';
|
import RequirePermission from '@/components/helper/RequirePermission';
|
||||||
import DateInput from '@/components/input/DateInput';
|
|
||||||
import PillBadge from '@/components/PillBadge';
|
import PillBadge from '@/components/PillBadge';
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { formatDate, formatNumber } from '@/lib/helper';
|
import { formatDate, formatNumber } from '@/lib/helper';
|
||||||
import { ChickinApi } from '@/services/api/production/chickin';
|
import { ChickinApi } from '@/services/api/production/chickin';
|
||||||
import { useChickinStore } from '@/stores/production/chickin/chickin.store';
|
|
||||||
import { BaseApproval } from '@/types/api/api-general';
|
import { BaseApproval } from '@/types/api/api-general';
|
||||||
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
|
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
|
import { useChickinStore } from '@/stores/production/chickin/chickin.store';
|
||||||
|
|
||||||
const ChickinLogsView = ({
|
const ChickinLogsView = ({
|
||||||
initialValues,
|
initialValues,
|
||||||
@@ -24,9 +23,6 @@ const ChickinLogsView = ({
|
|||||||
rawDataApprovals: BaseApproval[];
|
rawDataApprovals: BaseApproval[];
|
||||||
}) => {
|
}) => {
|
||||||
const [chickinErrorMessage, setChickinErrorMessage] = useState('');
|
const [chickinErrorMessage, setChickinErrorMessage] = useState('');
|
||||||
const [editingChickinId, setEditingChickinId] = useState<number | null>(null);
|
|
||||||
const [editDate, setEditDate] = useState('');
|
|
||||||
const [isEditLoading, setIsEditLoading] = useState(false);
|
|
||||||
const { openChickinApproveModal, openChickinDeleteModal } = useChickinStore();
|
const { openChickinApproveModal, openChickinDeleteModal } = useChickinStore();
|
||||||
|
|
||||||
const handleClickApprove = () => {
|
const handleClickApprove = () => {
|
||||||
@@ -48,23 +44,6 @@ const ChickinLogsView = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSaveChickinDate = async () => {
|
|
||||||
setIsEditLoading(true);
|
|
||||||
const res = await ChickinApi.updateChickinDate(
|
|
||||||
initialValues.id as number,
|
|
||||||
formatDate(editDate, 'YYYY-MM-DD')
|
|
||||||
);
|
|
||||||
setIsEditLoading(false);
|
|
||||||
if (isResponseSuccess(res)) {
|
|
||||||
toast.success(res?.message as string);
|
|
||||||
setEditingChickinId(null);
|
|
||||||
afterSubmit && afterSubmit();
|
|
||||||
}
|
|
||||||
if (isResponseError(res)) {
|
|
||||||
toast.error(res?.message as string);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDeleteChickin = (chickinId: number) => {
|
const handleDeleteChickin = (chickinId: number) => {
|
||||||
openChickinDeleteModal(chickinId, async () => {
|
openChickinDeleteModal(chickinId, async () => {
|
||||||
const deleteRes = await ChickinApi.delete(chickinId);
|
const deleteRes = await ChickinApi.delete(chickinId);
|
||||||
@@ -154,54 +133,9 @@ const ChickinLogsView = ({
|
|||||||
<Icon icon={'mdi:calendar'} width={14} height={14} />{' '}
|
<Icon icon={'mdi:calendar'} width={14} height={14} />{' '}
|
||||||
<span>Tanggal Chick In</span>
|
<span>Tanggal Chick In</span>
|
||||||
</div>
|
</div>
|
||||||
{editingChickinId === chickin.id ? (
|
<div className='text-end text-gray-500'>
|
||||||
<div className='flex flex-col gap-2 items-end w-1/2'>
|
{formatDate(chickin.chick_in_date, 'DD MMM YYYY')}
|
||||||
<DateInput
|
</div>
|
||||||
name='edit_chick_in_date'
|
|
||||||
value={editDate}
|
|
||||||
isNestedModal
|
|
||||||
onChange={(e) => setEditDate(e.target.value)}
|
|
||||||
/>
|
|
||||||
<div className='flex flex-row gap-1'>
|
|
||||||
<Button
|
|
||||||
color='none'
|
|
||||||
className='btn-xs btn-ghost text-gray-500'
|
|
||||||
onClick={() => setEditingChickinId(null)}
|
|
||||||
disabled={isEditLoading}
|
|
||||||
>
|
|
||||||
Batal
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
color='success'
|
|
||||||
className='btn-xs text-base-100'
|
|
||||||
onClick={handleSaveChickinDate}
|
|
||||||
isLoading={isEditLoading}
|
|
||||||
disabled={!editDate || isEditLoading}
|
|
||||||
>
|
|
||||||
Simpan
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className='flex flex-row gap-2 items-center'>
|
|
||||||
<span className='text-gray-500'>
|
|
||||||
{formatDate(chickin.chick_in_date, 'DD MMM YYYY')}
|
|
||||||
</span>
|
|
||||||
<button
|
|
||||||
className='btn btn-ghost btn-xs p-0 text-gray-400 hover:text-primary'
|
|
||||||
onClick={() => {
|
|
||||||
setEditingChickinId(chickin.id);
|
|
||||||
setEditDate(chickin.chick_in_date);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon
|
|
||||||
icon='mdi:pencil-outline'
|
|
||||||
width={13}
|
|
||||||
height={13}
|
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Kandang */}
|
{/* Kandang */}
|
||||||
|
|||||||
@@ -463,13 +463,16 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
}, [selectedKandang]);
|
}, [selectedKandang]);
|
||||||
|
|
||||||
// ===== TRANSITION RESTRICTION LOGIC =====
|
// ===== TRANSITION RESTRICTION LOGIC =====
|
||||||
const isTransitionPeriod = useMemo(() => {
|
// const isTransitionPeriod = useMemo(() => {
|
||||||
return (
|
// return (
|
||||||
initialValues?.is_transition ??
|
// initialValues?.is_transition ??
|
||||||
projectFlockKandangLookup?.is_transition ??
|
// projectFlockKandangLookup?.is_transition ??
|
||||||
false
|
// false
|
||||||
);
|
// );
|
||||||
}, [initialValues, projectFlockKandangLookup]);
|
// }, [initialValues, projectFlockKandangLookup]);
|
||||||
|
|
||||||
|
// set to false by request: 30 May 2026, 09:11
|
||||||
|
const isTransitionPeriod = false;
|
||||||
|
|
||||||
const recordingRestriction = useMemo(() => {
|
const recordingRestriction = useMemo(() => {
|
||||||
let isLaying: boolean;
|
let isLaying: boolean;
|
||||||
@@ -483,10 +486,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
false;
|
false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isTransition =
|
// const isTransition =
|
||||||
initialValues?.is_transition ??
|
// initialValues?.is_transition ??
|
||||||
projectFlockKandangLookup?.is_transition ??
|
// projectFlockKandangLookup?.is_transition ??
|
||||||
false;
|
// false;
|
||||||
|
|
||||||
|
// set to false by request: 30 May 2026, 09:11
|
||||||
|
const isTransition = false;
|
||||||
|
|
||||||
const currentIsLaying =
|
const currentIsLaying =
|
||||||
type === 'edit'
|
type === 'edit'
|
||||||
|
|||||||
@@ -11,63 +11,72 @@ export const getRecordingRestriction = (
|
|||||||
isTransition: boolean,
|
isTransition: boolean,
|
||||||
currentIsLaying?: boolean
|
currentIsLaying?: boolean
|
||||||
): RecordingRestriction => {
|
): RecordingRestriction => {
|
||||||
if (isTransition && !isLaying) {
|
// if (isTransition && !isLaying) {
|
||||||
const isLayingKandangInTransition = currentIsLaying === true;
|
// const isLayingKandangInTransition = currentIsLaying === true;
|
||||||
|
|
||||||
if (isLayingKandangInTransition) {
|
// if (isLayingKandangInTransition) {
|
||||||
return {
|
// return {
|
||||||
canEditStock: false,
|
// canEditStock: false,
|
||||||
canEditDepletion: true,
|
// canEditDepletion: true,
|
||||||
canEditEgg: true,
|
// canEditEgg: true,
|
||||||
isLocked: false,
|
// isLocked: false,
|
||||||
lockReason: undefined,
|
// lockReason: undefined,
|
||||||
};
|
// };
|
||||||
} else {
|
// } else {
|
||||||
return {
|
// return {
|
||||||
canEditStock: true,
|
// canEditStock: true,
|
||||||
canEditDepletion: false,
|
// canEditDepletion: false,
|
||||||
canEditEgg: false,
|
// canEditEgg: false,
|
||||||
isLocked: false,
|
// isLocked: false,
|
||||||
lockReason: undefined,
|
// lockReason: undefined,
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!isLaying && !isTransition && currentIsLaying) {
|
// if (!isLaying && !isTransition && currentIsLaying) {
|
||||||
return {
|
// return {
|
||||||
canEditStock: false,
|
// canEditStock: false,
|
||||||
canEditDepletion: false,
|
// canEditDepletion: false,
|
||||||
canEditEgg: false,
|
// canEditEgg: false,
|
||||||
isLocked: true,
|
// isLocked: true,
|
||||||
lockReason:
|
// lockReason:
|
||||||
'Recording Growing telah terkunci karena Project Flock sudah masuk fase Laying',
|
// 'Recording Growing telah terkunci karena Project Flock sudah masuk fase Laying',
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!isLaying && !isTransition) {
|
// if (!isLaying && !isTransition) {
|
||||||
return {
|
// return {
|
||||||
canEditStock: true,
|
// canEditStock: true,
|
||||||
canEditDepletion: true,
|
// canEditDepletion: true,
|
||||||
canEditEgg: false,
|
// canEditEgg: false,
|
||||||
isLocked: false,
|
// isLocked: false,
|
||||||
lockReason: undefined,
|
// lockReason: undefined,
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
if (isLaying && !isTransition) {
|
// if (isLaying && !isTransition) {
|
||||||
return {
|
// return {
|
||||||
canEditStock: true,
|
// canEditStock: true,
|
||||||
canEditDepletion: true,
|
// canEditDepletion: true,
|
||||||
canEditEgg: true,
|
// canEditEgg: true,
|
||||||
isLocked: false,
|
// isLocked: false,
|
||||||
lockReason: undefined,
|
// lockReason: undefined,
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// return {
|
||||||
|
// canEditStock: false,
|
||||||
|
// canEditDepletion: false,
|
||||||
|
// canEditEgg: false,
|
||||||
|
// isLocked: true,
|
||||||
|
// lockReason: 'Kondisi transisi tidak valid',
|
||||||
|
// };
|
||||||
|
|
||||||
|
// remove recording transition restriction by request: 30 May 2026, 09:11
|
||||||
return {
|
return {
|
||||||
canEditStock: false,
|
canEditStock: true,
|
||||||
canEditDepletion: false,
|
canEditDepletion: true,
|
||||||
canEditEgg: false,
|
canEditEgg: true,
|
||||||
isLocked: true,
|
isLocked: false,
|
||||||
lockReason: 'Kondisi transisi tidak valid',
|
lockReason: undefined,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,11 +45,8 @@ export class SalesOrderService extends BaseApiService<
|
|||||||
notes: notes || `${action} marketing ${id}`,
|
notes: notes || `${action} marketing ${id}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error: unknown) {
|
} catch (error) {
|
||||||
if (axios.isAxiosError<BaseApiResponse<{ message: string }>>(error)) {
|
throw error;
|
||||||
return error.response?.data;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,11 +68,8 @@ export class SalesOrderService extends BaseApiService<
|
|||||||
notes: notes || `${action} marketing ${ids.join(', ')}`,
|
notes: notes || `${action} marketing ${ids.join(', ')}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error: unknown) {
|
} catch (error) {
|
||||||
if (axios.isAxiosError<BaseApiResponse<{ message: string }>>(error)) {
|
throw error;
|
||||||
return error.response?.data;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,11 +110,8 @@ export class SalesOrderService extends BaseApiService<
|
|||||||
notes: notes || `Delivery marketing ${id}`,
|
notes: notes || `Delivery marketing ${id}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error: unknown) {
|
} catch (error) {
|
||||||
if (axios.isAxiosError<BaseApiResponse<{ message: string }>>(error)) {
|
throw error;
|
||||||
return error.response?.data;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,11 +142,8 @@ class MarketingExportService extends BaseApiService<
|
|||||||
notes: notes,
|
notes: notes,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error: unknown) {
|
} catch (error) {
|
||||||
if (axios.isAxiosError<BaseApiResponse<Marketing[] | Marketing>>(error)) {
|
throw error;
|
||||||
return error.response?.data;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
import { BaseApiService } from '@/services/api/base';
|
import { BaseApiService } from '@/services/api/base';
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
import { httpClient } from '@/services/http/client';
|
import { httpClient } from '@/services/http/client';
|
||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
export class ChickinService extends BaseApiService<
|
export class ChickinService extends BaseApiService<
|
||||||
Chickin,
|
Chickin,
|
||||||
@@ -17,29 +16,6 @@ export class ChickinService extends BaseApiService<
|
|||||||
super(basePath);
|
super(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateChickinDate(
|
|
||||||
projectFlockKandangId: number,
|
|
||||||
chickInDate: string
|
|
||||||
): Promise<BaseApiResponse<{ message: string }> | undefined> {
|
|
||||||
try {
|
|
||||||
return await httpClient<BaseApiResponse<{ message: string }>>(
|
|
||||||
`${this.basePath}/chick-in-date`,
|
|
||||||
{
|
|
||||||
method: 'PATCH',
|
|
||||||
body: {
|
|
||||||
project_flock_kandang_id: projectFlockKandangId,
|
|
||||||
chick_in_date: chickInDate,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (error: unknown) {
|
|
||||||
if (axios.isAxiosError<BaseApiResponse<{ message: string }>>(error)) {
|
|
||||||
return error.response?.data;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Approve single marketing data
|
* Approve single marketing data
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user