Merge branch 'alwi'
This commit is contained in:
@ -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}
|
||||||
|
|||||||
@ -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,17 +117,23 @@ const AddDialog = () => {
|
|||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
const getTransactionTypeList = async (sorting: any) => {
|
||||||
if (showAddDialog) {
|
try {
|
||||||
setFormField({
|
const response = await GetData(`${API_URL_TRANSACTION}/transactiontype/list`, {
|
||||||
...formField,
|
limit: 100,
|
||||||
created_by: parsedUser.username,
|
page: 1,
|
||||||
created_at: formattedTime
|
with_deleted: false,
|
||||||
|
order_field: sorting[0].id,
|
||||||
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}, [formattedTime]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
// console.log('TRANSACTION TYPE: ', response?.data);
|
||||||
|
setTransactions(response?.data.list);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching transaction type', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const getCustomerList = async (sorting: any) => {
|
const getCustomerList = async (sorting: any) => {
|
||||||
try {
|
try {
|
||||||
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||||
@ -145,24 +152,18 @@ const AddDialog = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTransactionTypeList = async (sorting: any) => {
|
useEffect(() => {
|
||||||
try {
|
if (showAddDialog) {
|
||||||
const response = await GetData(`${API_URL_TRANSACTION}/transactiontype/list`, {
|
setFormField({
|
||||||
limit: 100,
|
...formField,
|
||||||
page: 1,
|
created_by: parsedUser.username,
|
||||||
with_deleted: false,
|
created_at: formattedTime
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
};
|
}, [formattedTime]);
|
||||||
|
|
||||||
getCustomerList([{ id: 'msisdn', desc: false }]);
|
useEffect(() => {
|
||||||
|
getCustomerList([{ id: 'id', 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);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -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 }]);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user