update add manage notification

This commit is contained in:
Raja Oktafrianto
2025-04-18 13:31:19 +07:00
parent f235ee4832
commit a45d3b0a4f

View File

@ -26,7 +26,7 @@ import { Button } from '@/components/ui/button';
import { useManageNotificationContext } from '../hooks/useManageNotificationContext'; import { useManageNotificationContext } from '../hooks/useManageNotificationContext';
import { doSaveLogActivity } from '@/actions/GlobalActions'; import { doSaveLogActivity } from '@/actions/GlobalActions';
import { CustomerProps } from '@/pages/master/provider/blocks/AddDialog'; import { CustomerProps } from '@/pages/master/provider/blocks/AddDialog';
import { ChevronDown } from 'lucide-react'; import { Check, ChevronDown } from 'lucide-react';
const API_URL_CUSTOMER = apiConfig.service_customer; const API_URL_CUSTOMER = apiConfig.service_customer;
const API_URL_NOTIFICATION = apiConfig.service_notification; const API_URL_NOTIFICATION = apiConfig.service_notification;
@ -225,26 +225,33 @@ const AddDialog = () => {
> >
<CommandEmpty>No Customer found.</CommandEmpty> <CommandEmpty>No Customer found.</CommandEmpty>
<CommandGroup> <CommandGroup>
{customers.map((customer) => ( {customers.map((customer) => {
<CommandItem const isSelected = formField.customers.includes(customer.id);
key={customer.id} return (
value={customer.username} <CommandItem
onSelect={() => { key={customer.id}
const customerId = customer.id; value={customer.username}
setFormField((prev) => { onSelect={() => {
const isSelected = prev.customers.includes(customerId); const customerId = customer.id;
return { setFormField((prev) => {
...prev, const isSelected = prev.customers.includes(customerId);
customers: isSelected return {
? prev.customers.filter((id) => id !== customerId) ...prev,
: [...prev.customers, customerId] customers: isSelected
}; ? prev.customers.filter((id) => id !== customerId)
}); : [...prev.customers, customerId]
}} };
> });
{customer.username} }}
</CommandItem> className={isSelected ? 'bg-accent font-semibold' : ''}
))} >
<span className="flex items-center gap-2">
{isSelected && <Check className="w-4 h-4 text-green-600" />}
{customer.username}
</span>
</CommandItem>
);
})}
</CommandGroup> </CommandGroup>
</CommandList> </CommandList>
</Command> </Command>