mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
fix: hide phase selection, abk assignment, and activity checklist form when kandang is empty
This commit is contained in:
@@ -98,6 +98,8 @@ export function DailyChecklistContent() {
|
|||||||
const [emptyKandang, setEmptyKandang] = useState(false);
|
const [emptyKandang, setEmptyKandang] = useState(false);
|
||||||
const [emptyKandangEndDate, setEmptyKandangEndDate] = useState('');
|
const [emptyKandangEndDate, setEmptyKandangEndDate] = useState('');
|
||||||
|
|
||||||
|
const isKandangEmpty = selectedCategory === 'empty_kandang';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
options: kandangOptions,
|
options: kandangOptions,
|
||||||
isLoadingMore: isLoadingMoreKandang,
|
isLoadingMore: isLoadingMoreKandang,
|
||||||
@@ -298,7 +300,7 @@ export function DailyChecklistContent() {
|
|||||||
|
|
||||||
if (isResponseError(checklist)) {
|
if (isResponseError(checklist)) {
|
||||||
console.error('Error upserting checklist:', checklist.message);
|
console.error('Error upserting checklist:', checklist.message);
|
||||||
toast.error('Gagal memuat checklist');
|
toast.error('Gagal memuat checklist: ' + checklist.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +313,12 @@ export function DailyChecklistContent() {
|
|||||||
|
|
||||||
if (isResponseError(existingPhases)) {
|
if (isResponseError(existingPhases)) {
|
||||||
console.error('Error loading phases:', existingPhases.message);
|
console.error('Error loading phases:', existingPhases.message);
|
||||||
|
} else if (
|
||||||
|
existingPhases &&
|
||||||
|
existingPhases.data &&
|
||||||
|
existingPhases.data.phases.length === 0
|
||||||
|
) {
|
||||||
|
toast.success('Berhasil membuat daily checklist!');
|
||||||
} else if (
|
} else if (
|
||||||
existingPhases &&
|
existingPhases &&
|
||||||
existingPhases.data &&
|
existingPhases.data &&
|
||||||
@@ -1118,7 +1126,7 @@ export function DailyChecklistContent() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Phase Selection Section */}
|
{/* Phase Selection Section */}
|
||||||
{dailyChecklistId && (
|
{!isKandangEmpty && dailyChecklistId && (
|
||||||
<div className='mb-6 pb-6 border-b border-gray-200'>
|
<div className='mb-6 pb-6 border-b border-gray-200'>
|
||||||
{isChecklistStatusDraft && (
|
{isChecklistStatusDraft && (
|
||||||
<div className='flex items-center justify-between mb-3'>
|
<div className='flex items-center justify-between mb-3'>
|
||||||
@@ -1159,7 +1167,9 @@ export function DailyChecklistContent() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* ABK Assignment Section */}
|
{/* ABK Assignment Section */}
|
||||||
{dailyChecklistId && selectedPhaseIds.length > 0 && (
|
{!isKandangEmpty &&
|
||||||
|
dailyChecklistId &&
|
||||||
|
selectedPhaseIds.length > 0 && (
|
||||||
<div className='mb-6 pb-6 border-b border-gray-200'>
|
<div className='mb-6 pb-6 border-b border-gray-200'>
|
||||||
{isChecklistStatusDraft && (
|
{isChecklistStatusDraft && (
|
||||||
<div className='flex items-center justify-between mb-3'>
|
<div className='flex items-center justify-between mb-3'>
|
||||||
@@ -1198,12 +1208,16 @@ export function DailyChecklistContent() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<p className='text-sm text-gray-500'>Belum ada ABK dipilih</p>
|
<p className='text-sm text-gray-500'>
|
||||||
|
Belum ada ABK dipilih
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Activity Checklist Table */}
|
{/* Activity Checklist Table */}
|
||||||
|
{!isKandangEmpty && (
|
||||||
|
<>
|
||||||
{dailyChecklistId &&
|
{dailyChecklistId &&
|
||||||
selectedPhaseIds.length > 0 &&
|
selectedPhaseIds.length > 0 &&
|
||||||
selectedEmployees.length > 0 ? (
|
selectedEmployees.length > 0 ? (
|
||||||
@@ -1235,7 +1249,8 @@ export function DailyChecklistContent() {
|
|||||||
<tbody>
|
<tbody>
|
||||||
{Object.keys(groupActivitiesByPhase()).flatMap(
|
{Object.keys(groupActivitiesByPhase()).flatMap(
|
||||||
(phaseId) => {
|
(phaseId) => {
|
||||||
const phaseData = groupActivitiesByPhase()[phaseId];
|
const phaseData =
|
||||||
|
groupActivitiesByPhase()[phaseId];
|
||||||
const { phase, timeGroups } = phaseData;
|
const { phase, timeGroups } = phaseData;
|
||||||
|
|
||||||
const timeTypes = Object.keys(timeGroups).sort(
|
const timeTypes = Object.keys(timeGroups).sort(
|
||||||
@@ -1282,7 +1297,8 @@ export function DailyChecklistContent() {
|
|||||||
// TIME_TYPE sub-headers and activities
|
// TIME_TYPE sub-headers and activities
|
||||||
timeTypes.forEach((timeType) => {
|
timeTypes.forEach((timeType) => {
|
||||||
const activities = timeGroups[timeType];
|
const activities = timeGroups[timeType];
|
||||||
const hasMultipleTimeTypes = timeTypes.length > 1;
|
const hasMultipleTimeTypes =
|
||||||
|
timeTypes.length > 1;
|
||||||
|
|
||||||
// TIME Header (optional, only if phase has multiple time types) - GRAY SOFT
|
// TIME Header (optional, only if phase has multiple time types) - GRAY SOFT
|
||||||
if (hasMultipleTimeTypes) {
|
if (hasMultipleTimeTypes) {
|
||||||
@@ -1369,17 +1385,22 @@ export function DailyChecklistContent() {
|
|||||||
rows={1}
|
rows={1}
|
||||||
placeholder='Catatan (opsional)'
|
placeholder='Catatan (opsional)'
|
||||||
value={
|
value={
|
||||||
taskId && selectedEmployees.length > 0
|
taskId &&
|
||||||
|
selectedEmployees.length > 0
|
||||||
? assignments[taskId]?.[
|
? assignments[taskId]?.[
|
||||||
selectedEmployees[0].id
|
selectedEmployees[0].id
|
||||||
]?.note || ''
|
]?.note || ''
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
if (selectedEmployees.length > 0) {
|
if (
|
||||||
|
selectedEmployees.length > 0
|
||||||
|
) {
|
||||||
handleNoteChange(
|
handleNoteChange(
|
||||||
String(activity.id),
|
String(activity.id),
|
||||||
String(selectedEmployees[0].id),
|
String(
|
||||||
|
selectedEmployees[0].id
|
||||||
|
),
|
||||||
e.target.value
|
e.target.value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1449,8 +1470,11 @@ export function DailyChecklistContent() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{dailyChecklistId &&
|
{!isKandangEmpty &&
|
||||||
|
dailyChecklistId &&
|
||||||
selectedPhaseIds.length > 0 &&
|
selectedPhaseIds.length > 0 &&
|
||||||
selectedEmployees.length > 0 && (
|
selectedEmployees.length > 0 && (
|
||||||
<>
|
<>
|
||||||
@@ -1548,7 +1572,8 @@ export function DailyChecklistContent() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Action Buttons */}
|
{/* Action Buttons */}
|
||||||
{dailyChecklistId &&
|
{!isKandangEmpty &&
|
||||||
|
dailyChecklistId &&
|
||||||
selectedPhaseIds.length > 0 &&
|
selectedPhaseIds.length > 0 &&
|
||||||
selectedEmployees.length > 0 &&
|
selectedEmployees.length > 0 &&
|
||||||
isChecklistStatusDraft && (
|
isChecklistStatusDraft && (
|
||||||
|
|||||||
Reference in New Issue
Block a user