|
|
@@ -48,8 +48,7 @@ interface formProps { |
|
|
|
|
|
|
|
|
|
|
|
const EditStaff: React.FC<formProps> = ({ Staff, combos, SalaryEffectiveInfo }) => { |
|
|
|
console.log(combos.salary) |
|
|
|
console.log(SalaryEffectiveInfo) |
|
|
|
console.log(Staff) |
|
|
|
const defaultSkillset = Staff.skillset.map((s: any) => s.skill.id) |
|
|
|
const { t } = useTranslation(); |
|
|
|
const searchParams = useSearchParams() |
|
|
@@ -73,7 +72,7 @@ const EditStaff: React.FC<formProps> = ({ Staff, combos, SalaryEffectiveInfo }) |
|
|
|
emergContactName: Staff.emergContactName, |
|
|
|
emergContactPhone: Staff.emergContactPhone, |
|
|
|
joinDate: dayjs(Staff.joinDate).toString() || "", |
|
|
|
joinPositionId: Staff.joinPosition?.id, |
|
|
|
joinPositionId: Staff.joinPosition?.id || null, |
|
|
|
departDate: dayjs(Staff.departDate).toString() || "", |
|
|
|
departReason: Staff.departReason, |
|
|
|
remark: Staff.remark, |
|
|
@@ -152,15 +151,23 @@ const EditStaff: React.FC<formProps> = ({ Staff, combos, SalaryEffectiveInfo }) |
|
|
|
return |
|
|
|
} |
|
|
|
console.log("passed") |
|
|
|
const postData = { |
|
|
|
const postData: CreateStaffInputs = { |
|
|
|
id: id, |
|
|
|
...data, |
|
|
|
salaryEffectiveInfo: SalaryEffectiveInfo.map(item => ({ |
|
|
|
id: item.id, |
|
|
|
salaryPoint: item.salaryPoint, |
|
|
|
date: dayjs(item.date).format('YYYY-MM-DD') |
|
|
|
date: dayjs(item.date).format('YYYY-MM-DD').toString() |
|
|
|
})) |
|
|
|
} |
|
|
|
// remove useless data |
|
|
|
if (postData.joinDate === 'Invalid Date') |
|
|
|
postData.joinDate = null |
|
|
|
if (postData.departDate === 'Invalid Date') |
|
|
|
postData.departDate = null |
|
|
|
if (!postData.joinPositionId) |
|
|
|
postData.joinPositionId = null |
|
|
|
|
|
|
|
console.log(postData) |
|
|
|
await saveStaff(postData) |
|
|
|
router.replace("/settings/staff") |
|
|
|