diff --git a/admin/src/app/(dashboard)/residences/[id]/client.tsx b/admin/src/app/(dashboard)/residences/[id]/client.tsx
index 7822405..efff038 100644
--- a/admin/src/app/(dashboard)/residences/[id]/client.tsx
+++ b/admin/src/app/(dashboard)/residences/[id]/client.tsx
@@ -3,10 +3,10 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { useParams, useRouter } from 'next/navigation';
import Link from 'next/link';
-import { ArrowLeft, Trash2, Pencil } from 'lucide-react';
+import { ArrowLeft, Trash2, Pencil, ExternalLink } from 'lucide-react';
import { toast } from 'sonner';
-import { residencesApi } from '@/lib/api';
+import { residencesApi, tasksApi } from '@/lib/api';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import {
@@ -17,6 +17,14 @@ import {
CardTitle,
} from '@/components/ui/card';
import { Separator } from '@/components/ui/separator';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@/components/ui/table';
export function ResidenceDetailClient() {
const params = useParams();
@@ -30,6 +38,12 @@ export function ResidenceDetailClient() {
enabled: !!residenceId,
});
+ const { data: tasksData, isLoading: isLoadingTasks } = useQuery({
+ queryKey: ['residence-tasks', residenceId],
+ queryFn: () => tasksApi.list({ residence_id: residenceId, per_page: 100 }),
+ enabled: !!residenceId,
+ });
+
const deleteMutation = useMutation({
mutationFn: () => residencesApi.delete(residenceId),
onSuccess: () => {
@@ -217,6 +231,70 @@ export function ResidenceDetailClient() {
+
+ {/* Tasks */}
+
+
+ Tasks
+ All tasks for this property
+
+
+ {isLoadingTasks ? (
+ Loading tasks...
+ ) : !tasksData?.data || tasksData.data.length === 0 ? (
+ No tasks for this property
+ ) : (
+
+
+
+ Title
+ Status
+ Priority
+ Category
+ Due Date
+ Created By
+
+
+
+
+ {tasksData.data.map((task) => (
+
+
+
+ {task.title}
+ {task.is_cancelled && (
+ Cancelled
+ )}
+ {task.is_archived && (
+ Archived
+ )}
+
+
+
+ {task.status_name || '-'}
+
+ {task.priority_name || '-'}
+ {task.category_name || '-'}
+
+ {task.due_date
+ ? new Date(task.due_date).toLocaleDateString()
+ : '-'}
+
+ {task.created_by_name}
+
+
+
+
+ ))}
+
+
+ )}
+
+
);
}
diff --git a/admin/src/app/(dashboard)/tasks/[id]/edit/page.tsx b/admin/src/app/(dashboard)/tasks/[id]/edit/page.tsx
index 432e5bc..a124c17 100644
--- a/admin/src/app/(dashboard)/tasks/[id]/edit/page.tsx
+++ b/admin/src/app/(dashboard)/tasks/[id]/edit/page.tsx
@@ -84,8 +84,11 @@ export default function EditTaskPage() {
const [formInitialized, setFormInitialized] = useState(false);
+ // Wait for ALL data including lookups before initializing form
+ const lookupsLoaded = !categoriesLoading && !prioritiesLoading && !statusesLoading && !frequenciesLoading;
+
useEffect(() => {
- if (task && !formInitialized) {
+ if (task && lookupsLoaded && !formInitialized) {
setFormData({
residence_id: task.residence_id,
created_by_id: task.created_by_id,
@@ -106,9 +109,9 @@ export default function EditTaskPage() {
});
setFormInitialized(true);
}
- }, [task, formInitialized]);
+ }, [task, lookupsLoaded, formInitialized]);
- const isDataLoading = taskLoading || usersLoading || residencesLoading || categoriesLoading || prioritiesLoading || statusesLoading || frequenciesLoading || !formInitialized;
+ const isDataLoading = taskLoading || usersLoading || residencesLoading || !lookupsLoaded || !formInitialized;
const updateMutation = useMutation({
mutationFn: (data: UpdateTaskRequest) => tasksApi.update(taskId, data),
@@ -322,8 +325,14 @@ export default function EditTaskPage() {