update user & reward

This commit is contained in:
Raja Oktafrianto
2025-04-12 13:27:16 +07:00
parent 4afc55952f
commit a44bbcc77a
5 changed files with 63 additions and 68 deletions

View File

@ -34,6 +34,7 @@ const DeleteDialog = () => {
const response = await DeleteData(`${API_URL}/user/delete/${selectedUser}/${enforce}`, {
id: selectedUser
});
// console.log('Delete Response User:', response);
if (response?.status) {
setAlert((prev) => ({ ...prev, show: false, message: '' }));
handleDeleteDialog(false, null);

View File

@ -25,6 +25,7 @@ import {
} from '@/components/ui/dialog';
import { CustomerProps } from './AddDialog';
import { useUserContext } from '../hooks';
import { ChevronDown } from 'lucide-react';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { apiConfig } from '@/config/api.config';
@ -142,7 +143,7 @@ const EditDialog = () => {
const doFetchUserData = useCallback(async (id: string) => {
const response = await GetData(`${API_URL}/user/detail/${id}`, { id });
console.log('User detail response:', response?.data);
// console.log('User detail response:', response?.data);
if (response?.status) {
setFormField((prev) => ({
@ -154,7 +155,7 @@ const EditDialog = () => {
status: response.data.status,
customerid: response.data.customerid
}));
console.log('Customer ID dari user detail:', response.data.customerid);
// console.log('Customer ID dari user detail:', response.data.customerid);
} else {
setFormField((prev) => ({
...prev,
@ -230,6 +231,34 @@ const EditDialog = () => {
)}
<form onSubmit={doUpdateUser}>
<div className="card-body grid gap-5 p-0">
<div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56">Name</label>
<Input
className="input"
type="text"
value={formField.name}
onChange={({ target }) =>
setFormField((prev) => ({ ...prev, name: target.value }))
}
/>
</div>
</div>
<div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56">Username</label>
<Input
className="input"
type="text"
value={formField.username}
onChange={({ target }) =>
setFormField((prev) => ({ ...prev, username: target.value }))
}
/>
</div>
</div>
<div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56">Customer</label>
@ -237,11 +266,14 @@ const EditDialog = () => {
<PopoverTrigger asChild>
<button
type="button"
className="input col-span-5 text-left"
className="input col-span-5 text-left flex justify-between"
style={{ color: 'inherit' }}
>
{customers.find((customer) => customer.id === formField.customerid)
?.username || 'Select Customer'}
<span>
{customers.find((customer) => customer.id === formField.customerid)
?.username || 'Select Customer'}
</span>
<ChevronDown className="w-4 h-4 opacity-70" />
</button>
</PopoverTrigger>
<PopoverContent className="w-[400px] p-0">
@ -279,34 +311,6 @@ const EditDialog = () => {
</div>
</div>
<div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56">Name</label>
<Input
className="input"
type="text"
value={formField.name}
onChange={({ target }) =>
setFormField((prev) => ({ ...prev, name: target.value }))
}
/>
</div>
</div>
<div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56">Username</label>
<Input
className="input"
type="text"
value={formField.username}
onChange={({ target }) =>
setFormField((prev) => ({ ...prev, username: target.value }))
}
/>
</div>
</div>
<div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56">Email</label>