Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM-5572] Bidding Tool Integration (Edit) #2856

Merged
merged 14 commits into from
Jun 12, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
useSelector(state => state.biddingToolFetchDataLoading)) || false;
const deleteErrored = useSelector(state => state.biddingToolDeleteErrored);
const createErrored = useSelector(state => state.biddingToolCreateErrored);
const createSuccess = useSelector(state => state.biddingToolCreateSuccess);
const editErrored = useSelector(state => state.biddingToolEditErrored);
const editLoading = useSelector(state => state.biddingToolEditLoading);

const locations = result?.locations || [];
const statuses = result?.statuses || [];
Expand Down Expand Up @@ -127,7 +130,37 @@
const [values, setValues] = useState(initialValues);
useEffect(() => {
if (editMode) {
setValues(initialValues);
setValues({
location: result?.location,
status: result?.status,
tod: result?.tod,
unaccompanied_status: result?.unaccompanied_status,
housing: result?.housing,
quarters: result?.quarters,
efm_issues: result?.efm_issues,

snd: result?.snd ?? 'N',
hds: result?.hds ?? 'N',
apo_fpo_dpo: result?.apo_fpo_dpo ?? 'N',
consumable_allowance: result?.consumable_allowance ?? 'N',
fm_fp: result?.fm_fp ?? 'N',
inside_efm_employment: result?.inside_efm_employment ?? 'N',
outside_efm_employment: result?.outside_efm_employment ?? 'N',

cola: result?.cola,
differential_rate: result?.differential_rate,
danger_pay: result?.danger_pay,
climate_zone: result?.climate_zone,

rr_point: result?.rr_point ?? '',
medical: result?.medical ?? '',
remarks: result?.remarks ?? '',
quarters_remark: result?.quarters_remark ?? '',
special_ship_allowance: result?.special_ship_allowance ?? '',
school_year: result?.school_year ?? '',
grade_education: result?.grade_education ?? '',
efm_employment: result?.efm_employment ?? '',
});
}
}, [editMode]);

Expand All @@ -139,11 +172,11 @@
{ 'R & R Point': result?.rr_point || 'None Listed' },
{ 'COLA': result?.cola?.toString() || 'None Listed' },
{ 'Differential Rate': result?.differential_rate?.toString() || 'None Listed' },
{ 'Consumable Allowance': result?.consumable_allowance ? 'Yes' : 'No' },
{ 'APO/FPO/DPO': result?.apo_fpo_dpo ? 'Yes' : 'No' },
{ 'Consumable Allowance': result?.consumable_allowance === 'Y' ? 'Yes' : 'No' },
{ 'APO/FPO/DPO': result?.apo_fpo_dpo === 'Y' ? 'Yes' : 'No' },
{ 'Danger Pay': result?.danger_pay?.toString() || 'None Listed' },
{ 'SND': result?.snd ? 'Yes' : 'No' },
{ 'HDS': result?.hds ? 'Yes' : 'No' },
{ 'SND': result?.snd === 'Y' ? 'Yes' : 'No' },
{ 'HDS': result?.hds === 'Y' ? 'Yes' : 'No' },
{ 'Unaccompanied Status': unaccompaniedStatuses.find(o => o.code === result?.unaccompanied_status)?.description || 'None Listed' },
{ 'Housing Type': housingTypes.find(o => o.code === result?.housing_type)?.description || 'None Listed' },
{ 'Quarters': quartersTypes.find(o => o.code === result?.quarters_type)?.description || 'None Listed' },
Expand Down Expand Up @@ -239,15 +272,19 @@
const onSubmit = () => {
if (isCreate) {
dispatch(biddingToolCreate(values));
if (!createErrored) {
history.push(`${rootLocation()}/${values.location}`);
const createdId = createSuccess?.data;
if (!createErrored && createdId) {
history.push(`${rootLocation()}/${createdId}`);
Fixed Show fixed Hide fixed
}
} else {
dispatch(biddingToolEdit({
...values,
updater_id: result?.updater_id,
updated_date: result?.updated_date,
}));
if (!editLoading && !editErrored) {
setEditMode(false);
}
}
};

Expand Down