mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +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 [emptyKandangEndDate, setEmptyKandangEndDate] = useState('');
|
||||
|
||||
const isKandangEmpty = selectedCategory === 'empty_kandang';
|
||||
|
||||
const {
|
||||
options: kandangOptions,
|
||||
isLoadingMore: isLoadingMoreKandang,
|
||||
@@ -298,7 +300,7 @@ export function DailyChecklistContent() {
|
||||
|
||||
if (isResponseError(checklist)) {
|
||||
console.error('Error upserting checklist:', checklist.message);
|
||||
toast.error('Gagal memuat checklist');
|
||||
toast.error('Gagal memuat checklist: ' + checklist.message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -311,6 +313,12 @@ export function DailyChecklistContent() {
|
||||
|
||||
if (isResponseError(existingPhases)) {
|
||||
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 (
|
||||
existingPhases &&
|
||||
existingPhases.data &&
|
||||
@@ -1118,7 +1126,7 @@ export function DailyChecklistContent() {
|
||||
</div>
|
||||
|
||||
{/* Phase Selection Section */}
|
||||
{dailyChecklistId && (
|
||||
{!isKandangEmpty && dailyChecklistId && (
|
||||
<div className='mb-6 pb-6 border-b border-gray-200'>
|
||||
{isChecklistStatusDraft && (
|
||||
<div className='flex items-center justify-between mb-3'>
|
||||
@@ -1159,7 +1167,9 @@ export function DailyChecklistContent() {
|
||||
)}
|
||||
|
||||
{/* ABK Assignment Section */}
|
||||
{dailyChecklistId && selectedPhaseIds.length > 0 && (
|
||||
{!isKandangEmpty &&
|
||||
dailyChecklistId &&
|
||||
selectedPhaseIds.length > 0 && (
|
||||
<div className='mb-6 pb-6 border-b border-gray-200'>
|
||||
{isChecklistStatusDraft && (
|
||||
<div className='flex items-center justify-between mb-3'>
|
||||
@@ -1198,12 +1208,16 @@ export function DailyChecklistContent() {
|
||||
))}
|
||||
</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>
|
||||
)}
|
||||
|
||||
{/* Activity Checklist Table */}
|
||||
{!isKandangEmpty && (
|
||||
<>
|
||||
{dailyChecklistId &&
|
||||
selectedPhaseIds.length > 0 &&
|
||||
selectedEmployees.length > 0 ? (
|
||||
@@ -1235,7 +1249,8 @@ export function DailyChecklistContent() {
|
||||
<tbody>
|
||||
{Object.keys(groupActivitiesByPhase()).flatMap(
|
||||
(phaseId) => {
|
||||
const phaseData = groupActivitiesByPhase()[phaseId];
|
||||
const phaseData =
|
||||
groupActivitiesByPhase()[phaseId];
|
||||
const { phase, timeGroups } = phaseData;
|
||||
|
||||
const timeTypes = Object.keys(timeGroups).sort(
|
||||
@@ -1282,7 +1297,8 @@ export function DailyChecklistContent() {
|
||||
// TIME_TYPE sub-headers and activities
|
||||
timeTypes.forEach((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
|
||||
if (hasMultipleTimeTypes) {
|
||||
@@ -1369,17 +1385,22 @@ export function DailyChecklistContent() {
|
||||
rows={1}
|
||||
placeholder='Catatan (opsional)'
|
||||
value={
|
||||
taskId && selectedEmployees.length > 0
|
||||
taskId &&
|
||||
selectedEmployees.length > 0
|
||||
? assignments[taskId]?.[
|
||||
selectedEmployees[0].id
|
||||
]?.note || ''
|
||||
: ''
|
||||
}
|
||||
onChange={(e) => {
|
||||
if (selectedEmployees.length > 0) {
|
||||
if (
|
||||
selectedEmployees.length > 0
|
||||
) {
|
||||
handleNoteChange(
|
||||
String(activity.id),
|
||||
String(selectedEmployees[0].id),
|
||||
String(
|
||||
selectedEmployees[0].id
|
||||
),
|
||||
e.target.value
|
||||
);
|
||||
}
|
||||
@@ -1449,8 +1470,11 @@ export function DailyChecklistContent() {
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{dailyChecklistId &&
|
||||
{!isKandangEmpty &&
|
||||
dailyChecklistId &&
|
||||
selectedPhaseIds.length > 0 &&
|
||||
selectedEmployees.length > 0 && (
|
||||
<>
|
||||
@@ -1548,7 +1572,8 @@ export function DailyChecklistContent() {
|
||||
)}
|
||||
|
||||
{/* Action Buttons */}
|
||||
{dailyChecklistId &&
|
||||
{!isKandangEmpty &&
|
||||
dailyChecklistId &&
|
||||
selectedPhaseIds.length > 0 &&
|
||||
selectedEmployees.length > 0 &&
|
||||
isChecklistStatusDraft && (
|
||||
|
||||
Reference in New Issue
Block a user