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