feat: complete requirements gaps - backup/restore, uat signoff, pm attachments, templates, and filters
This commit is contained in:
@@ -8,6 +8,7 @@ import { ApiError } from "@/api/client";
|
||||
import { assetsApi, type AssetLookupItem } from "@/api/assets";
|
||||
import { vendorsApi } from "@/api/masters";
|
||||
import { pmApi, type ServiceMode } from "@/api/pm";
|
||||
import { attachmentsApi } from "@/api/attachments";
|
||||
|
||||
const inputCls =
|
||||
"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500";
|
||||
@@ -250,6 +251,7 @@ export function CompletePMModal({
|
||||
const [completedDate, setCompletedDate] = useState("");
|
||||
const [serviceDetails, setServiceDetails] = useState("");
|
||||
const [remarks, setRemarks] = useState("");
|
||||
const [reportFile, setReportFile] = useState<File | null>(null);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
@@ -258,6 +260,7 @@ export function CompletePMModal({
|
||||
setCompletedDate(new Date().toISOString().slice(0, 10));
|
||||
setServiceDetails("");
|
||||
setRemarks("");
|
||||
setReportFile(null);
|
||||
setError(null);
|
||||
}, [open, recordId]);
|
||||
|
||||
@@ -272,8 +275,12 @@ export function CompletePMModal({
|
||||
service_details: serviceDetails.trim(),
|
||||
remarks: remarks.trim() || null,
|
||||
});
|
||||
if (reportFile) {
|
||||
await attachmentsApi.upload("pm_record", recordId, reportFile);
|
||||
}
|
||||
await qc.invalidateQueries({ queryKey: ["pm-records"] });
|
||||
await qc.invalidateQueries({ queryKey: ["pm-schedules"] });
|
||||
await qc.invalidateQueries({ queryKey: ["attachments", "pm_record", recordId] });
|
||||
if (assetId) await qc.invalidateQueries({ queryKey: ["asset-overview", assetId] });
|
||||
onClose();
|
||||
} catch (err) {
|
||||
@@ -317,6 +324,15 @@ export function CompletePMModal({
|
||||
className={inputCls}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className={labelCls}>Service Report / Checklist (optional)</label>
|
||||
<input
|
||||
type="file"
|
||||
accept=".pdf,.png,.jpg,.jpeg,.doc,.docx"
|
||||
onChange={(e) => setReportFile(e.target.files?.[0] ?? null)}
|
||||
className="w-full text-xs text-gray-700 file:mr-3 file:py-1.5 file:px-3 file:rounded-md file:border-0 file:text-xs file:font-medium file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100 border border-gray-200 rounded-md p-1"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 pt-2">
|
||||
<Button type="button" variant="outline" onClick={onClose}>
|
||||
Cancel
|
||||
|
||||
Reference in New Issue
Block a user