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 AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
|
||||
import { Head, useForm } from '@inertiajs/react';
|
||||
import axios from 'axios';
|
||||
import { FormEventHandler } from 'react';
|
||||
|
||||
interface CustomerProps {
|
||||
|
|
@ -45,6 +46,14 @@ export default function Customer({customer}: CustomerProps) {
|
|||
});
|
||||
}
|
||||
|
||||
const deleteCustomer = (id: string | number) => {
|
||||
axios.delete('/api/customer/' + id)
|
||||
.then(response => {
|
||||
window.location.href = "/dashboard";
|
||||
})
|
||||
.catch(error => {console.log(error)})
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout>
|
||||
<Head title="Deltagare" />
|
||||
|
|
@ -151,8 +160,9 @@ export default function Customer({customer}: CustomerProps) {
|
|||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
|
||||
<button onClick={() => deleteCustomer(customer.id)} className="button mt-4 is-danger is-outlined is-small">
|
||||
<span>Radera deltagare</span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,4 +11,5 @@ Route::post('register_customer', [CustomerController::class, 'store'])->name('re
|
|||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::post('register_deposit', [DepositController::class, 'store'])->name('register_deposit');
|
||||
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