penambahan fitur relasi to table user
This commit is contained in:
@@ -132,7 +132,13 @@
|
|||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type User = {
|
||||||
|
id: string;
|
||||||
|
full_name: string;
|
||||||
|
};
|
||||||
|
|
||||||
let dataVilla: Villa[] = [];
|
let dataVilla: Villa[] = [];
|
||||||
|
let dataUser: User[] = [];
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
@@ -144,6 +150,15 @@
|
|||||||
} else if (data) {
|
} else if (data) {
|
||||||
dataVilla = data;
|
dataVilla = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { data: userData, error: userError } = await supabase
|
||||||
|
.from("users")
|
||||||
|
.select("id, full_name");
|
||||||
|
if (userError) {
|
||||||
|
console.error("Error fetching users:", userError);
|
||||||
|
} else if (userData) {
|
||||||
|
dataUser = userData;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
type Issue = {
|
type Issue = {
|
||||||
@@ -403,9 +418,9 @@
|
|||||||
<option value="" disabled selected
|
<option value="" disabled selected
|
||||||
>Select option...</option
|
>Select option...</option
|
||||||
>
|
>
|
||||||
{#each reportedBy as reporter}
|
{#each dataUser as reporter}
|
||||||
<option value={reporter.value}>
|
<option value={reporter.id}>
|
||||||
{reporter.label}
|
{reporter.full_name}
|
||||||
</option>
|
</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
@@ -541,8 +556,8 @@
|
|||||||
<option value="" disabled selected
|
<option value="" disabled selected
|
||||||
>Select option...</option
|
>Select option...</option
|
||||||
>
|
>
|
||||||
{#each inputBy as input}
|
{#each dataUser as input}
|
||||||
<option value={input.value}>{input.label}</option>
|
<option value={input.id}>{input.full_name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
{#if $formErrors.input_by}
|
{#if $formErrors.input_by}
|
||||||
Reference in New Issue
Block a user