This commit is contained in:
+3
-3
@@ -6,11 +6,11 @@ import { useRFA } from "@/hooks/use-rfa";
|
||||
import { Loader2 } from "lucide-react";
|
||||
|
||||
export default function RFADetailPage() {
|
||||
const { id } = useParams();
|
||||
const { uuid } = useParams();
|
||||
|
||||
if (!id) notFound();
|
||||
if (!uuid) notFound();
|
||||
|
||||
const { data: rfa, isLoading, isError } = useRFA(String(id));
|
||||
const { data: rfa, isLoading, isError } = useRFA(String(uuid));
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
+5
-5
@@ -22,12 +22,12 @@ import { toast } from "sonner";
|
||||
|
||||
export default function TransmittalDetailPage() {
|
||||
const params = useParams();
|
||||
const id = params.id as string;
|
||||
const uuid = params.uuid as string;
|
||||
|
||||
const { data: transmittal, isLoading, error } = useQuery<Transmittal>({
|
||||
queryKey: ["transmittal", id],
|
||||
queryFn: () => transmittalService.getById(id),
|
||||
enabled: !!id,
|
||||
queryKey: ["transmittal", uuid],
|
||||
queryFn: () => transmittalService.getByUuid(uuid),
|
||||
enabled: !!uuid,
|
||||
});
|
||||
|
||||
const handlePrint = () => {
|
||||
@@ -100,7 +100,7 @@ export default function TransmittalDetailPage() {
|
||||
<p className="text-sm text-muted-foreground">Generated From</p>
|
||||
{transmittal.correspondence ? (
|
||||
<Link
|
||||
href={`/correspondences/${transmittal.correspondenceId}`}
|
||||
href={`/correspondences/${transmittal.correspondence.uuid}`}
|
||||
className="font-medium text-primary hover:underline"
|
||||
>
|
||||
{transmittal.correspondence.correspondence_number}
|
||||
@@ -1,22 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { TransmittalList } from "@/components/transmittal/transmittal-list";
|
||||
import { transmittalService } from "@/lib/services/transmittal.service";
|
||||
import { projectService } from "@/lib/services/project.service";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { Plus, RefreshCw } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { TransmittalListResponse } from "@/types/transmittal";
|
||||
|
||||
export default function TransmittalPage() {
|
||||
// ADR-019: Dynamic project selection via UUID
|
||||
const [selectedProjectUuid, setSelectedProjectUuid] = useState<string>("");
|
||||
|
||||
const { data: projectsData } = useQuery({
|
||||
queryKey: ["projects-for-transmittals"],
|
||||
queryFn: () => projectService.getAll(),
|
||||
});
|
||||
const projects = projectsData?.data || projectsData || [];
|
||||
|
||||
const {
|
||||
data,
|
||||
isLoading,
|
||||
error,
|
||||
refetch,
|
||||
} = useQuery<TransmittalListResponse>({
|
||||
queryKey: ["transmittals"],
|
||||
queryFn: () => transmittalService.getAll({ projectId: 1 }),
|
||||
queryKey: ["transmittals", selectedProjectUuid],
|
||||
queryFn: () => transmittalService.getAll({ projectId: selectedProjectUuid }),
|
||||
enabled: !!selectedProjectUuid,
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -47,6 +66,23 @@ export default function TransmittalPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ADR-019: Project filter */}
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-sm font-medium text-muted-foreground">Project:</span>
|
||||
<Select value={selectedProjectUuid} onValueChange={setSelectedProjectUuid}>
|
||||
<SelectTrigger className="w-[280px]">
|
||||
<SelectValue placeholder="Select a project" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{(Array.isArray(projects) ? projects : []).map((p: { uuid: string; projectName?: string; projectCode?: string }) => (
|
||||
<SelectItem key={p.uuid} value={p.uuid}>
|
||||
{p.projectName || p.projectCode}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="bg-destructive/10 text-destructive px-4 py-3 rounded-md">
|
||||
Failed to load transmittals.
|
||||
|
||||
Reference in New Issue
Block a user