mirror of
https://github.com/anna-sara/lan_kiosk
synced 2025-10-26 13:07:14 +01:00
Made it possible to delete customer
This commit is contained in:
parent
d9f15a2d99
commit
5859ba1c49
2 changed files with 15 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import TextInput from '@/Components/TextInput';
|
import TextInput from '@/Components/TextInput';
|
||||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
|
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
|
||||||
import { Head, useForm } from '@inertiajs/react';
|
import { Head, useForm } from '@inertiajs/react';
|
||||||
|
import axios from 'axios';
|
||||||
import { FormEventHandler } from 'react';
|
import { FormEventHandler } from 'react';
|
||||||
|
|
||||||
interface CustomerProps {
|
interface CustomerProps {
|
||||||
|
|
@ -44,14 +45,22 @@ export default function Customer({customer}: CustomerProps) {
|
||||||
onFinish: () => reset('deposit'),
|
onFinish: () => reset('deposit'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const deleteCustomer = (id: string | number) => {
|
||||||
|
axios.delete('/api/customer/' + id)
|
||||||
|
.then(response => {
|
||||||
|
window.location.href = "/dashboard";
|
||||||
|
})
|
||||||
|
.catch(error => {console.log(error)})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthenticatedLayout>
|
<AuthenticatedLayout>
|
||||||
<Head title="Deltagare" />
|
<Head title="Deltagare" />
|
||||||
|
|
||||||
<section className='section'>
|
<section className='section'>
|
||||||
<div className="container is-max-desktop">
|
<div className="container is-max-desktop">
|
||||||
<h1 className="title is-2">{customer.name}</h1>
|
<h1 className="title is-2">{customer.name}</h1>
|
||||||
<div className='container is-centered'>
|
<div className='container is-centered'>
|
||||||
<div className="box">
|
<div className="box">
|
||||||
<h2 className='title is-4'>Saldo: {customer.amount_left ? customer.amount_left : 0} kr</h2>
|
<h2 className='title is-4'>Saldo: {customer.amount_left ? customer.amount_left : 0} kr</h2>
|
||||||
|
|
@ -151,8 +160,9 @@ export default function Customer({customer}: CustomerProps) {
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
|
<button onClick={() => deleteCustomer(customer.id)} className="button mt-4 is-danger is-outlined is-small">
|
||||||
|
<span>Radera deltagare</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,5 @@ Route::post('register_customer', [CustomerController::class, 'store'])->name('re
|
||||||
Route::middleware('auth:sanctum')->group(function () {
|
Route::middleware('auth:sanctum')->group(function () {
|
||||||
Route::post('register_deposit', [DepositController::class, 'store'])->name('register_deposit');
|
Route::post('register_deposit', [DepositController::class, 'store'])->name('register_deposit');
|
||||||
Route::post('register_purchase', [PurchaseController::class, 'store'])->name('register_purchase');
|
Route::post('register_purchase', [PurchaseController::class, 'store'])->name('register_purchase');
|
||||||
|
Route::delete('customer/{id}', [CustomerController::class, 'destroy'])->name('delete_customer');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue