penamabahan menu approval untill received
This commit is contained in:
@@ -130,6 +130,7 @@
|
||||
type Issue = {
|
||||
id: string;
|
||||
name: string;
|
||||
villa_id: string;
|
||||
villa_name: string;
|
||||
area_of_villa: string;
|
||||
priority: string;
|
||||
@@ -148,11 +149,12 @@
|
||||
follow_up: boolean;
|
||||
need_approval: boolean;
|
||||
created_at: string;
|
||||
// Optional field to hold the name of the villa
|
||||
};
|
||||
|
||||
type issueInsert = {
|
||||
name: string;
|
||||
villa_name: string;
|
||||
villa_id: string;
|
||||
area_of_villa: string;
|
||||
priority: string;
|
||||
issue_type: string;
|
||||
@@ -244,7 +246,7 @@
|
||||
}
|
||||
|
||||
// Ambil semua villa_id unik dari issues
|
||||
const villaIds = [...new Set(issues.map((i: Issue) => i.villa_name))];
|
||||
const villaIds = [...new Set(issues.map((i: Issue) => i.villa_id))];
|
||||
|
||||
const { data: villas, error: villaError } = await supabase
|
||||
.from("villas")
|
||||
@@ -260,7 +262,7 @@
|
||||
allRows = issues.map((issue: Issue) => ({
|
||||
...issue,
|
||||
villa_name:
|
||||
villas.find((v) => v.id === issue.villa_name).name || null,
|
||||
villas.find((v) => v.id === issue.villa_id).name || null,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -268,10 +270,6 @@
|
||||
let rowsPerPage = limit;
|
||||
$: totalPages = Math.ceil(totalItems / rowsPerPage);
|
||||
|
||||
function editIssue(id: number) {
|
||||
alert(`Edit issue with ID ${id}`);
|
||||
}
|
||||
|
||||
function goToPage(page: number) {
|
||||
if (page >= 1 && page <= totalPages) currentPage = page;
|
||||
}
|
||||
@@ -352,7 +350,7 @@
|
||||
} else {
|
||||
const issueInsert: issueInsert = {
|
||||
name: formData.get("name") as string,
|
||||
villa_name: formData.get("villa_name") as string,
|
||||
villa_id: formData.get("villa_id") as string,
|
||||
area_of_villa: formData.get("area_of_villa") as string,
|
||||
priority: formData.get("priority") as string,
|
||||
issue_type: formData.get("issue_type") as string,
|
||||
@@ -429,7 +427,7 @@
|
||||
"name",
|
||||
"description_of_the_issue",
|
||||
"issue_source",
|
||||
"villa_name",
|
||||
"villa_id",
|
||||
"reported_date",
|
||||
"reported_by",
|
||||
"priority",
|
||||
@@ -1029,15 +1027,15 @@
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if col.key === "villa_name"}
|
||||
{:else if col.key === "villa_id"}
|
||||
<div class="space-y-1">
|
||||
<label class="block text-sm font-medium text-gray-700"
|
||||
>Villa Name</label
|
||||
>
|
||||
<select
|
||||
name="villa_name"
|
||||
name="villa_id"
|
||||
class="w-full border px-3 py-2 rounded {errorClass(
|
||||
'villa_name',
|
||||
'villa_id',
|
||||
)}"
|
||||
bind:value={newIssue[col.key as keyof Issue]}
|
||||
>
|
||||
@@ -1048,9 +1046,9 @@
|
||||
<option value={villa.id}>{villa.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{#if $formErrors.villa_name}
|
||||
{#if $formErrors.villa_id}
|
||||
<p class="text-red-500 text-xs">
|
||||
{$formErrors.villa_name}
|
||||
{$formErrors.villa_id}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user