Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
anawork-mobile-v2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dungtnguyen
anawork-mobile-v2
Commits
42a00560
Commit
42a00560
authored
Oct 08, 2024
by
quynhquang400@gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix request leave
parent
ca8fc7a4
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
190 additions
and
135 deletions
+190
-135
index.js
src/components/Select/index.js
+2
-0
TextInputComponent.js
src/components/TextInputComponent.js
+1
-2
onLeaveApi.js
src/network/api/onLeaveApi.js
+3
-1
ConfirmDateContainer.js
src/screens/confirm_date/ConfirmDateContainer.js
+1
-11
ConfirmMainView.js
src/screens/confirm_date/template/ConfirmMainView.js
+0
-3
OnLeaveContainer.js
src/screens/onleave/OnLeaveContainer.js
+67
-47
onLeavePropsProvider.js
src/screens/onleave/onLeavePropsProvider.js
+6
-3
onLeaveSlice.js
src/screens/onleave/onLeaveSlice.js
+14
-1
style.js
src/screens/onleave/style.js
+1
-1
OnLeaveMainView.js
src/screens/onleave/template/OnLeaveMainView.js
+6
-6
RequestLeavesDays.js
src/screens/onleave/template/subViews/RequestLeavesDays.js
+89
-60
No files found.
src/components/Select/index.js
View file @
42a00560
...
@@ -22,6 +22,7 @@ const SelectDropdownComponent = ({
...
@@ -22,6 +22,7 @@ const SelectDropdownComponent = ({
setValue
,
setValue
,
width
,
width
,
height
,
height
,
disable
=
false
,
})
=>
{
})
=>
{
// const [value, setValue] = useState(null);
// const [value, setValue] = useState(null);
const
[
isFocus
,
setIsFocus
]
=
useState
(
false
);
const
[
isFocus
,
setIsFocus
]
=
useState
(
false
);
...
@@ -29,6 +30,7 @@ const SelectDropdownComponent = ({
...
@@ -29,6 +30,7 @@ const SelectDropdownComponent = ({
return
(
return
(
<
View
style
=
{
styles
.
container
}
>
<
View
style
=
{
styles
.
container
}
>
<
Dropdown
<
Dropdown
disable
=
{
disable
}
style
=
{[
style
=
{[
styles
.
dropdown
,
styles
.
dropdown
,
{
width
:
width
??
100
,
height
:
height
??
40
},
{
width
:
width
??
100
,
height
:
height
??
40
},
...
...
src/components/TextInputComponent.js
View file @
42a00560
...
@@ -36,7 +36,6 @@ const TextInputComponent = ({
...
@@ -36,7 +36,6 @@ const TextInputComponent = ({
noBorder
,
noBorder
,
autoCompleteType
,
autoCompleteType
,
borderColor
,
borderColor
,
type
,
})
=>
{
})
=>
{
return
(
return
(
<
View
style
=
{
stylesTextInput
.
container
}
>
<
View
style
=
{
stylesTextInput
.
container
}
>
...
@@ -78,7 +77,7 @@ const TextInputComponent = ({
...
@@ -78,7 +77,7 @@ const TextInputComponent = ({
secureTextEntry
=
{
secureTextEntry
}
secureTextEntry
=
{
secureTextEntry
}
maxLength
=
{
maxLength
}
maxLength
=
{
maxLength
}
onFocus
=
{
onFocus
}
onFocus
=
{
onFocus
}
editable
=
{
!
disable
}
editable
=
{
disable
}
autoComplete
=
{
autoCompleteType
}
autoComplete
=
{
autoCompleteType
}
/
>
/
>
{
rightIcon
&&
(
{
rightIcon
&&
(
...
...
src/network/api/onLeaveApi.js
View file @
42a00560
...
@@ -11,5 +11,7 @@ export default {
...
@@ -11,5 +11,7 @@ export default {
),
),
requestGetLeaveCategory
:
()
=>
axiosClient
.
get
(
'leaveCategories'
),
requestGetLeaveCategory
:
()
=>
axiosClient
.
get
(
'leaveCategories'
),
requestGetDirectManagers
:
()
=>
axiosClient
.
get
(
'myDirectManagers'
),
requestGetDirectManagers
:
()
=>
axiosClient
.
get
(
'myDirectManagers'
),
requestPostLeaveRequest
:
(
payload
)
=>
axiosClient
.
post
(
'leaveDays'
,
payload
),
requestPostLeaveRequest
:
payload
=>
axiosClient
.
post
(
'leaveDays'
,
payload
),
requestPostApproveLeaveRequest
:
({
id
})
=>
axiosClient
.
post
(
`leaveDays/
${
id
}
/approve?comment=`
),
};
};
src/screens/confirm_date/ConfirmDateContainer.js
View file @
42a00560
...
@@ -50,17 +50,7 @@ const ConfirmDateContainer = props => {
...
@@ -50,17 +50,7 @@ const ConfirmDateContainer = props => {
const
[
dayPress
,
setDayPress
]
=
useState
();
const
[
dayPress
,
setDayPress
]
=
useState
();
// open the modal
// open the modal
const
onOpenDetailModal
=
detailItem
=>
{
const
onOpenDetailModal
=
detailItem
=>
{};
setModalContent
(
<
ConfirmModalDetails
onClose
=
{
onCloseModal
}
alertMessage
=
{
alertMessage
}
userDetails
=
{
userInfo
}
detailItem
=
{
detailItem
}
setApproveReqPayload
=
{
setApproveReqPayload
}
/>
,
);
};
const
onOpenAddModal
=
()
=>
{
const
onOpenAddModal
=
()
=>
{
setModalContent
(
setModalContent
(
...
...
src/screens/confirm_date/template/ConfirmMainView.js
View file @
42a00560
...
@@ -36,9 +36,6 @@ const ConfirmDateMainView = ({
...
@@ -36,9 +36,6 @@ const ConfirmDateMainView = ({
onOpenRequestLeavesModal
,
onOpenRequestLeavesModal
,
approveReqPayload
,
approveReqPayload
,
onChangeSelectFilter
,
onChangeSelectFilter
,
onChangeMonthFilter
,
dayPress
,
onChangeDayPressInChart
,
minutesToHours
,
minutesToHours
,
})
=>
{
})
=>
{
const
typeChartColor
=
[
const
typeChartColor
=
[
...
...
src/screens/onleave/OnLeaveContainer.js
View file @
42a00560
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable react-hooks/exhaustive-deps */
import
Moment
from
'moment'
;
import
Moment
from
'moment'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
use
Callback
,
use
Effect
,
useState
}
from
'react'
;
import
{
useDispatch
}
from
'react-redux'
;
import
{
useDispatch
}
from
'react-redux'
;
import
RootNavigation
from
'../../navigation/RootNavigation'
;
import
RootNavigation
from
'../../navigation/RootNavigation'
;
import
{
import
{
...
@@ -20,6 +20,7 @@ import {
...
@@ -20,6 +20,7 @@ import {
getDirectManagers
,
getDirectManagers
,
handleSelectManagersLeaveRequest
,
handleSelectManagersLeaveRequest
,
postLeaveRequest
,
postLeaveRequest
,
postSubmitApproveLeaveRequest
,
}
from
'./onLeaveSlice'
;
}
from
'./onLeaveSlice'
;
import
OnLeaveMainView
from
'./template/OnLeaveMainView'
;
import
OnLeaveMainView
from
'./template/OnLeaveMainView'
;
import
onLeavePropsProvider
from
'./onLeavePropsProvider'
;
import
onLeavePropsProvider
from
'./onLeavePropsProvider'
;
...
@@ -57,23 +58,16 @@ const OnLeaveContainer = props => {
...
@@ -57,23 +58,16 @@ const OnLeaveContainer = props => {
const
[
leaveRequestList
,
setLeaveRequestList
]
=
useState
([]);
const
[
leaveRequestList
,
setLeaveRequestList
]
=
useState
([]);
const
[
showAlert
,
setShowAlert
]
=
useState
({
isError
:
false
,
title
:
''
,
message
:
''
,
});
const
[
totalArr
,
setTotalArr
]
=
useState
({
totalApproveReqLeaves
:
0
,
totalLeaveList
:
0
,
});
const
[
isDisableLoadMore
,
setDisableLoadMore
]
=
useState
({
const
[
isDisableLoadMore
,
setDisableLoadMore
]
=
useState
({
approveReqBtn
:
false
,
approveReqBtn
:
false
,
leaveBtn
:
false
,
leaveBtn
:
false
,
});
});
const
[
modalContent
,
setModalContent
]
=
useState
(
null
);
const
[
leavesDaysModal
,
setLeavesDaysModal
]
=
useState
({
const
[
leavesDaysModal
,
setLeavesDaysModal
]
=
useState
(
null
);
visible
:
false
,
userInfo
:
null
,
isRequest
:
false
,
});
const
[
openTimePicker
,
setOpenTimePicker
]
=
useState
({
const
[
openTimePicker
,
setOpenTimePicker
]
=
useState
({
startDate
:
false
,
startDate
:
false
,
...
@@ -94,24 +88,46 @@ const OnLeaveContainer = props => {
...
@@ -94,24 +88,46 @@ const OnLeaveContainer = props => {
reason
:
''
,
reason
:
''
,
});
});
// open the modal
// open the modal
const
onOpenDetailModal
=
detailItem
=>
{
const
onOpenDetailModal
=
useCallback
(
setModalContent
(
detail
=>
{
<
OnLeaveModalDetail
if
(
detail
)
{
onClose
=
{
onCloseModal
}
const
user
=
{
alertMessage
=
{
alertMessage
}
id
:
detail
?.
staff_id
,
userInfo
=
{
userInfo
}
avatar
:
detail
?.
extend_creator_avatar
,
detailItem
=
{
detailItem
}
full_name
:
detail
?.
extend_creator_full_name
,
setPayloadApproveLeaves
=
{
setPayloadApproveRequestLeavesDays
}
employee_code
:
detail
?.
extend_creator_employee_code
,
/>
,
position
:
detail
?.
extend_creator_position
,
);
isApprover
:
detail
?.
approver_id
===
userInfo
?.
id
,
};
leave_id
:
detail
?.
id
,
};
setLeaveRequestTicket
({
leaveCategory
:
detail
?.
extend_category_name
,
reason
:
detail
?.
reason
,
});
setLeavesDaysModal
({
visible
:
true
,
userInfo
:
user
,
isRequest
:
false
,
});
}
},
[
userInfo
],
);
const
onOpenRequestLeavesModal
=
()
=>
{
const
onOpenRequestLeavesModal
=
userDetails
=>
{
setLeavesDaysModal
(
true
);
setLeavesDaysModal
({
visible
:
true
,
userInfo
:
userInfo
,
isRequest
:
true
,
});
};
};
const
onCloseModal
=
()
=>
{
const
onCloseModal
=
()
=>
{
setLeavesDaysModal
(
null
);
setLeavesDaysModal
({
visible
:
false
,
userInfo
:
null
,
isRequest
:
false
,
});
};
};
const
formatDataChart
=
()
=>
{
const
formatDataChart
=
()
=>
{
// console.log('userRestDays', userRestDays);
// console.log('userRestDays', userRestDays);
...
@@ -136,21 +152,6 @@ const OnLeaveContainer = props => {
...
@@ -136,21 +152,6 @@ const OnLeaveContainer = props => {
RootNavigation
.
navigate
(
APP_NAVIGATE_SCREEN
.
OVERTIME
);
RootNavigation
.
navigate
(
APP_NAVIGATE_SCREEN
.
OVERTIME
);
};
};
const
alertMessage
=
message
=>
{
setShowAlert
({
isError
:
true
,
title
:
'Thông báo'
,
message
:
`
${
message
}
👍`
,
});
};
const
onHideAlert
=
()
=>
{
setShowAlert
({
isError
:
false
,
title
:
''
,
message
:
''
,
});
};
const
onLoadMoreLeavesTicket
=
()
=>
{
const
onLoadMoreLeavesTicket
=
()
=>
{
setPayloadLeaves
(
prev
=>
({
setPayloadLeaves
(
prev
=>
({
...
prev
,
...
prev
,
...
@@ -391,6 +392,29 @@ const OnLeaveContainer = props => {
...
@@ -391,6 +392,29 @@ const OnLeaveContainer = props => {
const
onSelectManagerLeaveRequest
=
(
index
,
value
)
=>
{
const
onSelectManagerLeaveRequest
=
(
index
,
value
)
=>
{
dispatch
(
handleSelectManagersLeaveRequest
({
index
,
value
}));
dispatch
(
handleSelectManagersLeaveRequest
({
index
,
value
}));
};
};
const
onSubmitApproveLeaveRequest
=
leave_id
=>
{
try
{
dispatch
(
postSubmitApproveLeaveRequest
({
id
:
leave_id
})).
then
(
response
=>
{
const
{
success
}
=
Utils
.
getValues
(
response
,
'payload'
,
false
);
if
(
success
)
{
fetchApproveRequestLeavesDays
();
onCloseModal
();
}
ToastMessage
({
title
:
'Hệ thống'
,
message
:
`Duyệt nghỉ phép
${
success
?
'thành công'
:
'thất bại'
}
`
,
type
:
success
?
'success'
:
'error'
,
});
});
}
catch
(
err
)
{
ToastMessage
({
title
:
'Hệ thống'
,
message
:
'Đã có lỗi xảy ra !!!'
,
type
:
'error'
,
});
}
};
// useEffect
// useEffect
useEffect
(()
=>
{
useEffect
(()
=>
{
usersLeavesDayList
&&
formatLeaveLstFromApi
();
usersLeavesDayList
&&
formatLeaveLstFromApi
();
...
@@ -427,11 +451,8 @@ const OnLeaveContainer = props => {
...
@@ -427,11 +451,8 @@ const OnLeaveContainer = props => {
usersLeavesDayList
,
usersLeavesDayList
,
userInfo
,
userInfo
,
dataChart
,
dataChart
,
showAlert
,
totalArr
,
isDisableLoadMore
,
isDisableLoadMore
,
leaveRequestList
,
leaveRequestList
,
modalContent
,
payloadApproveRequestLeavesDays
,
payloadApproveRequestLeavesDays
,
approveRequestLeavesDaysList
,
approveRequestLeavesDaysList
,
leavesDaysModal
,
leavesDaysModal
,
...
@@ -452,8 +473,6 @@ const OnLeaveContainer = props => {
...
@@ -452,8 +473,6 @@ const OnLeaveContainer = props => {
onRefreshLeaveApproveReqList
,
onRefreshLeaveApproveReqList
,
navigateToConfirmDate
,
navigateToConfirmDate
,
navigateToOverTime
,
navigateToOverTime
,
alertMessage
,
onHideAlert
,
onLoadMoreLeavesTicket
,
onLoadMoreLeavesTicket
,
onOpenDetailModal
,
onOpenDetailModal
,
onOpenRequestLeavesModal
,
onOpenRequestLeavesModal
,
...
@@ -462,6 +481,7 @@ const OnLeaveContainer = props => {
...
@@ -462,6 +481,7 @@ const OnLeaveContainer = props => {
minutesToHours
,
minutesToHours
,
onSubmitLeaveRequest
,
onSubmitLeaveRequest
,
onSelectManagerLeaveRequest
,
onSelectManagerLeaveRequest
,
onSubmitApproveLeaveRequest
,
};
};
return
<
OnLeaveMainView
{...
onLeavePropsProvider
(
leaveProps
)}
/>
;
return
<
OnLeaveMainView
{...
onLeavePropsProvider
(
leaveProps
)}
/>
;
};
};
...
...
src/screens/onleave/onLeavePropsProvider.js
View file @
42a00560
...
@@ -37,7 +37,8 @@ export default function onLeavePropsProvider(props) {
...
@@ -37,7 +37,8 @@ export default function onLeavePropsProvider(props) {
leaveRequestTicket
,
leaveRequestTicket
,
setLeaveRequestTicket
,
setLeaveRequestTicket
,
onSubmitLeaveRequest
,
onSubmitLeaveRequest
,
onSelectManagerLeaveRequest
onSelectManagerLeaveRequest
,
onSubmitApproveLeaveRequest
,
}
=
props
;
}
=
props
;
return
{
return
{
leavesDaysModal
,
leavesDaysModal
,
...
@@ -74,7 +75,7 @@ export default function onLeavePropsProvider(props) {
...
@@ -74,7 +75,7 @@ export default function onLeavePropsProvider(props) {
},
},
leaveRequestModalProps
:
{
leaveRequestModalProps
:
{
leaveCategory
,
leaveCategory
,
userInfo
,
userInfo
:
leavesDaysModal
.
userInfo
||
userInfo
,
onCloseModal
,
onCloseModal
,
directManagersList
,
directManagersList
,
openTimePicker
,
openTimePicker
,
...
@@ -87,7 +88,9 @@ export default function onLeavePropsProvider(props) {
...
@@ -87,7 +88,9 @@ export default function onLeavePropsProvider(props) {
leaveRequestTicket
,
leaveRequestTicket
,
setLeaveRequestTicket
,
setLeaveRequestTicket
,
onSubmitLeaveRequest
,
onSubmitLeaveRequest
,
onSelectManagerLeaveRequest
onSelectManagerLeaveRequest
,
isRequest
:
leavesDaysModal
.
isRequest
,
onSubmitApproveLeaveRequest
,
},
},
};
};
}
}
src/screens/onleave/onLeaveSlice.js
View file @
42a00560
...
@@ -87,6 +87,19 @@ export const postLeaveRequest = createAsyncThunk(
...
@@ -87,6 +87,19 @@ export const postLeaveRequest = createAsyncThunk(
});
});
},
},
);
);
export
const
postSubmitApproveLeaveRequest
=
createAsyncThunk
(
'onLeave/postSubmitApproveLeaveRequest'
,
async
(
data
,
thunkAPI
)
=>
{
return
serviceRequest
({
dispatch
:
thunkAPI
.
dispatch
,
serviceMethod
:
onLeaveApi
.
requestPostApproveLeaveRequest
,
payload
:
data
,
options
:
{
skipLoader
:
false
,
},
});
},
);
const
onLeaveSlice
=
createSlice
({
const
onLeaveSlice
=
createSlice
({
name
:
'onLeave'
,
name
:
'onLeave'
,
initialState
:
initialHome
,
initialState
:
initialHome
,
...
@@ -96,7 +109,7 @@ const onLeaveSlice = createSlice({
...
@@ -96,7 +109,7 @@ const onLeaveSlice = createSlice({
let
managers
=
JSON
.
parse
(
JSON
.
stringify
(
state
.
directManagersList
));
let
managers
=
JSON
.
parse
(
JSON
.
stringify
(
state
.
directManagersList
));
if
(
managers
.
length
>
0
)
{
if
(
managers
.
length
>
0
)
{
managers
[
index
].
isChecked
=
value
;
managers
[
index
].
isChecked
=
value
;
state
.
directManagersList
=
[...
managers
]
state
.
directManagersList
=
[...
managers
];
}
}
},
},
},
},
...
...
src/screens/onleave/style.js
View file @
42a00560
...
@@ -470,7 +470,7 @@ export const leavesModalStyles = StyleSheet.create({
...
@@ -470,7 +470,7 @@ export const leavesModalStyles = StyleSheet.create({
alignItems
:
'center'
,
alignItems
:
'center'
,
height
:
40
,
height
:
40
,
borderRadius
:
8
,
borderRadius
:
8
,
width
:
10
0
,
paddingHorizontal
:
1
0
,
},
},
btnCancel
:
{
btnCancel
:
{
backgroundColor
:
colors
.
white
,
backgroundColor
:
colors
.
white
,
...
...
src/screens/onleave/template/OnLeaveMainView.js
View file @
42a00560
...
@@ -121,12 +121,12 @@ const AddNewLeavesSection = React.memo(props => {
...
@@ -121,12 +121,12 @@ const AddNewLeavesSection = React.memo(props => {
<
Image
source
=
{
IMAGES
.
IcTask
}
style
=
{
styles
.
iconPlus
}
/
>
<
Image
source
=
{
IMAGES
.
IcTask
}
style
=
{
styles
.
iconPlus
}
/
>
<
AppText
style
=
{
styles
.
primary_blue
}
>
X
á
c
nh
ậ
n
ng
à
y
c
ô
ng
<
/AppText
>
<
AppText
style
=
{
styles
.
primary_blue
}
>
X
á
c
nh
ậ
n
ng
à
y
c
ô
ng
<
/AppText
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
TouchableOpacity
{
/*
<TouchableOpacity
onPress={navigateToOverTime}
onPress={navigateToOverTime}
style={{flexDirection: 'row', marginTop: 5}}>
style={{flexDirection: 'row', marginTop: 5}}>
<Image source={IMAGES.IcBackTime} style={styles.iconPlus} />
<Image source={IMAGES.IcBackTime} style={styles.iconPlus} />
<AppText style={styles.primary_blue}>Tăng ca của tôi</AppText>
<AppText style={styles.primary_blue}>Tăng ca của tôi</AppText>
<
/TouchableOpacity
>
</TouchableOpacity>
*/
}
<
/View
>
<
/View
>
);
);
});
});
...
@@ -262,7 +262,7 @@ const LeavesRequest = React.memo(
...
@@ -262,7 +262,7 @@ const LeavesRequest = React.memo(
{leaveRequestList &&
{leaveRequestList &&
leaveRequestList.map((item, index) => (
leaveRequestList.map((item, index) => (
<TouchableOpacity
<TouchableOpacity
onPress={() => onOpenDetailModal(item)}
onPress={() => onOpenDetailModal(item
, true
)}
key={index}>
key={index}>
<View
<View
style={[
style={[
...
@@ -306,7 +306,6 @@ const LeavesRequest = React.memo(
...
@@ -306,7 +306,6 @@ const LeavesRequest = React.memo(
);
);
const OnLeaveMainView = ({
const OnLeaveMainView = ({
userInfo,
navigateToConfirmDate,
navigateToConfirmDate,
navigateToOverTime,
navigateToOverTime,
dataChart,
dataChart,
...
@@ -315,7 +314,6 @@ const OnLeaveMainView = ({
...
@@ -315,7 +314,6 @@ const OnLeaveMainView = ({
onOpenRequestLeavesModal,
onOpenRequestLeavesModal,
approveRequestLeavesDaysProps,
approveRequestLeavesDaysProps,
leaveRequestList,
leaveRequestList,
onCloseModal,
leavesDaysModal,
leavesDaysModal,
leaveRequestModalProps,
leaveRequestModalProps,
}) => {
}) => {
...
@@ -337,7 +335,9 @@ const OnLeaveMainView = ({
...
@@ -337,7 +335,9 @@ const OnLeaveMainView = ({
onOpenDetailModal={onOpenDetailModal}
onOpenDetailModal={onOpenDetailModal}
/>
/>
</ScrollView>
</ScrollView>
{leavesDaysModal && <RequestLeavesDays {...leaveRequestModalProps} />}
{leavesDaysModal?.visible && (
<RequestLeavesDays {...leaveRequestModalProps} />
)}
</SafeAreaView>
</SafeAreaView>
);
);
};
};
...
...
src/screens/onleave/template/subViews/RequestLeavesDays.js
View file @
42a00560
...
@@ -24,7 +24,7 @@ const RequestLeavesDays = props => {
...
@@ -24,7 +24,7 @@ const RequestLeavesDays = props => {
userInfo
,
userInfo
,
onCloseModal
,
onCloseModal
,
leaveCategory
,
leaveCategory
,
directManagersList
,
directManagersList
=
[]
,
openTimePicker
,
openTimePicker
,
setOpenTimePicker
,
setOpenTimePicker
,
timeRequestLeave
,
timeRequestLeave
,
...
@@ -36,8 +36,9 @@ const RequestLeavesDays = props => {
...
@@ -36,8 +36,9 @@ const RequestLeavesDays = props => {
setLeaveRequestTicket
,
setLeaveRequestTicket
,
onSubmitLeaveRequest
,
onSubmitLeaveRequest
,
onSelectManagerLeaveRequest
,
onSelectManagerLeaveRequest
,
isRequest
=
false
,
onSubmitApproveLeaveRequest
,
}
=
props
;
}
=
props
;
const
formatLeaveCategory
=
useMemo
(()
=>
{
const
formatLeaveCategory
=
useMemo
(()
=>
{
leaveCategory
.
map
(
item
=>
{
leaveCategory
.
map
(
item
=>
{
return
{
label
:
item
.
name
,
value
:
item
.
name
};
return
{
label
:
item
.
name
,
value
:
item
.
name
};
...
@@ -49,6 +50,14 @@ const RequestLeavesDays = props => {
...
@@ -49,6 +50,14 @@ const RequestLeavesDays = props => {
:
[];
:
[];
},
[
leaveCategory
]);
},
[
leaveCategory
]);
const
fullName
=
useMemo
(()
=>
{
return
userInfo
?.
full_name
?
userInfo
?.
full_name
:
`
${
userInfo
?.
first_name
}
$
{
userInfo
?.
middle_name
?
userInfo
?.
middle_name
:
''
}
$
{
userInfo
?.
last_name
}
`;
}, [userInfo]);
return (
return (
<Modal
<Modal
animationType="slide"
animationType="slide"
...
@@ -74,11 +83,10 @@ const RequestLeavesDays = props => {
...
@@ -74,11 +83,10 @@ const RequestLeavesDays = props => {
style={leavesModalStyles.ImgAvatar}
style={leavesModalStyles.ImgAvatar}
/>
/>
<View style={{marginLeft: 15}}>
<View style={{marginLeft: 15}}>
<
AppText
style
=
{
leavesModalStyles
.
modalTitle
}
>
{
`
${
<AppText
userInfo
?.
first_name
style={
}
$
{
userInfo
?.
middle_name
?
userInfo
?.
middle_name
:
''
}
$
{
leavesModalStyles.modalTitle
userInfo
?.
last_name
}>{`
$
{
fullName
}
-
$
{
userInfo
?.
employee_code
}
`}</AppText>
}
-
$
{
userInfo
?.
employee_code
}
`}</AppText>
<AppText>{userInfo?.position}</AppText>
<AppText>{userInfo?.position}</AppText>
</View>
</View>
</View>
</View>
...
@@ -89,6 +97,7 @@ const RequestLeavesDays = props => {
...
@@ -89,6 +97,7 @@ const RequestLeavesDays = props => {
<View style={leavesModalStyles.rowView}>
<View style={leavesModalStyles.rowView}>
<AppText>Loại nghỉ phép</AppText>
<AppText>Loại nghỉ phép</AppText>
<SelectDropdownComponent
<SelectDropdownComponent
disable={!isRequest}
selectData={formatLeaveCategory}
selectData={formatLeaveCategory}
setValue={value =>
setValue={value =>
setLeaveRequestTicket(prev => ({
setLeaveRequestTicket(prev => ({
...
@@ -104,6 +113,7 @@ const RequestLeavesDays = props => {
...
@@ -104,6 +113,7 @@ const RequestLeavesDays = props => {
<AppText>Từ ngày</AppText>
<AppText>Từ ngày</AppText>
<View>
<View>
<TouchableOpacity
<TouchableOpacity
disabled={!isRequest}
onPress={() =>
onPress={() =>
setOpenTimePicker(state => ({
setOpenTimePicker(state => ({
...state,
...state,
...
@@ -143,6 +153,7 @@ const RequestLeavesDays = props => {
...
@@ -143,6 +153,7 @@ const RequestLeavesDays = props => {
<AppText>Giờ</AppText>
<AppText>Giờ</AppText>
<View>
<View>
<TouchableOpacity
<TouchableOpacity
disabled={!isRequest}
onPress={() =>
onPress={() =>
setOpenTimePicker(state => ({
setOpenTimePicker(state => ({
...state,
...state,
...
@@ -182,6 +193,7 @@ const RequestLeavesDays = props => {
...
@@ -182,6 +193,7 @@ const RequestLeavesDays = props => {
<AppText>Đến ngày</AppText>
<AppText>Đến ngày</AppText>
<View>
<View>
<TouchableOpacity
<TouchableOpacity
disabled={!isRequest}
onPress={() =>
onPress={() =>
setOpenTimePicker(state => ({
setOpenTimePicker(state => ({
...state,
...state,
...
@@ -221,6 +233,7 @@ const RequestLeavesDays = props => {
...
@@ -221,6 +233,7 @@ const RequestLeavesDays = props => {
<AppText>Giờ</AppText>
<AppText>Giờ</AppText>
<View>
<View>
<TouchableOpacity
<TouchableOpacity
disabled={!isRequest}
onPress={() =>
onPress={() =>
setOpenTimePicker(state => ({
setOpenTimePicker(state => ({
...state,
...state,
...
@@ -272,6 +285,7 @@ const RequestLeavesDays = props => {
...
@@ -272,6 +285,7 @@ const RequestLeavesDays = props => {
}}>{`
L
ý
do
(
*
)
`}</AppText>
}}>{`
L
ý
do
(
*
)
`}</AppText>
<View>
<View>
<TextInputComponent
<TextInputComponent
disable={isRequest}
styleAreaInput={leavesModalStyles.inputText}
styleAreaInput={leavesModalStyles.inputText}
value={leaveRequestTicket.reason}
value={leaveRequestTicket.reason}
placeholder="Nhập lý do tại đây"
placeholder="Nhập lý do tại đây"
...
@@ -315,76 +329,91 @@ const RequestLeavesDays = props => {
...
@@ -315,76 +329,91 @@ const RequestLeavesDays = props => {
)}
)}
</View>
</View>
</View>
</View>
<View style={{marginTop: 10}}>
{isRequest && directManagersList.length > 0 && (
<AppText
<View style={{marginTop: 10}}>
style={[
<AppText
leavesModalStyles.modalTitle,
style={[
{
leavesModalStyles.modalTitle,
marginBottom: 10,
{
},
marginBottom: 10,
]}>
},
Người duyệt
]}>
</AppText>
Người duyệt
{directManagersList.map((item, index) => (
</AppText>
<View
{directManagersList.map((item, index) => (
key={index}
style={{
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginTop: 4,
}}>
<View
<View
key={index}
style={{
style={{
flexDirection: 'row',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
alignItems: 'center',
paddingLeft: 18
,
marginTop: 4
,
}}>
}}>
<Image
<View
source={{
uri: config.imageEndPoint + item.avatar,
}}
style={leavesModalStyles.avatarApprove}
/>
<AppText
style={{
style={{
marginLeft: 10,
flexDirection: 'row',
}}>{`
$
{
item
.
extend_user_full_name
}
`}</AppText>
alignItems: 'center',
</View>
paddingLeft: 18,
<View style={{paddingRight: 10}}>
}}>
<CheckBox
<Image
disabled={false}
source={{
value={item.isChecked}
uri: config.imageEndPoint + item.avatar,
onValueChange={newValue =>
}}
onSelectManagerLeaveRequest(index, newValue)
style={leavesModalStyles.avatarApprove}
}
/>
boxType={'square'}
<AppText
animationDuration={0.3}
style={{
lineWidth={1}
marginLeft: 10,
key={index}
}}>{`
$
{
item
.
extend_user_full_name
}
`}</AppText>
tintColors={'#9E663C'}
</View>
/>
<View style={{paddingRight: 10}}>
<CheckBox
disabled={false}
value={item.isChecked}
onValueChange={newValue =>
onSelectManagerLeaveRequest(index, newValue)
}
boxType={'square'}
animationDuration={0.3}
lineWidth={1}
key={index}
tintColors={'#9E663C'}
/>
</View>
</View>
</View>
</View>
))}
))}
</View>
</View>
)}
</View>
</View>
<View
<View
style={{
style={{
flexDirection: 'row',
flexDirection: 'row',
justifyContent: 'flex-end',
justifyContent: 'flex-end',
marginTop:
1
0,
marginTop:
2
0,
}}>
}}>
<TouchableOpacity
<TouchableOpacity
onPress={
() => onCloseModal(null)
}
onPress={
onCloseModal
}
style={leavesModalStyles.btnCancel}>
style={leavesModalStyles.btnCancel}>
<AppText style={leavesModalStyles.blueTxt}>Hủy</AppText>
<AppText style={leavesModalStyles.blueTxt}>Hủy</AppText>
</TouchableOpacity>
</TouchableOpacity>
<TouchableOpacity
{isRequest && (
style={leavesModalStyles.btnSubmit}
<TouchableOpacity
onPress={onSubmitLeaveRequest}>
style={leavesModalStyles.btnSubmit}
<AppText style={leavesModalStyles.whiteTxt}>Gửi yêu cầu</AppText>
onPress={onSubmitLeaveRequest}>
</TouchableOpacity>
<AppText style={leavesModalStyles.whiteTxt}>
Gửi yêu cầu
</AppText>
</TouchableOpacity>
)}
{userInfo?.isApprover && (
<TouchableOpacity
style={leavesModalStyles.btnSubmit}
onPress={() => onSubmitApproveLeaveRequest(userInfo?.leave_id)}>
<AppText style={leavesModalStyles.whiteTxt}>
Duyệt yêu cầu
</AppText>
</TouchableOpacity>
)}
</View>
</View>
</View>
</View>
</ScrollView>
</ScrollView>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment