timesheet approval
This commit is contained in:
@@ -191,6 +191,14 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { data: approvers, error: approverError } = await supabase
|
||||||
|
.from("vb_users") // or vb_employee if you store them there
|
||||||
|
.select("id, full_name");
|
||||||
|
|
||||||
|
if (approverError) {
|
||||||
|
console.error("Error fetching approvers:", approverError);
|
||||||
|
}
|
||||||
|
|
||||||
let reportedBy: { label: string; value: string }[] = [];
|
let reportedBy: { label: string; value: string }[] = [];
|
||||||
const { data: staffData, error: staffError } = await supabase
|
const { data: staffData, error: staffError } = await supabase
|
||||||
.from("vb_employee")
|
.from("vb_employee")
|
||||||
@@ -209,7 +217,8 @@
|
|||||||
const villa = villas.find((v) => v.id === issue.villa_id);
|
const villa = villas.find((v) => v.id === issue.villa_id);
|
||||||
// Map entered_by to staff_id
|
// Map entered_by to staff_id
|
||||||
const staff = reportedBy.find((s) => s.value === issue.entered_by);
|
const staff = reportedBy.find((s) => s.value === issue.entered_by);
|
||||||
|
const approver = approvers?.find(u => u.id === issue.approved_by);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: issue.id,
|
id: issue.id,
|
||||||
name: issue.work_description, // Map work_description to name
|
name: issue.work_description, // Map work_description to name
|
||||||
@@ -231,6 +240,8 @@
|
|||||||
new Date(issue.datetime_in).getTime(),
|
new Date(issue.datetime_in).getTime(),
|
||||||
) /
|
) /
|
||||||
(1000 * 60 * 60), // Convert milliseconds to hours
|
(1000 * 60 * 60), // Convert milliseconds to hours
|
||||||
|
approved_by: approver?.full_name ?? "Not Approved",
|
||||||
|
approved_date: issue.approved_date,
|
||||||
remarks: issue.remarks,
|
remarks: issue.remarks,
|
||||||
created_at: issue.created_at
|
created_at: issue.created_at
|
||||||
? new Date(issue.created_at)
|
? new Date(issue.created_at)
|
||||||
@@ -271,7 +282,18 @@
|
|||||||
if (issue) {
|
if (issue) {
|
||||||
isEditing = true;
|
isEditing = true;
|
||||||
currentEditingId = issue.id;
|
currentEditingId = issue.id;
|
||||||
newIssue = { ...issue };
|
|
||||||
|
newIssue = {
|
||||||
|
work_description: issue.name,
|
||||||
|
entered_by: issue.entered_by || "", // you may need to store the UUID if not already
|
||||||
|
type_of_work: issue.type_of_work,
|
||||||
|
category_of_work: issue.category_of_work,
|
||||||
|
villa_id: dataVilla.find(v => v.villa_name === issue.villa_name)?.id || "",
|
||||||
|
date_in: issue.date_in?.toISOString().slice(0, 16), // for datetime-local
|
||||||
|
date_out: issue.date_out?.toISOString().slice(0, 16),
|
||||||
|
remarks: issue.remarks,
|
||||||
|
total_work_hour: issue.total_hours_work,
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentEditingId = null;
|
currentEditingId = null;
|
||||||
@@ -280,6 +302,7 @@
|
|||||||
showModal = true;
|
showModal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function saveIssue(event: Event) {
|
async function saveIssue(event: Event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user