fix master area
This commit is contained in:
@ -65,13 +65,13 @@ const DetailMember = ({ showAddDialog, setShowAddDialog, handleSubmit, initialDa
|
|||||||
setNationality(getNationality.data.data)
|
setNationality(getNationality.data.data)
|
||||||
setFormData({ ...formData, [name]: value });
|
setFormData({ ...formData, [name]: value });
|
||||||
} else {
|
} else {
|
||||||
|
if (name === 'municipio_id' || name === 'posto_adms_id' || name === 'suco_id') await getMasterAfter(name, value);
|
||||||
setFormData({ ...formData, [name]: value });
|
setFormData({ ...formData, [name]: value });
|
||||||
if (name === 'municipio' || name === 'posto_adms' || name === 'suco') await getMasterAfter(name, value);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function getMasterAfter(name: string, id: any) {
|
async function getMasterAfter(name: string, id: any) {
|
||||||
if (name === 'municipio') {
|
if (name === 'municipio_id') {
|
||||||
let getMunicipiosPosto = await axios.get(`${BASE_URL_MASTER_DATA}/municipios/postoadms/${id}`, {
|
let getMunicipiosPosto = await axios.get(`${BASE_URL_MASTER_DATA}/municipios/postoadms/${id}`, {
|
||||||
params: {
|
params: {
|
||||||
limit: 50,
|
limit: 50,
|
||||||
@ -83,7 +83,7 @@ const DetailMember = ({ showAddDialog, setShowAddDialog, handleSubmit, initialDa
|
|||||||
});
|
});
|
||||||
setPostoAdm(getMunicipiosPosto.data.data)
|
setPostoAdm(getMunicipiosPosto.data.data)
|
||||||
}
|
}
|
||||||
if (name === 'posto_adms') {
|
if (name === 'posto_adms_id') {
|
||||||
let getPostoSuco = await axios.get(`${BASE_URL_MASTER_DATA}/postoadms/sucos/${id}`, {
|
let getPostoSuco = await axios.get(`${BASE_URL_MASTER_DATA}/postoadms/sucos/${id}`, {
|
||||||
params: {
|
params: {
|
||||||
limit: 50,
|
limit: 50,
|
||||||
@ -95,7 +95,7 @@ const DetailMember = ({ showAddDialog, setShowAddDialog, handleSubmit, initialDa
|
|||||||
});
|
});
|
||||||
setSucos(getPostoSuco.data.data)
|
setSucos(getPostoSuco.data.data)
|
||||||
}
|
}
|
||||||
if (name === 'suco') {
|
if (name === 'suco_id') {
|
||||||
let getSucoAldeias = await axios.get(`${BASE_URL_MASTER_DATA}/sucos/aldeias/${id}`, {
|
let getSucoAldeias = await axios.get(`${BASE_URL_MASTER_DATA}/sucos/aldeias/${id}`, {
|
||||||
params: {
|
params: {
|
||||||
limit: 50,
|
limit: 50,
|
||||||
@ -130,46 +130,21 @@ const DetailMember = ({ showAddDialog, setShowAddDialog, handleSubmit, initialDa
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
setGroups(getGroups.data.data.list);
|
setGroups(getGroups.data.data.list);
|
||||||
// let getMunicipios = await axios.get(`${BASE_URL_MASTER_DATA}/municipios/list`, {
|
|
||||||
// params: {
|
let getMunicipios = await axios.get(`${BASE_URL_MASTER_DATA}/municipios/list`, {
|
||||||
// limit: 50,
|
params: {
|
||||||
// page: 1,
|
limit: 70,
|
||||||
// with_deleted: false,
|
page: 1,
|
||||||
// order_field: 'name',
|
with_deleted: false,
|
||||||
// order_direction: 'ASC',
|
order_field: 'name',
|
||||||
// }
|
order_direction: 'ASC',
|
||||||
// });
|
}
|
||||||
// setMunicipios(getMunicipios.data.data.list)
|
});
|
||||||
// let getPostoAdms = await axios.get(`${BASE_URL_MASTER_DATA}/postoadms/list`, {
|
setMunicipios(getMunicipios.data.data.list)
|
||||||
// params: {
|
if (formData.municipio_id) await handleChange({target: { name: "municipio_id",value: formData.municipio_id }});
|
||||||
// limit: 50,
|
if (formData.posto_adms_id) await handleChange({target: { name: "posto_adms_id",value: formData.posto_adms_id }});
|
||||||
// page: 1,
|
if (formData.suco_id) await handleChange({target: { name: "suco_id",value: formData.suco_id }});
|
||||||
// with_deleted: false,
|
if (formData.aldeia_id) await handleChange({target: { name: "aldeia_id",value: formData.aldeia_id }});
|
||||||
// order_field: 'name',
|
|
||||||
// order_direction: 'ASC',
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// setPostoAdm(getPostoAdms.data.data.list)
|
|
||||||
// let getSucos = await axios.get(`${BASE_URL_MASTER_DATA}/sucos/list`, {
|
|
||||||
// params: {
|
|
||||||
// limit: 50,
|
|
||||||
// page: 1,
|
|
||||||
// with_deleted: false,
|
|
||||||
// order_field: 'name',
|
|
||||||
// order_direction: 'ASC',
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// setSucos(getSucos.data.data.list)
|
|
||||||
// let getAldeias = await axios.get(`${BASE_URL_MASTER_DATA}/aldeias/list`, {
|
|
||||||
// params: {
|
|
||||||
// limit: 50,
|
|
||||||
// page: 1,
|
|
||||||
// with_deleted: false,
|
|
||||||
// order_field: 'name',
|
|
||||||
// order_direction: 'ASC',
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// setAldeias(getAldeias.data.data.list)
|
|
||||||
} catch (error:any) {
|
} catch (error:any) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
toast.error(error.message)
|
toast.error(error.message)
|
||||||
@ -234,10 +209,10 @@ const DetailMember = ({ showAddDialog, setShowAddDialog, handleSubmit, initialDa
|
|||||||
{(formData.id || dialogType === "create") ? generateInput(formData, handleChange, 'Email', 'email', 'text', true, viewOnly): ''}
|
{(formData.id || dialogType === "create") ? generateInput(formData, handleChange, 'Email', 'email', 'text', true, viewOnly): ''}
|
||||||
{/* {generateList(formData, handleChange, status, 'status', 'Status', null, true)} */}
|
{/* {generateList(formData, handleChange, status, 'status', 'Status', null, true)} */}
|
||||||
{(formData.id || dialogType === "create") ? generateList(formData, handleChange, profession, 'profession', 'Profession', false, false): ''}
|
{(formData.id || dialogType === "create") ? generateList(formData, handleChange, profession, 'profession', 'Profession', false, false): ''}
|
||||||
{(formData.id || dialogType === "create") ? generateList(formData, handleChange, municipios, 'municipio', 'Municipio', false, false): ''}
|
{(formData.id || dialogType === "create") ? generateList(formData, handleChange, municipios, 'municipio_id', 'Municipio', false, false): ''}
|
||||||
{(formData.id || dialogType === "create") ? generateList(formData, handleChange, postoAdm, 'posto_adms', 'Posto', false, false): ''}
|
{(formData.id || dialogType === "create") ? generateList(formData, handleChange, postoAdm, 'posto_adms_id', 'Posto', false, false): ''}
|
||||||
{(formData.id || dialogType === "create") ? generateList(formData, handleChange, sucos, 'suco', 'Suco', false, false): ''}
|
{(formData.id || dialogType === "create") ? generateList(formData, handleChange, sucos, 'suco_id', 'Suco', false, false): ''}
|
||||||
{(formData.id || dialogType === "create") ? generateList(formData, handleChange, aldeias, 'aldeia', 'Aldeia', false, false): ''}
|
{(formData.id || dialogType === "create") ? generateList(formData, handleChange, aldeias, 'aldeia_id', 'Aldeia', false, false): ''}
|
||||||
{(formData.id || dialogType === "create") ? generateInput(formData, handleChange, 'Nationality', 'nationality', 'text', true, viewOnly): ''}
|
{(formData.id || dialogType === "create") ? generateInput(formData, handleChange, 'Nationality', 'nationality', 'text', true, viewOnly): ''}
|
||||||
<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"></label>
|
<label className="form-label flex items-center gap-1 max-w-56"></label>
|
||||||
|
|||||||
Reference in New Issue
Block a user