feat: deleting vehicles
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
} from "$lib/vehicles/vehicles.svelte";
|
||||
import AddVehicleDrawer from "./AddVehicleDrawer.svelte";
|
||||
import { m } from "$lang/messages";
|
||||
import { updateStore } from "$lib/services/stores.svelte";
|
||||
|
||||
let open = $state(false);
|
||||
|
||||
@ -56,9 +57,10 @@
|
||||
</Drawer.Header>
|
||||
<div class="p-4 pt-0 flex flex-col gap-2">
|
||||
{#each vehicles.current as vehicle (vehicle.name)}
|
||||
<div class="flex items-center gap-2">
|
||||
<Button
|
||||
variant={selectedVehicle() === vehicle.data ? "default" : "secondary"}
|
||||
class="w-full p-5"
|
||||
class="w-[calc(100%-48px-8px)] p-5"
|
||||
onclick={() => {
|
||||
selectVehicle(vehicle.data);
|
||||
open = false;
|
||||
@ -68,6 +70,13 @@
|
||||
<Icon />
|
||||
{vehicle.data.name}
|
||||
</Button>
|
||||
<Button variant="destructive" class="w-[48px]" onclick={() => {
|
||||
if(!confirm("Are you sure you want to delete this vehicle? This action cannot be undone.")) return;
|
||||
updateStore({ type: "vehicle", name: vehicle.name }, null);
|
||||
}}>
|
||||
X
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
<AddVehicleDrawer>
|
||||
|
||||
Reference in New Issue
Block a user