diff --git a/.gitignore b/.gitignore
index 3514e407..65f53dd0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,3 +38,5 @@ storybook-static
# netlify
.netlify
+.aider*
+.env
diff --git a/src/components/pages/employees/EmployeeForm.tsx b/src/components/pages/employees/EmployeeForm.tsx
index d64a0e48..b52e3f15 100644
--- a/src/components/pages/employees/EmployeeForm.tsx
+++ b/src/components/pages/employees/EmployeeForm.tsx
@@ -182,13 +182,11 @@ export const EmployeeForm = (props: Props) => {
showArrow
filterOption={searchFilterOption}
>
- {Object.keys(employeeStatuses)
- .map((key) => ({
- value: key,
- label:
- employeeStatuses[key as keyof typeof employeeStatuses],
- }))
- .map(renderStatusOption)}
+ {Object.values(EmployeeStatus).map((status) => (
+
+ {employeeStatuses[status]}
+
+ ))}
diff --git a/src/components/pages/employees/detail/General.tsx b/src/components/pages/employees/detail/General.tsx
index 0398b893..aae73d95 100644
--- a/src/components/pages/employees/detail/General.tsx
+++ b/src/components/pages/employees/detail/General.tsx
@@ -28,7 +28,7 @@ import {
ViewPosition,
} from 'types/schema'
import { client, GET_PATHS } from 'libs/apis'
-import { ReactElement, useMemo, useState } from 'react'
+import { ReactElement, useRef, useMemo, useState } from 'react'
import {
EmployeeStatus,
employeeStatuses,
@@ -55,6 +55,7 @@ import { AuthenticatedContent } from 'components/common/AuthenticatedContent'
import { TotalResultCount } from 'components/common/Table/TotalResultCount'
import { formatCurrency } from 'utils/currency'
import { DEFAULT_CURRENCY_SYMBOL } from 'constants/currency'
+import { Modal } from 'antd'
import { EditPersonalInfoModal } from './EditPersonalInfoModal'
import { EditSkillsModal } from './EditSkillsModal'
import { EditGeneralInfoModal } from './EditGeneralInfoModal'
@@ -177,11 +178,52 @@ export const General = (props: Props) => {
mutate([GET_PATHS.getEmployees, data.username])
}
+ const isKeepFwdEmailRef = useRef(false)
+
const onChangeStatus = async (value: string) => {
+ if (value === EmployeeStatus.LEFT) {
+ // Reset the checkbox state before opening the modal
+ isKeepFwdEmailRef.current = false
+
+ Modal.confirm({
+ title: 'Confirm Employee Status Change',
+ content: (
+
+
Are you sure you want to change the status to "Left"?
+
+ {
+ isKeepFwdEmailRef.current = e.target.checked
+ }}
+ aria-label="Keep Forward Email"
+ />
+
+
+
+ ),
+ onOk() {
+ return updateEmployeeStatus(value);
+ },
+ okText: 'Confirm',
+ cancelText: 'Cancel',
+ });
+ } else {
+ await updateEmployeeStatus(value)
+ }
+ }
+
+ const updateEmployeeStatus = async (value: string) => {
try {
setIsLoading(true)
- await client.updateEmployeeStatus(data.id || '', value)
+ await client.updateEmployeeStatus(data.id || '', value, isKeepFwdEmailRef.current)
// Refetch user data
notification.success({ message: 'Employee status updated successfully!' })
diff --git a/src/libs/apis.ts b/src/libs/apis.ts
index aa6ccd01..ee70a436 100644
--- a/src/libs/apis.ts
+++ b/src/libs/apis.ts
@@ -216,7 +216,7 @@ class Client {
})
}
- public updateEmployeeStatus(id: string, employeeStatus: string) {
+ public updateEmployeeStatus(id: string, employeeStatus: string, isKeepFwdEmail?: boolean) {
return fetcher>(
`${BASE_URL}/employees/${id}/employee-status`,
{
@@ -224,6 +224,7 @@ class Client {
headers: { ...this.privateHeaders, 'Content-Type': 'application/json' },
body: JSON.stringify({
employeeStatus,
+ isKeepFwdEmail,
}),
},
)