Private
Public Access
feat: añadido eliminar repuestos y un modal para ver el objeto entero
This commit is contained in:
1 parent
72790ac9a3
commit
2549b7d6ba
7 files changed
+168
-12
No files matched your search
@@ -0,0 +1,39 @@
|
||||
<script>
|
||||
import {
|
||||
StructuredList,
|
||||
StructuredListBody,
|
||||
StructuredListRow,
|
||||
StructuredListCell,
|
||||
Modal
|
||||
} from 'carbon-components-svelte';
|
||||
|
||||
let { objeto = $bindable(), open = $bindable() } = $props();
|
||||
|
||||
function handleClose() {
|
||||
objeto = null;
|
||||
open = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
bind:open
|
||||
modalHeading="Info"
|
||||
secondaryButtonText="Cerrar"
|
||||
on:click:button--secondary={handleClose}
|
||||
primaryButtonDisabled={true}
|
||||
>
|
||||
{#if objeto != null}
|
||||
<StructuredList>
|
||||
<StructuredListBody>
|
||||
{#each Object.entries(objeto) as [campo, valor]}
|
||||
<StructuredListRow>
|
||||
<StructuredListCell>{campo}</StructuredListCell>
|
||||
<StructuredListCell>
|
||||
{JSON.stringify(valor)}
|
||||
</StructuredListCell>
|
||||
</StructuredListRow>
|
||||
{/each}
|
||||
</StructuredListBody>
|
||||
</StructuredList>
|
||||
{/if}
|
||||
</Modal>
|
||||
@@ -0,0 +1,20 @@
|
||||
import { API_URL } from '$lib/env';
|
||||
import { getToken } from '../token';
|
||||
|
||||
export async function eliminarRepuesto(id: number) {
|
||||
try {
|
||||
const req = await fetch(`${API_URL}/repuestos/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Authorization: `Bearer ${getToken()}`
|
||||
}
|
||||
});
|
||||
if (req.ok) {
|
||||
return 'Ok';
|
||||
}
|
||||
const data = await req.json();
|
||||
return data.error;
|
||||
} catch {
|
||||
return 'no se puso alcanzar el servidor';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user