mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
chore: add activity_count
This commit is contained in:
@@ -47,6 +47,7 @@ import { httpClientFetcher, SWRHttpKey } from '@/services/http/client';
|
||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import { PhaseActivityApi } from '@/services/api/daily-checklist/phase-activity';
|
||||
import { PhaseActivity } from '@/types/api/daily-checklist/phase-activity';
|
||||
import { Phase } from '@/types/api/daily-checklist/phase';
|
||||
|
||||
// Static categories - tidak bisa CRUD
|
||||
const CATEGORIES = [
|
||||
@@ -64,13 +65,6 @@ const TIME_TYPES = [
|
||||
{ value: 'Malam', label: 'Malam' },
|
||||
];
|
||||
|
||||
interface Phase {
|
||||
id: string;
|
||||
name: string;
|
||||
category: string;
|
||||
activityCount?: number;
|
||||
}
|
||||
|
||||
export function MasterAktivitasContent() {
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>('');
|
||||
const [selectedPhase, setSelectedPhase] = useState<Phase | null>(null);
|
||||
@@ -103,7 +97,7 @@ export function MasterAktivitasContent() {
|
||||
SWRHttpKey
|
||||
>(
|
||||
selectedPhase?.id
|
||||
? `${PhaseActivityApi.basePath}?page=1&limit=100&phase_id=${selectedPhase.id}`
|
||||
? `${PhaseActivityApi.basePath}?page=1&limit=100&phase_ids=${selectedPhase.id}`
|
||||
: '',
|
||||
httpClientFetcher,
|
||||
{
|
||||
@@ -171,7 +165,7 @@ export function MasterAktivitasContent() {
|
||||
const handleEditPhase = (phase: Phase) => {
|
||||
setPhaseModalMode('edit');
|
||||
setPhaseForm({
|
||||
id: phase.id,
|
||||
id: String(phase.id),
|
||||
name: phase.name,
|
||||
});
|
||||
setShowPhaseModal(true);
|
||||
@@ -265,7 +259,7 @@ export function MasterAktivitasContent() {
|
||||
setPhaseToDelete(null);
|
||||
|
||||
// Clear selection if deleted phase was selected
|
||||
if (selectedPhase?.id === phaseToDelete) {
|
||||
if (selectedPhase?.id === Number(phaseToDelete)) {
|
||||
setSelectedPhase(null);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -543,7 +537,7 @@ export function MasterAktivitasContent() {
|
||||
{phase.name}
|
||||
</p>
|
||||
<p className='text-xs text-gray-500 mt-1'>
|
||||
{phase.activityCount || 0} aktivitas
|
||||
{phase.activity_count || 0} aktivitas
|
||||
</p>
|
||||
</div>
|
||||
<DropdownMenu>
|
||||
@@ -567,7 +561,9 @@ export function MasterAktivitasContent() {
|
||||
Edit
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => handleDeletePhaseClick(phase.id)}
|
||||
onClick={() =>
|
||||
handleDeletePhaseClick(String(phase.id))
|
||||
}
|
||||
className='text-red-600'
|
||||
>
|
||||
<Trash2 className='mr-2 h-4 w-4' />
|
||||
|
||||
Reference in New Issue
Block a user