shoc-frontend-new/src/pages/followup/api.js

65 lines
1.8 KiB
JavaScript
Raw Normal View History

// Mock follow-ups data
const mockFollowUps = [
{
id: 1,
workOrder: "WO-001",
reason: "Quarterly maintenance check",
scheduledDate: "2024-01-22",
status: "Pending",
createdBy: "John Anderson",
createdDate: "2024-01-15",
notes: "Check all HVAC filters and oil levels",
},
{
id: 2,
workOrder: "WO-002",
reason: "Verify electrical repairs",
scheduledDate: "2024-01-25",
status: "Pending",
createdBy: "Sarah Martinez",
createdDate: "2024-01-16",
notes: "Test all outlets to ensure proper operation",
},
{
id: 3,
workOrder: "WO-003",
reason: "Post-repair inspection",
scheduledDate: "2024-01-20",
status: "Completed",
createdBy: "Mike Johnson",
createdDate: "2024-01-10",
notes: "Plumbing inspection completed successfully",
},
];
export const getFollowUps = async () => {
await new Promise(resolve => setTimeout(resolve, 300));
return [...mockFollowUps];
};
export const getFollowUpById = async (id) => {
await new Promise(resolve => setTimeout(resolve, 200));
return mockFollowUps.find(f => f.id === parseInt(id));
};
export const addFollowUp = async (followUp) => {
await new Promise(resolve => setTimeout(resolve, 500));
const newFollowUp = { id: mockFollowUps.length + 1, ...followUp };
mockFollowUps.push(newFollowUp);
return newFollowUp;
};
export const editFollowUp = async (followUp) => {
await new Promise(resolve => setTimeout(resolve, 500));
const idx = mockFollowUps.findIndex(f => f.id === followUp.id);
if (idx >= 0) mockFollowUps[idx] = followUp;
return followUp;
};
export const deleteFollowUp = async (id) => {
await new Promise(resolve => setTimeout(resolve, 500));
const idx = mockFollowUps.findIndex(f => f.id === id);
if (idx >= 0) mockFollowUps.splice(idx, 1);
return true;
};