Merge branch 'alwi'
This commit is contained in:
@ -78,6 +78,24 @@ const AddDialog = () => {
|
|||||||
[formField]
|
[formField]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const doFetchSucos = async (sorting: any) => {
|
||||||
|
try {
|
||||||
|
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||||
|
const response = await GetData(`${API_URL}/sucos/list`, {
|
||||||
|
limit: 1000,
|
||||||
|
page: 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: sorting[0].id,
|
||||||
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log('SUCOS', response?.data);
|
||||||
|
setSucos(response?.data.list);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching municipios', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -102,25 +120,7 @@ const AddDialog = () => {
|
|||||||
}, [formattedTime]);
|
}, [formattedTime]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchSucos = async (sorting: any) => {
|
doFetchSucos([{ id: 'name', desc: false }]);
|
||||||
try {
|
|
||||||
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
|
||||||
const response = await GetData(`${API_URL}/sucos/list`, {
|
|
||||||
limit: 100,
|
|
||||||
page: 1,
|
|
||||||
with_deleted: false,
|
|
||||||
order_field: sorting[0].id,
|
|
||||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.log('SUCOS', response?.data);
|
|
||||||
setSucos(response?.data.list);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching municipios', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchSucos([{ id: 'name', desc: false }]);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -77,6 +77,42 @@ const EditDialog = () => {
|
|||||||
[selectedAldeias, formField]
|
[selectedAldeias, formField]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const doFetchSucos = async (sorting: any) => {
|
||||||
|
try {
|
||||||
|
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||||
|
const response = await GetData(`${API_URL}/sucos/list`, {
|
||||||
|
limit: 1000,
|
||||||
|
page: 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: sorting[0].id,
|
||||||
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log('SUCOS', response?.data);
|
||||||
|
setSucos(response?.data.list);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching municipios', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const doFetchData = useCallback(async (id: string) => {
|
||||||
|
const response = await GetData(`${API_URL}/aldeias/getdata/${id}`, { id });
|
||||||
|
|
||||||
|
if (response?.status) {
|
||||||
|
setFormField((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: response.data.name,
|
||||||
|
sucos_id: response.data.sucos.id
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
setFormField((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: '',
|
||||||
|
sucos_id: 0
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -90,6 +126,18 @@ const EditDialog = () => {
|
|||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (selectedAldeias) {
|
||||||
|
doFetchData(selectedAldeias);
|
||||||
|
}
|
||||||
|
}, [selectedAldeias]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (showEditDialog === false) {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
}, [showEditDialog]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (showEditDialog) {
|
if (showEditDialog) {
|
||||||
setFormField({
|
setFormField({
|
||||||
@ -101,25 +149,7 @@ const EditDialog = () => {
|
|||||||
}, [formattedTime]);
|
}, [formattedTime]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchSucos = async (sorting: any) => {
|
doFetchSucos([{ id: 'name', desc: false }]);
|
||||||
try {
|
|
||||||
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
|
||||||
const response = await GetData(`${API_URL}/sucos/list`, {
|
|
||||||
limit: 100,
|
|
||||||
page: 1,
|
|
||||||
with_deleted: false,
|
|
||||||
order_field: sorting[0].id,
|
|
||||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.log('SUCOS', response?.data);
|
|
||||||
setSucos(response?.data.list);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching municipios', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchSucos([{ id: 'name', desc: false }]);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -25,7 +25,7 @@ const EditDialog = () => {
|
|||||||
const { showEditDialog, handleEditDialog, selectedMunicipios, municipios } =
|
const { showEditDialog, handleEditDialog, selectedMunicipios, municipios } =
|
||||||
useManageMunicipiosContext();
|
useManageMunicipiosContext();
|
||||||
const { reload } = useDataGrid();
|
const { reload } = useDataGrid();
|
||||||
const { PutData } = useCallApi();
|
const { PutData, GetData } = useCallApi();
|
||||||
const parsedUser = getAuth()?.user;
|
const parsedUser = getAuth()?.user;
|
||||||
const [alert, setAlert] = useState({
|
const [alert, setAlert] = useState({
|
||||||
show: false,
|
show: false,
|
||||||
@ -44,6 +44,7 @@ const EditDialog = () => {
|
|||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
setFormField(initialState);
|
setFormField(initialState);
|
||||||
|
setAlert({ show: false, message: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
const doUpdateMunicipios = useCallback(
|
const doUpdateMunicipios = useCallback(
|
||||||
@ -74,6 +75,22 @@ const EditDialog = () => {
|
|||||||
[selectedMunicipios, formField]
|
[selectedMunicipios, formField]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const doFetchData = useCallback(async (id: string) => {
|
||||||
|
const response = await GetData(`${API_URL}/municipios/getdata/${id}`, { id });
|
||||||
|
|
||||||
|
if (response?.status) {
|
||||||
|
setFormField((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: response.data.name
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
setFormField((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: ''
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -82,20 +99,22 @@ const EditDialog = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// setFormField({
|
|
||||||
// name: formField.name,
|
|
||||||
// created_by: parsedUser.email,
|
|
||||||
// created_at: formattedTime
|
|
||||||
// });
|
|
||||||
|
|
||||||
doUpdateMunicipios(e);
|
doUpdateMunicipios(e);
|
||||||
console.log(formField);
|
console.log(formField);
|
||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
// const doFetchMunicipios = useCallback(async (id: string) => {
|
useEffect(() => {
|
||||||
// const response = await axios.get(`${API_URL}/municipios/${id}`);
|
if (selectedMunicipios) {
|
||||||
// }, []);
|
doFetchData(selectedMunicipios);
|
||||||
|
}
|
||||||
|
}, [selectedMunicipios]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (showEditDialog === false) {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
}, [showEditDialog]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedMunicipios) {
|
if (selectedMunicipios) {
|
||||||
@ -127,7 +146,9 @@ const EditDialog = () => {
|
|||||||
<div className="card-body grid gap-5">
|
<div className="card-body grid gap-5">
|
||||||
<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">Name</label>
|
<label className="form-label flex items-center gap-1 max-w-56">
|
||||||
|
Name<span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@ -80,6 +80,24 @@ const AddDialog = () => {
|
|||||||
[formField]
|
[formField]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const doFetchMunicipios = async (sorting: any) => {
|
||||||
|
try {
|
||||||
|
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||||
|
const response = await GetData(`${API_URL}/municipios/list`, {
|
||||||
|
limit: 100,
|
||||||
|
page: 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: sorting[0].id,
|
||||||
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log(response?.data);
|
||||||
|
setMunicipios(response?.data.list);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching municipios', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -110,25 +128,7 @@ const AddDialog = () => {
|
|||||||
}, [showAddDialog]);
|
}, [showAddDialog]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMunicipios = async (sorting: any) => {
|
doFetchMunicipios([{ id: 'name', desc: false }]);
|
||||||
try {
|
|
||||||
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
|
||||||
const response = await GetData(`${API_URL}/municipios/list`, {
|
|
||||||
limit: 100,
|
|
||||||
page: 1,
|
|
||||||
with_deleted: false,
|
|
||||||
order_field: sorting[0].id,
|
|
||||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.log(response?.data);
|
|
||||||
setMunicipios(response?.data.list);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching municipios', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchMunicipios([{ id: 'name', desc: false }]);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -80,6 +80,41 @@ const EditDialog = () => {
|
|||||||
[selectedPostoAdms, formField]
|
[selectedPostoAdms, formField]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const doFetchMunicipios = useCallback(async (sorting: any) => {
|
||||||
|
try {
|
||||||
|
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||||
|
const response = await GetData(`${API_URL}/municipios/list`, {
|
||||||
|
limit: 100,
|
||||||
|
page: 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: sorting[0].id,
|
||||||
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log('MUNICIPIOS: ', response?.data);
|
||||||
|
setMunicipios(response?.data.list);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching municipios', error);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const doFetchData = useCallback(async (id: string) => {
|
||||||
|
const response = await GetData(`${API_URL}/postoadms/getdata/${id}`, { id });
|
||||||
|
|
||||||
|
if (response?.status) {
|
||||||
|
setFormField((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: response.data.name,
|
||||||
|
municipio_id: response.data.municipios.id
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
setFormField((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: ''
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -93,6 +128,18 @@ const EditDialog = () => {
|
|||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (showEditDialog === false) {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
}, [showEditDialog]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (selectedPostoAdms) {
|
||||||
|
doFetchData(selectedPostoAdms);
|
||||||
|
}
|
||||||
|
}, [selectedPostoAdms]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedPostoAdms) {
|
if (selectedPostoAdms) {
|
||||||
setFormField({
|
setFormField({
|
||||||
@ -104,25 +151,7 @@ const EditDialog = () => {
|
|||||||
}, [formattedTime]);
|
}, [formattedTime]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
doFetchMunicipios([{ id: 'name', desc: false }]);
|
||||||
const fetchMunicipios = async (sorting: any) => {
|
|
||||||
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
|
||||||
const response = await GetData(`${API_URL}/municipios/list`, {
|
|
||||||
limit: 100,
|
|
||||||
page: 1,
|
|
||||||
with_deleted: false,
|
|
||||||
order_field: sorting[0].id,
|
|
||||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.log(response?.data);
|
|
||||||
setMunicipios(response?.data.list);
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchMunicipios([{ id: 'name', desc: false }]);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching municipios', error);
|
|
||||||
}
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// console.log(selectedPostoAdms);
|
// console.log(selectedPostoAdms);
|
||||||
|
|||||||
@ -20,7 +20,7 @@ const API_URL = apiConfig.service_master_data;
|
|||||||
const EditDialog = () => {
|
const EditDialog = () => {
|
||||||
const { showEditDialog, handleEditDialog, selectedProducts } = useManageProductsContext();
|
const { showEditDialog, handleEditDialog, selectedProducts } = useManageProductsContext();
|
||||||
const { reload } = useDataGrid();
|
const { reload } = useDataGrid();
|
||||||
const { PutData } = useCallApi();
|
const { PutData, GetData } = useCallApi();
|
||||||
const parsedUser = getAuth()?.user;
|
const parsedUser = getAuth()?.user;
|
||||||
const created_time = new Date();
|
const created_time = new Date();
|
||||||
const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' ');
|
const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' ');
|
||||||
@ -66,6 +66,25 @@ const EditDialog = () => {
|
|||||||
[selectedProducts, formField]
|
[selectedProducts, formField]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const doFetchData = useCallback(async (id: string) => {
|
||||||
|
const response = await GetData(`${API_URL}/product/getdata/${selectedProducts}`, { id });
|
||||||
|
|
||||||
|
if (response?.status) {
|
||||||
|
setFormField((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: response.data.name,
|
||||||
|
description: response.data.description,
|
||||||
|
price_point: response.data.price_point,
|
||||||
|
price_cash: response.data.price_cash,
|
||||||
|
cashback_point: response.data.cashback_point,
|
||||||
|
cashback_cash: response.data.cashback_cash,
|
||||||
|
status: response.data.status
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
setFormField(initialState);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -89,6 +108,18 @@ const EditDialog = () => {
|
|||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (showEditDialog === false) {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
}, [showEditDialog]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (selectedProducts) {
|
||||||
|
doFetchData(selectedProducts);
|
||||||
|
}
|
||||||
|
}, [selectedProducts]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (showEditDialog) {
|
if (showEditDialog) {
|
||||||
setFormField({
|
setFormField({
|
||||||
|
|||||||
@ -85,11 +85,16 @@ const ManagePositionContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
|
const isActive = row.original.status === 'Y';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EnforceSwitch
|
<span
|
||||||
enforce={row.original.status == 'Y' ? true : false}
|
className={`px-2 py-1 text-xs font-semibold rounded-full ${
|
||||||
onChange={() => {}}
|
isActive ? 'bg-green-100 text-green-600' : 'bg-red-100 text-red-600'
|
||||||
/>
|
}`}
|
||||||
|
>
|
||||||
|
{isActive ? 'Active' : 'Inactive'}
|
||||||
|
</span>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
|
|||||||
@ -127,11 +127,16 @@ const ManageUserContextProvider = ({ children }: { children: React.ReactNode })
|
|||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
|
const isActive = row.original.status === 'Y';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EnforceSwitch
|
<span
|
||||||
enforce={row.original.status == 'Y' ? true : false}
|
className={`px-2 py-1 text-xs font-semibold rounded-full ${
|
||||||
onChange={() => {}}
|
isActive ? 'bg-green-100 text-green-600' : 'bg-red-100 text-red-600'
|
||||||
/>
|
}`}
|
||||||
|
>
|
||||||
|
{isActive ? 'Active' : 'Inactive'}
|
||||||
|
</span>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
|
|||||||
Reference in New Issue
Block a user