|
|
@@ -45,7 +45,6 @@ interface formProps { |
|
|
|
|
|
|
|
|
|
|
|
const EditStaff: React.FC<formProps> = ({ Staff, combos, SalaryEffectiveInfo, InvolvedProject, InfoHistory }) => { |
|
|
|
console.log(combos.position) |
|
|
|
const defaultSkillset = Staff.skillset.map((s: any) => s.skill.id) |
|
|
|
const { t } = useTranslation(); |
|
|
|
const searchParams = useSearchParams() |
|
|
@@ -121,10 +120,10 @@ const EditStaff: React.FC<formProps> = ({ Staff, combos, SalaryEffectiveInfo, In |
|
|
|
const onSubmit = useCallback<SubmitHandler<CreateStaffInputs & { salaryEffectiveInfo: SalaryEffectiveInfo[] } >>( |
|
|
|
async (data) => { |
|
|
|
try { |
|
|
|
console.log(data); |
|
|
|
// console.log(data); |
|
|
|
let haveError = false; |
|
|
|
let regex_email = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/ |
|
|
|
let regex_phone = /^\d{8}$/ |
|
|
|
const regex_email = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/ |
|
|
|
const regex_phone = /^\d{8}$/ |
|
|
|
|
|
|
|
if (!regex_email.test(data.email)) { |
|
|
|
haveError = true |
|
|
@@ -194,9 +193,6 @@ const EditStaff: React.FC<formProps> = ({ Staff, combos, SalaryEffectiveInfo, In |
|
|
|
from: dayjs(item.from).format('YYYY-MM-DD'), |
|
|
|
to: (item.to as string).length != 0 ? dayjs(item.to).format('YYYY-MM-DD') : undefined, |
|
|
|
})) |
|
|
|
console.log(teamHistory) |
|
|
|
console.log(gradeHistory) |
|
|
|
console.log(positionHistory) |
|
|
|
|
|
|
|
const salaryEffectiveInfo = data.salaryEffectiveInfo.map((item: SalaryEffectiveInfo) => ({ |
|
|
|
id: item.id, |
|
|
@@ -208,9 +204,9 @@ const EditStaff: React.FC<formProps> = ({ Staff, combos, SalaryEffectiveInfo, In |
|
|
|
id: id, |
|
|
|
...data, |
|
|
|
salaryEffectiveInfo: salaryEffectiveInfo, |
|
|
|
teamHistory: teamHistory, |
|
|
|
gradeHistory: gradeHistory, |
|
|
|
positionHistory: positionHistory, |
|
|
|
teamHistory: teamHistory ?? [], |
|
|
|
gradeHistory: gradeHistory ?? [], |
|
|
|
positionHistory: positionHistory ?? [], |
|
|
|
delTeamHistory: data.delTeamHistory ? data.delTeamHistory : [], |
|
|
|
delGradeHistory: data.delGradeHistory ? data.delGradeHistory : [], |
|
|
|
delPositionHistory: data.delPositionHistory ? data.delPositionHistory : [], |
|
|
@@ -223,7 +219,6 @@ const EditStaff: React.FC<formProps> = ({ Staff, combos, SalaryEffectiveInfo, In |
|
|
|
} |
|
|
|
console.log(postData) |
|
|
|
await saveStaff(postData) |
|
|
|
return |
|
|
|
router.replace("/settings/staff") |
|
|
|
} catch (e: any) { |
|
|
|
console.log(e); |
|
|
|