mirror of
https://github.com/AbaTekNTNU/followspot-psn.git
synced 2025-12-06 13:54:58 +00:00
Actually use input value
This commit is contained in:
@@ -3,32 +3,34 @@
|
|||||||
import { Button } from "$lib/components/ui/button/index.js";
|
import { Button } from "$lib/components/ui/button/index.js";
|
||||||
import TrackerSetting from "./TrackerSetting.svelte";
|
import TrackerSetting from "./TrackerSetting.svelte";
|
||||||
|
|
||||||
const addTracker = async () => {
|
const addTracker = async (arg: number) => {
|
||||||
const response = await fetch("/tracker", {
|
const response = await fetch("/tracker", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
id: 4,
|
id: arg,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(response);
|
console.log(response);
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteTracker = async () => {
|
const deleteTracker = async (arg: number) => {
|
||||||
const response = await fetch("/tracker", {
|
const response = await fetch("/tracker", {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
id: 4,
|
id: arg,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
console.log(response);
|
console.log(response);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let id = $state(0);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Drawer.Root>
|
<Drawer.Root>
|
||||||
@@ -41,8 +43,12 @@
|
|||||||
<Drawer.Description>This action cannot be undone.</Drawer.Description>
|
<Drawer.Description>This action cannot be undone.</Drawer.Description>
|
||||||
</Drawer.Header>
|
</Drawer.Header>
|
||||||
<div class="flex items-center justify-evenly">
|
<div class="flex items-center justify-evenly">
|
||||||
<TrackerSetting action={addTracker} text="Add Tracker" />
|
<TrackerSetting bind:value={id} action={addTracker} text="Add Tracker" />
|
||||||
<TrackerSetting action={deleteTracker} text="Delete Tracker" />
|
<TrackerSetting
|
||||||
|
bind:value={id}
|
||||||
|
action={deleteTracker}
|
||||||
|
text="Delete Tracker"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Drawer.Content>
|
</Drawer.Content>
|
||||||
</Drawer.Root>
|
</Drawer.Root>
|
||||||
|
|||||||
@@ -4,14 +4,15 @@
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
text: string;
|
text: string;
|
||||||
action: () => void;
|
action: (arg: number) => void;
|
||||||
|
value: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
let { action, text }: Props = $props();
|
let { action, text, value = $bindable() }: Props = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h2>{text}</h2>
|
<h2>{text}</h2>
|
||||||
<Input placeholder={"1"} type="tel" />
|
<Input placeholder={"1"} type="tel" bind:value />
|
||||||
<Button onclick={action}>Submit</Button>
|
<Button onclick={() => action(value)}>Submit</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user