commit
efaf906f0a
|
|
@ -40,6 +40,8 @@ import {
|
|||
} from '@/api/Admin'
|
||||
import { update, Xdelete } from '@/rtk/helpers/CRUD'
|
||||
import { get, exportFile } from '@/rtk/helpers/apiService'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { RootState } from '@/rtk/store'
|
||||
|
||||
interface User {
|
||||
id: number
|
||||
|
|
@ -95,6 +97,8 @@ interface UserData {
|
|||
// }
|
||||
|
||||
const LeaveManagement = () => {
|
||||
const user = useSelector((state: RootState) => state.authentication)
|
||||
|
||||
const [opened1, { open: open1, close: close1 }] = useDisclosure(false)
|
||||
const [openedDetailOff, { open: openDetailOff, close: closeDetailOff }] =
|
||||
useDisclosure(false)
|
||||
|
|
@ -527,6 +531,14 @@ const LeaveManagement = () => {
|
|||
}}
|
||||
label={'Phép năm'}
|
||||
placeholder="Nhập số ngày phép năm"
|
||||
disabled={
|
||||
!['admin', 'hr'].some((role) =>
|
||||
user.user.user.permission
|
||||
.split(',')
|
||||
.map((p: string) => p.trim())
|
||||
.includes(role),
|
||||
)
|
||||
}
|
||||
/>
|
||||
<TextInput
|
||||
mb={'md'}
|
||||
|
|
@ -554,6 +566,14 @@ const LeaveManagement = () => {
|
|||
}}
|
||||
label={'Phép năm cũ'}
|
||||
placeholder="Nhập số ngày phép năm cũ"
|
||||
disabled={
|
||||
!['admin', 'hr'].some((role) =>
|
||||
user.user.user.permission
|
||||
.split(',')
|
||||
.map((p: string) => p.trim())
|
||||
.includes(role),
|
||||
)
|
||||
}
|
||||
/>
|
||||
<TextInput
|
||||
mb={'md'}
|
||||
|
|
@ -581,6 +601,14 @@ const LeaveManagement = () => {
|
|||
}}
|
||||
label={'Phép đặc biệt'}
|
||||
placeholder="Nhập số ngày phép đặc biệt"
|
||||
disabled={
|
||||
!['admin', 'hr'].some((role) =>
|
||||
user.user.user.permission
|
||||
.split(',')
|
||||
.map((p: string) => p.trim())
|
||||
.includes(role),
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Textarea
|
||||
mb={'md'}
|
||||
|
|
@ -590,8 +618,22 @@ const LeaveManagement = () => {
|
|||
setCustomAddNotes({ ...customAddNotes, note: e.target.value })
|
||||
}}
|
||||
rows={10}
|
||||
disabled={
|
||||
!['admin', 'hr'].some((role) =>
|
||||
user.user.user.permission
|
||||
.split(',')
|
||||
.map((p: string) => p.trim())
|
||||
.includes(role),
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
{['admin', 'hr'].some((role) =>
|
||||
user.user.user.permission
|
||||
.split(',')
|
||||
.map((p: string) => p.trim())
|
||||
.includes(role),
|
||||
) ? (
|
||||
<Button
|
||||
onClick={() => {
|
||||
setDisableBtn(true)
|
||||
|
|
@ -624,6 +666,9 @@ const LeaveManagement = () => {
|
|||
>
|
||||
Save
|
||||
</Button>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</Drawer>
|
||||
|
||||
{/* Filter Year, Export Btn */}
|
||||
|
|
@ -1102,7 +1147,17 @@ const LeaveManagement = () => {
|
|||
<Table.Tr>
|
||||
<Table.Th>Time</Table.Th>
|
||||
<Table.Th>Status</Table.Th>
|
||||
|
||||
{['admin', 'hr'].some((role) =>
|
||||
user.user.user.permission
|
||||
.split(',')
|
||||
.map((p: string) => p.trim())
|
||||
.includes(role),
|
||||
) ? (
|
||||
<Table.Th>Action</Table.Th>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</Table.Tr>
|
||||
</Table.Thead>
|
||||
|
||||
|
|
@ -1129,6 +1184,13 @@ const LeaveManagement = () => {
|
|||
{item.reason_name}
|
||||
</Badge>
|
||||
</Table.Td>
|
||||
|
||||
{['admin', 'hr'].some((role) =>
|
||||
user.user.user.permission
|
||||
.split(',')
|
||||
.map((p: string) => p.trim())
|
||||
.includes(role),
|
||||
) ? (
|
||||
<Table.Td>
|
||||
{item.reason_code === 'ONLEAVE' ? (
|
||||
<IconRefresh
|
||||
|
|
@ -1173,6 +1235,9 @@ const LeaveManagement = () => {
|
|||
height={20}
|
||||
/>
|
||||
</Table.Td>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</Table.Tr>
|
||||
)
|
||||
})}
|
||||
|
|
|
|||
Loading…
Reference in New Issue