Merge branch 'alwi'

This commit is contained in:
Wikzyy
2025-03-25 13:58:27 +07:00
3 changed files with 45 additions and 44 deletions

View File

@ -19,7 +19,7 @@ const DialogOverlay = React.forwardRef<
<DialogPrimitive.Overlay <DialogPrimitive.Overlay
ref={ref} ref={ref}
className={cn( className={cn(
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0', 'fixed inset-0 z-50 bg-black/40 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
className className
)} )}
{...props} {...props}

View File

@ -33,6 +33,7 @@ import {
} from '@/components/ui/command'; } from '@/components/ui/command';
export interface CustomerProps { export interface CustomerProps {
id: string;
msisdn: string; msisdn: string;
email: string; email: string;
fullname: string; fullname: string;
@ -86,7 +87,7 @@ const AddDialog = () => {
const response = await PostData(`${API_URL_MASTERDATA}/provider/create`, formField); const response = await PostData(`${API_URL_MASTERDATA}/provider/create`, formField);
if (response?.status) { if (response?.status) {
resetForm(); // resetForm();
handleAddDialog(false); handleAddDialog(false);
toast.success('Success Create Provider'); toast.success('Success Create Provider');
reload(); reload();
@ -116,6 +117,41 @@ const AddDialog = () => {
setAlert({ show: false, message: '' }); setAlert({ show: false, message: '' });
}; };
const getTransactionTypeList = async (sorting: any) => {
try {
const response = await GetData(`${API_URL_TRANSACTION}/transactiontype/list`, {
limit: 100,
page: 1,
with_deleted: false,
order_field: sorting[0].id,
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
});
// console.log('TRANSACTION TYPE: ', response?.data);
setTransactions(response?.data.list);
} catch (error) {
console.error('Error fetching transaction type', error);
}
};
const getCustomerList = async (sorting: any) => {
try {
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
const response = await GetData(`${API_URL_CUSTOMER}/customer/list`, {
limit: 100,
page: 1,
with_deleted: false,
order_field: sorting[0].id,
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
});
// console.log('CUSTOMER: ', response?.data);
setCustomers(response?.data.list);
} catch (error) {
console.error('Error fetching customer', error);
}
};
useEffect(() => { useEffect(() => {
if (showAddDialog) { if (showAddDialog) {
setFormField({ setFormField({
@ -127,42 +163,7 @@ const AddDialog = () => {
}, [formattedTime]); }, [formattedTime]);
useEffect(() => { useEffect(() => {
const getCustomerList = async (sorting: any) => { getCustomerList([{ id: 'id', desc: false }]);
try {
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
const response = await GetData(`${API_URL_CUSTOMER}/customer/list`, {
limit: 100,
page: 1,
with_deleted: false,
order_field: sorting[0].id,
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
});
// console.log('CUSTOMER: ', response?.data);
setCustomers(response?.data.list);
} catch (error) {
console.error('Error fetching customer', error);
}
};
const getTransactionTypeList = async (sorting: any) => {
try {
const response = await GetData(`${API_URL_TRANSACTION}/transactiontype/list`, {
limit: 100,
page: 1,
with_deleted: false,
order_field: sorting[0].id,
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
});
// console.log('TRANSACTION TYPE: ', response?.data);
setTransactions(response?.data.list);
} catch (error) {
console.error('Error fetching transaction type', error);
}
};
getCustomerList([{ id: 'msisdn', desc: false }]);
getTransactionTypeList([{ id: 'name', desc: false }]); getTransactionTypeList([{ id: 'name', desc: false }]);
}, []); }, []);
@ -290,7 +291,7 @@ const AddDialog = () => {
<Popover open={open} onOpenChange={setOpen}> <Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild> <PopoverTrigger asChild>
<button type="button" className="input col-span-5 text-left"> <button type="button" className="input col-span-5 text-left">
{customers.find((customer) => customer.msisdn === formField.agent) {customers.find((customer) => customer.id === formField.agent)
?.fullname || 'Select Agent'} ?.fullname || 'Select Agent'}
</button> </button>
</PopoverTrigger> </PopoverTrigger>
@ -302,12 +303,12 @@ const AddDialog = () => {
<CommandGroup> <CommandGroup>
{customers.map((customer) => ( {customers.map((customer) => (
<CommandItem <CommandItem
key={customer.msisdn} key={customer.id}
value={customer.fullname} value={customer.id}
onSelect={() => { onSelect={() => {
setFormField({ setFormField({
...formField, ...formField,
agent: customer.msisdn agent: customer.id
}); });
setOpen(false); setOpen(false);
}} }}

View File

@ -128,7 +128,7 @@ const EditDialog = () => {
const doFetchData = useCallback(async (id: string) => { const doFetchData = useCallback(async (id: string) => {
const response = await GetData(`${API_URL_MASTERDATA}/provider/getdata/${id}`, { id }); const response = await GetData(`${API_URL_MASTERDATA}/provider/getdata/${id}`, { id });
console.log(response); // console.log(response);
if (response?.status) { if (response?.status) {
setFormField((prev) => ({ setFormField((prev) => ({
...prev, ...prev,
@ -185,7 +185,7 @@ const EditDialog = () => {
}, [formattedTime]); }, [formattedTime]);
useEffect(() => { useEffect(() => {
getCustomerList([{ id: 'msisdn', desc: false }]); getCustomerList([{ id: 'id', desc: false }]);
getTransactionTypeList([{ id: 'name', desc: false }]); getTransactionTypeList([{ id: 'name', desc: false }]);
}, []); }, []);