Update API call for fetching sucos and modify payload structure
- Change `with_deleted` from true to false when fetching sucos - Update payload sent to API to include only name, description, and status
This commit is contained in:
@ -153,7 +153,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
|
|||||||
const response = await GetData(`${API_URL}/sucos/list`, {
|
const response = await GetData(`${API_URL}/sucos/list`, {
|
||||||
limit: limit,
|
limit: limit,
|
||||||
page: page + 1,
|
page: page + 1,
|
||||||
with_deleted: true,
|
with_deleted: false,
|
||||||
order_field: sorting[0].id,
|
order_field: sorting[0].id,
|
||||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||||
filter: JSON.stringify(filter)
|
filter: JSON.stringify(filter)
|
||||||
|
|||||||
@ -53,13 +53,11 @@ const EditDialog = () => {
|
|||||||
description: string;
|
description: string;
|
||||||
status: string;
|
status: string;
|
||||||
group: string[];
|
group: string[];
|
||||||
currency_id: string;
|
|
||||||
} = {
|
} = {
|
||||||
name: '',
|
name: '',
|
||||||
description: '',
|
description: '',
|
||||||
status: '',
|
status: '',
|
||||||
group: [],
|
group: []
|
||||||
currency_id: ''
|
|
||||||
};
|
};
|
||||||
const [formField, setFormField] = useState(initialState);
|
const [formField, setFormField] = useState(initialState);
|
||||||
const [currencies, setCurrencies] = useState<CurrencyProps[]>([]);
|
const [currencies, setCurrencies] = useState<CurrencyProps[]>([]);
|
||||||
@ -71,12 +69,12 @@ const EditDialog = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const doUpdateWallet = useCallback(
|
const doUpdateWallet = useCallback(
|
||||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
async (payload: { name: string; description: string; status: string }) => {
|
||||||
e.preventDefault();
|
// e.preventDefault();
|
||||||
|
|
||||||
const response = await PutData(
|
const response = await PutData(
|
||||||
`${API_URL_MASTER_DATA}/wallet/update/${selectedWallet?.Wallet_id}`,
|
`${API_URL_MASTER_DATA}/wallet/update/${selectedWallet?.Wallet_id}`,
|
||||||
formField
|
payload
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response?.status) {
|
if (response?.status) {
|
||||||
@ -94,8 +92,14 @@ const EditDialog = () => {
|
|||||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
console.log(formField);
|
// const { name, description, status } = formField;
|
||||||
doUpdateWallet(e);
|
const payload = {
|
||||||
|
name: formField.name,
|
||||||
|
description: formField.description,
|
||||||
|
status: formField.status
|
||||||
|
};
|
||||||
|
// console.log(payload);
|
||||||
|
doUpdateWallet(payload);
|
||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -156,8 +160,6 @@ const EditDialog = () => {
|
|||||||
.map((g) => g.name)
|
.map((g) => g.name)
|
||||||
.join(', ');
|
.join(', ');
|
||||||
|
|
||||||
const selectedCurrency = currencies.find((currency) => currency.ID === formField.currency_id);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getCurrencyLists([{ id: 'name', desc: false }]);
|
getCurrencyLists([{ id: 'name', desc: false }]);
|
||||||
getGroupLists([{ id: 'name', desc: false }]);
|
getGroupLists([{ id: 'name', desc: false }]);
|
||||||
@ -182,7 +184,7 @@ const EditDialog = () => {
|
|||||||
resetForm();
|
resetForm();
|
||||||
}
|
}
|
||||||
}, [showEditDialog]);
|
}, [showEditDialog]);
|
||||||
// console.log(selectedWallet);
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
|
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
|
||||||
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
||||||
@ -246,17 +248,10 @@ const EditDialog = () => {
|
|||||||
</div>
|
</div>
|
||||||
</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">Currency</label>
|
|
||||||
<Input type="text" placeholder='Empty' value={selectedCurrency?.name || ''} readOnly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<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">Groups</label>
|
<label className="form-label flex items-center gap-1 max-w-56">Groups</label>
|
||||||
<Input type="text" placeholder='Empty' value={selectedGroupNames} readOnly />
|
<Input type="text" placeholder="Empty" value={selectedGroupNames} readOnly />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -264,7 +259,9 @@ const EditDialog = () => {
|
|||||||
<Button type="button" variant="outline" onClick={resetForm}>
|
<Button type="button" variant="outline" onClick={resetForm}>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="default">Update</Button>
|
<Button variant="default" type="submit">
|
||||||
|
Update
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user