OnLeaveModalDetails.js 32.1 KB
Newer Older
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
1 2 3 4
/* eslint-disable prettier/prettier */
import CheckBox from '@react-native-community/checkbox';
import Moment from 'moment';
import React, {useEffect, useState} from 'react';
5
import {
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
6 7 8 9
  Dimensions,
  Image,
  KeyboardAvoidingView,
  Modal,
10 11
  SafeAreaView,
  ScrollView,
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
12 13
  StyleSheet,
  TextInput,
14 15 16
  TouchableOpacity,
  View,
} from 'react-native';
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
17 18 19 20
import Toast from 'react-native-toast-message';
import {useDispatch, useSelector} from 'react-redux';
import AppText from '../../../components/AppText';
import ButtonComponent from '../../../components/ButtonComponent';
21
import {
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
22
  deleteLeaveTicket,
23
  getCommentByCode,
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
24
  getImageByCode,
25 26
  getUserLeaveHistories,
  postApproveLeaveDay,
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
27 28
  postComment,
  postRejectLeaveDay,
29 30
} from '../../../store/actions/UserAction';
import colors from '../../../values/colors';
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
31
import {IMAGES} from '../../../values/images';
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
const OnLeaveModalDetail = ({
  alertMessage,
  onClose,
  detailItem,
  userDetails,
  setPayloadApproveLeaves,
}) => {
  const dispatch = useDispatch();
  //console.log('detailItem', detailItem);
  const userDirectManagersList = useSelector(
    state => state.MyDirectManagers.myDirectManagers,
  );
  const initStateLeave = {
    id: '',
    since: new Date(),
    timeStart: '',
    dateStart: '',
    toDate: new Date(),
    timeFinish: '',
    dateFinish: '',
    reason: '',
    taken_hours: 0,
    approved_date: new Date(),
    approver_id: '',
  };
  const initComment = {
    code: '',
    content: '',
  };
  // STATE
  const [detailImage, setDetailImage] = useState([]);
  const [leave, setLeave] = useState(initStateLeave);
  const [leaveDayDetail, setLeaveDayDetail] = useState(null);
  const [leaveHistories, setLeaveHistories] = useState([]);
  const [leaveComment, setLeaveComment] = useState([]);
  const [comment, setComment] = useState(initComment);
  const [userManagerList, setUserManagerList] = useState([]);
  const [commentApprove, setCommentApprove] = useState('');
  const [isNextApprover, setIsNextApprover] = useState(false);
  const [nextApproverId, setNextApproverId] = useState('');
  // main function
  const onOpenDetailLeave = async () => {
    const objectClone = JSON.parse(JSON.stringify(userDirectManagersList));
    let obj = [];
    objectClone.forEach(element => {
      element.checked = false;
      obj.push(element);
    });
    setUserManagerList(obj);
    setLeaveDayDetail(detailItem);
    if (detailItem) {
      const responseHistories = await dispatch(
        getUserLeaveHistories(detailItem.id),
      );
      setLeaveHistories(responseHistories);
      const responseComment = await dispatch(getCommentByCode(detailItem.id));
      setLeaveComment(responseComment);
      const responseImage = await dispatch(getImageByCode(detailItem.id));
      setDetailImage(responseImage);
    }
  };
  const onSelectManager = async (value, index, item) => {
    let userManagerListClone = [...userManagerList];
    let elementFound = userManagerListClone.find(
      element => element.id == item.id,
    );
    let indexElementFound = userManagerListClone.findIndex(
      element => element.id == item.id,
    );
    userManagerListClone.splice(indexElementFound, 1, {
      ...elementFound,
      checked: value,
    });
    setUserManagerList(userManagerListClone);
    setLeave(state => ({
      ...state,
      approver_id: item.id,
    }));

    if (isNextApprover) {
      setNextApproverId(item.id);
    } else {
      setNextApproverId('');
      setLeave(state => ({
        ...state,
        approver_id: item.id,
      }));
    }
  };
  const onSubmitComment = async () => {
    if (comment.content) {
      const res = await dispatch(postComment(comment));
      if (res) {
        setComment(initComment);
        const responseComment = await dispatch(getCommentByCode(comment.code));
        setLeaveComment(responseComment);
        return;
      }
    }
  };
  const onRejectRequest = async id => {
    const res = await dispatch(postRejectLeaveDay(id, commentApprove));
    if (res) {
      Toast.show({
        type: 'success',
        text1: `Hệ thống`,
        text2: `Thành công!`,
        styles: {zIndex: 1000},
      });

      refreshAfterSubmit();
    } else {
      Toast.show({
        type: 'success',
        text1: `Hệ thống`,
        text2: `Không thành công!`,
        styles: {zIndex: 1000},
      });
    }
    onClose(null);
  };
  const onApproveRequest = async id => {
    const res = await dispatch(
      postApproveLeaveDay(id, commentApprove, nextApproverId),
    );
    if (res) {
      Toast.show({
        type: 'success',
        text1: `Hệ thống`,
        text2: `Thành công!`,
        styles: {zIndex: 1000},
      });
      refreshAfterSubmit();
    } else {
      Toast.show({
        type: 'success',
        text1: `Hệ thống`,
        text2: `Không thành công!`,
        styles: {zIndex: 1000},
      });
    }
    onClose(null);
  };
  const refreshAfterSubmit = () => {
    setLeave(initStateLeave);
    setComment(initComment);
    setCommentApprove('');
    setDetailImage(null);
    setLeaveDayDetail(null);
    setIsNextApprover(false);
    setUserManagerList([]);
    setPayloadApproveLeaves(prev => ({...prev, isRefresh: true}));
  };
  const deleteItem = async () => {
    const res = await dispatch(deleteLeaveTicket(detailItem.id));
    if (res) {
      onClose(null);
      Toast.show({
        type: 'success',
        text1: `Hệ thống`,
        text2: `Hủy yêu cầu thành công 💓`,
        visibilityTime: 2000,
        style: {zIndex: 1001},
      });
    } else {
      onClose(null);
      Toast.show({
        type: 'error',
        text1: `Hệ thống`,
        text2: `Hủy yêu cầu thất bại 💔`,
        visibilityTime: 2000,
        style: {zIndex: 1001},
      });
    }
    //console.log('deleteItem', detailItem);
  };
  useEffect(() => {
    onOpenDetailLeave();
  }, []);
  return (
    <Modal
      animationType="slide"
      transparent={true}
      visible={true}
      onRequestClose={() => onClose(null)}>
      <SafeAreaView>
        <ScrollView>
          <View style={styles.modalViewEdit}>
            <View style={styles.headerModalBottom}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
221 222 223
              <AppText style={styles.titleModalBottom}>
                Chi tiết ngh phép
              </AppText>
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
              <TouchableOpacity onPress={() => onClose(null)}>
                <Image
                  style={{height: 20, width: 20}}
                  source={IMAGES.IcClose}
                />
              </TouchableOpacity>
            </View>
            <View style={styles.bodyHeight}>
              <View style={styles.bodyModal}>
                <View style={{flexDirection: 'row'}}>
                  <Image
                    source={{
                      uri:
                        'https://meu.anawork.com' +
                        leaveDayDetail?.extend_creator_avatar,
                    }}
                    style={{width: 40, height: 40, borderRadius: 2}}
                  />
                  <View
                    style={{
                      justifyContent: 'space-around',
                      marginLeft: 16,
                    }}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
247
                    <AppText style={{fontSize: 14, fontWeight: '600'}}>
248 249
                      {leaveDayDetail?.extend_creator_full_name} -{' '}
                      {leaveDayDetail?.extend_creator_employee_code}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
250 251 252 253
                    </AppText>
                    <AppText>
                      {leaveDayDetail?.extend_creator_department}
                    </AppText>
254 255 256 257
                  </View>
                </View>
                {leaveDayDetail && (
                  <View style={{marginTop: 16}}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
258
                    <AppText
259 260 261 262 263 264
                      style={{
                        fontWeight: '500',
                        fontSize: 14,
                        marginBottom: 12,
                      }}>
                      Thông tin chung
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
265
                    </AppText>
266
                    <View style={styles.commonDetail}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
267 268 269 270
                      <AppText style={styles.textMediumGrey}>
                        Loi ngh phép
                      </AppText>
                      <AppText>{leaveDayDetail.extend_category_name}</AppText>
271 272
                    </View>
                    <View style={styles.commonDetail}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
273 274
                      <AppText style={styles.textMediumGrey}>T ngày</AppText>
                      <AppText>
275 276 277
                        {Moment(leaveDayDetail.start).format(
                          'DD/MM/YYYY hh:mm',
                        )}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
278
                      </AppText>
279 280
                    </View>
                    <View style={styles.commonDetail}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
281 282
                      <AppText style={styles.textMediumGrey}>Đến ngày</AppText>
                      <AppText>
283 284 285
                        {Moment(leaveDayDetail.finish).format(
                          'DD/MM/YYYY hh:mm',
                        )}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
286
                      </AppText>
287 288
                    </View>
                    <View style={styles.commonDetail}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
289 290 291 292
                      <AppText style={styles.textMediumGrey}>
                        Thi gian ngh
                      </AppText>
                      <AppText>{leaveDayDetail.extend_taken_days} ngày</AppText>
293 294
                    </View>
                    <View style={styles.commonDetail}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
295 296
                      <AppText style={styles.textMediumGrey}>Lý do</AppText>
                      <AppText style={[styles.reason]}>
297
                        {leaveDayDetail.reason}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
298
                      </AppText>
299 300
                    </View>
                    <View style={styles.commonDetail}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
301
                      <AppText style={[styles.textMediumGrey, {fontSize: 12}]}>
302
                        Tp đính kèm
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
303
                      </AppText>
304 305 306 307 308
                      <View style={styles.attachment}>
                        {
                          //physical_path.slice(30)
                          detailImage?.length > 0 &&
                            detailImage.map((item, index) => (
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
309
                              <AppText
310 311 312 313
                                key={index}
                                numberOfLines={1}
                                style={{fontSize: 13, color: '#5d78ff'}}>
                                {item.file_name}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
314
                              </AppText>
315 316 317
                            ))
                        }
                        {detailImage?.length == 0 && (
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
318
                          <AppText style={{fontSize: 13, color: '#757575'}}>
319
                            Không có tp đính kèm
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
320
                          </AppText>
321 322 323 324 325 326
                        )}
                      </View>
                    </View>
                  </View>
                )}
                <View style={{marginTop: 16}}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
327
                  <AppText
328 329 330 331 332 333
                    style={{
                      fontWeight: '500',
                      fontSize: 14,
                      marginBottom: 12,
                    }}>
                    Lch s duyt
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
334
                  </AppText>
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
                  {leaveHistories.length > 0 &&
                    leaveHistories.map((item, index) => (
                      <View key={index} style={{flexDirection: 'row'}}>
                        <Image
                          source={{
                            uri:
                              'https://meu.anawork.com' +
                              item.extend_approver_avatar,
                          }}
                          style={styles.avatarApprove}
                        />
                        <View>
                          <View
                            style={{
                              flexDirection: 'row',
                              justifyContent: 'space-between',
                              width: '83%',
                            }}>
                            <View
                              style={{
                                justifyContent: 'space-between',
                                marginLeft: 8,
                              }}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
358 359 360
                              <AppText>
                                {item.extend_approver_full_name}
                              </AppText>
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
                              <View style={{flexDirection: 'row'}}>
                                {item.extend_approved_status_name ==
                                  'APPROVED' && (
                                  <Image
                                    style={{height: 16, width: 16}}
                                    source={IMAGES.uCheck}
                                  />
                                )}
                                {item.extend_approved_status_name ==
                                  'PENDING' && <Image source={IMAGES.uMinus} />}
                                {item.extend_approved_status_name ==
                                  'REJECTED' && (
                                  <Image
                                    source={IMAGES.IcReject}
                                    style={{
                                      height: 12,
                                      width: 12,
                                      alignSelf: 'center',
                                    }}
                                  />
                                )}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
382
                                <AppText
383 384 385 386 387 388 389 390 391 392 393 394
                                  style={{
                                    color: item.extend_approved_status_color,
                                    fontStyle: 'italic',
                                    fontSize: 12,
                                  }}>
                                  {(item.extend_approved_status_name ==
                                    'APPROVED' &&
                                    'Đã duyệt') ||
                                    (item.extend_approved_status_name ==
                                      'PENDING' &&
                                      'Đang chờ') ||
                                    'Đã từ chối'}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
395
                                </AppText>
396 397
                              </View>
                            </View>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
398
                            <AppText style={{fontSize: 12, color: '#959595'}}>
399
                              {Moment(item.created_at).format('DD/MM/YYYY')}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
400
                            </AppText>
401 402
                          </View>
                          <View style={{marginLeft: 8}}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
403
                            <AppText style={{fontSize: 13, color: '#757575'}}>
404
                              {item.comment ? item.comment : ''}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
405
                            </AppText>
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
                          </View>
                        </View>
                      </View>
                    ))}
                  {leaveDayDetail?.extend_approved_status_name == 'PENDING' &&
                    leaveDayDetail?.approver_id == userDetails.id && (
                      <View style={{flexDirection: 'row'}}>
                        <Image
                          source={{
                            uri: 'https://meu.anawork.com' + userDetails.avatar,
                          }}
                          style={styles.avatarApprove}
                        />
                        <View>
                          <View
                            style={{
                              flexDirection: 'row',
                              justifyContent: 'space-between',
                              width: '83%',
                            }}>
                            <View
                              style={{
                                justifyContent: 'space-between',
                                marginLeft: 8,
                              }}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
431
                              <AppText>
432
                                {leaveDayDetail.extend_approver_full_name}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
433
                              </AppText>
434 435 436 437 438 439 440 441 442 443
                              <View style={{flexDirection: 'row'}}>
                                {leaveDayDetail.extend_approved_status_name ==
                                'APPROVED' ? (
                                  <Image
                                    style={{height: 16, width: 16}}
                                    source={IMAGES.uCheck}
                                  />
                                ) : (
                                  <Image source={IMAGES.uMinus} />
                                )}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
444
                                <AppText
445 446 447 448 449 450 451 452 453 454 455 456 457
                                  style={{
                                    color:
                                      leaveDayDetail.extend_approved_status_color,
                                    fontStyle: 'italic',
                                    fontSize: 12,
                                  }}>
                                  {(leaveDayDetail.extend_approved_status_name ==
                                    'APPROVED' &&
                                    'Đã duyệt') ||
                                    (leaveDayDetail.extend_approved_status_name ==
                                      'PENDING' &&
                                      'Đang chờ') ||
                                    'Đã từ chối'}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
458
                                </AppText>
459 460
                              </View>
                            </View>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
461
                            <AppText style={{fontSize: 12, color: '#959595'}}>
462
                              {Moment().format('DD/MM/YYYY')}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
463
                            </AppText>
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
                          </View>
                          <View style={{marginLeft: 8}}>
                            <View style={styles.wrapperComment}>
                              <KeyboardAvoidingView
                                behavior={
                                  Platform.OS === 'ios' ? 'padding' : 'height'
                                }>
                                <TextInput
                                  placeholder="Nhập lý do tại đây"
                                  style={styles.commentInput}
                                  multiline
                                  value={commentApprove}
                                  onChangeText={text => {
                                    setCommentApprove(text);
                                  }}
                                />
                              </KeyboardAvoidingView>
                            </View>
                          </View>
                        </View>
                      </View>
                    )}
                </View>
                {leaveDayDetail?.approver_id == userDetails.id && (
                  <View
                    style={{
                      marginTop: 12,
                      flexDirection: 'row',
                      alignItems: 'center',
                    }}>
                    <CheckBox
                      boxType="square"
                      animationDuration={0.3}
                      value={isNextApprover}
                      onValueChange={value => setIsNextApprover(value)}
                    />
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
500
                    <AppText
501 502 503 504 505 506
                      style={{
                        fontSize: 14,
                        color: '#434349',
                        marginLeft: 4,
                      }}>
                      Chn người duyt tiếp theo
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
507
                    </AppText>
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
                  </View>
                )}
                {isNextApprover &&
                  userManagerList.map((item, index) => (
                    <View
                      key={index}
                      style={{
                        flexDirection: 'row',
                        justifyContent: 'space-between',
                        alignItems: 'center',
                        marginTop: 12,
                      }}>
                      <Image
                        source={{
                          uri: 'https://meu.anawork.com' + item.avatar,
                        }}
                        style={styles.avatarApprove}
                      />
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
526
                      <AppText
527 528 529 530
                        style={{
                          fontSize: 16,
                          fontWeight: '500',
                          marginLeft: 10,
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
531
                        }}>{`${item.extend_user_full_name}`}</AppText>
532 533 534 535 536 537 538 539 540 541 542 543
                      <CheckBox
                        disabled={false}
                        value={item.checked}
                        onValueChange={newValue =>
                          onSelectManager(newValue, index, item)
                        }
                        boxType="square"
                        animationDuration={0.3}
                      />
                    </View>
                  ))}
                <View style={{marginTop: 16}}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
544
                  <AppText
545 546 547 548 549 550
                    style={{
                      fontWeight: '500',
                      fontSize: 14,
                      marginBottom: 12,
                    }}>
                    Bình lun
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
551
                  </AppText>
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
                  {/*others comment*/}
                  {leaveComment &&
                    leaveComment.map((item, index) => (
                      <View style={styles.commentHistories} key={index}>
                        <Image
                          source={{
                            uri:
                              'https://meu.anawork.com' +
                              item.extend_staff_avatar,
                          }}
                          style={styles.avatarComment}
                        />
                        <View style={styles.commentBox}>
                          <View
                            style={{
                              flexDirection: 'row',
                              justifyContent: 'space-between',
                            }}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
570
                            <AppText
571 572 573 574 575 576
                              style={{
                                color: '#434349',
                                fontSize: 12,
                                fontWeight: '500',
                              }}>
                              {item.extend_staff_full_name}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
577 578
                            </AppText>
                            <AppText style={{color: '#959595', fontSize: 10}}>
579 580 581
                              {Moment(item.created_at).format(
                                'DD/MM/YYYY hh:mm',
                              )}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
582
                            </AppText>
583
                          </View>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
584
                          <AppText
585 586 587 588 589 590
                            style={{
                              color: '#666666',
                              fontSize: 13,
                              marginTop: 8,
                            }}>
                            {item.content}
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
591
                          </AppText>
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
                        </View>
                      </View>
                    ))}
                  {/*my comment*/}
                  <View style={[styles.commentHistories, {marginTop: 16}]}>
                    <Image
                      source={{
                        uri: 'https://meu.anawork.com' + userDetails.avatar,
                      }}
                      style={styles.avatarComment}
                    />
                    <View style={{width: '88%', position: 'relative'}}>
                      <TextInput
                        style={styles.commentText}
                        multiline
                        placeholder="Nhập bình luận ở đây"
                        onChangeText={text => {
                          setComment({
                            content: text,
                            code: leaveDayDetail.id,
                          });
                        }}
                        value={comment.content}
                      />
                      <View style={{position: 'absolute', right: 0, top: 10}}>
                        <TouchableOpacity onPress={onSubmitComment}>
                          <Image
                            style={{height: 16, width: 16, marginRight: 4}}
                            source={IMAGES.IcSend}
                          />
                        </TouchableOpacity>
                      </View>
                    </View>
                  </View>
                </View>
              </View>
            </View>
            <View style={styles.bottomModal}>
              <TouchableOpacity
                style={styles.btnCancel}
                onPress={() => onClose(null)}>
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
633
                <AppText
634 635
                  style={{color: '#5d78ff', fontSize: 14, fontWeight: '500'}}>
                  Hy
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
636
                </AppText>
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
              </TouchableOpacity>
              {leaveDayDetail &&
                leaveDayDetail?.approver_id !== userDetails.id &&
                detailItem.extend_approved_status_name === 'PENDING' && (
                  <ButtonComponent
                    style={{flexDirection: 'row', alignItems: 'center'}}
                    text={'Xóa yêu cầu'}
                    textStyle={{
                      color: '#ff0a3a',
                      fontSize: 14,
                      fontWeight: '500',
                    }}
                    leftIcon={IMAGES.IcReject}
                    styleIcon={{height: 15, width: 15, marginRight: 4}}
                    onPress={deleteItem}
                  />
                )}
              {leaveDayDetail?.approver_id === userDetails.id &&
                leaveDayDetail?.extend_approved_status_name == 'PENDING' && (
                  <View style={{flexDirection: 'row'}}>
                    <TouchableOpacity
                      style={styles.btnReject}
                      onPress={() => {
                        onRejectRequest(leaveDayDetail.id);
                      }}>
                      <Image
                        style={{height: 16, width: 16, marginRight: 4}}
                        source={IMAGES.IcReject}
                      />
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
666
                      <AppText
667 668 669 670 671 672
                        style={{
                          color: '#ff0a3a',
                          fontSize: 14,
                          fontWeight: '500',
                        }}>
                        T chi
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
673
                      </AppText>
674 675 676 677 678 679 680 681 682 683
                    </TouchableOpacity>
                    <TouchableOpacity
                      style={styles.btnAccept}
                      onPress={() => {
                        onApproveRequest(leaveDayDetail.id);
                      }}>
                      <Image
                        style={{height: 16, width: 16, marginRight: 4}}
                        source={IMAGES.IcAccept}
                      />
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
684
                      <AppText
685 686 687 688 689 690
                        style={{
                          color: 'white',
                          fontSize: 14,
                          fontWeight: '500',
                        }}>
                        Duyt yêu cu
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
691
                      </AppText>
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981
                    </TouchableOpacity>
                  </View>
                )}
            </View>
          </View>
        </ScrollView>
      </SafeAreaView>
    </Modal>
  );
};
const windowWidth = Dimensions.get('window').width;
const windowHeight = Dimensions.get('window').height;
const styles = StyleSheet.create({
  container: {
    flex: 1,
  },

  primary_blue: {
    color: '#5d78ff',
  },
  item: {
    padding: 20,
    marginVertical: 2,
    marginHorizontal: 16,
    borderWidth: 1,
    borderBottomColor: '#f2f2f2',
    borderTopColor: '#f2f2f2',
    borderRightColor: '#f2f2f2',
    borderRadius: 8,
    borderLeftWidth: 3,
    flexDirection: 'row',
  },
  title: {
    fontWeight: '500',
    fontSize: 16,
    color: 'black',
  },
  centeredView: {
    justifyContent: 'center',
    alignItems: 'center',
    marginTop: 22,
  },
  modalView: {
    backgroundColor: 'white',
    borderRadius: 20,
    padding: 16,
    shadowColor: '#000',
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.25,
    shadowRadius: 4,
    elevation: 5,
    marginTop: 20,
    // height: windowHeight,
  },
  modalViewEdit: {
    backgroundColor: 'white',
    borderRadius: 20,
    padding: 16,
    // height: windowHeight,
    shadowColor: '#000',
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.25,
    shadowRadius: 4,
    elevation: 5,
    marginTop: 20,
    minHeight: windowHeight,
  },
  button: {
    borderRadius: 20,
    padding: 10,
    elevation: 2,
  },
  buttonOpen: {
    backgroundColor: '#F194FF',
  },
  buttonClose: {
    backgroundColor: '#2196F3',
  },
  textStyle: {
    color: 'white',
    fontWeight: 'bold',
    textAlign: 'center',
  },
  modalTitle: {
    fontWeight: '500',
    fontSize: 16,
  },
  dropdown1DropdownStyle: {backgroundColor: '#EFEFEF'},
  dropdown1RowStyle: {
    backgroundColor: '#EFEFEF',
    borderBottomColor: '#C5C5C5',
    height: 38,
    borderRadius: 4,
  },
  dropdown1RowTxtStyle: {color: '#444', textAlign: 'left', fontSize: 14},
  dropdownSelectTimeText: {color: '#444', textAlign: 'left', fontSize: 14},
  dropdown1BtnStyle: {
    backgroundColor: '#FFF',
    borderBottomWidth: 0.2,
    height: 24,
    width: '100%',
    fontSize: 12,
    borderColor: '#444',
  },
  dropdown1BtnTxtStyle: {color: '#000', fontSize: 14, textAlign: 'left'},
  rowView: {
    flexDirection: 'row',
    marginTop: 10,
    justifyContent: 'space-between',
    alignItems: 'center',
  },
  inputText: {
    backgroundColor: '#FFF',
    paddingLeft: 18,
    marginTop: 4,
  },
  touchableOpacity: {
    borderColor: colors.primary_blue,
    borderStyle: 'dotted',
    borderWidth: 1,
    justifyContent: 'center',
    alignItems: 'center',
    height: 100,
    padding: 10,
    width: '35%',
  },
  btnSubmit: {
    backgroundColor: '#5d78ff',
    justifyContent: 'center',
    alignItems: 'center',
    height: 40,
    borderRadius: 8,
    width: 100,
  },
  btnCancel: {
    backgroundColor: colors.white,
    justifyContent: 'center',
    alignItems: 'center',
    height: 40,
    borderRadius: 8,
    width: 100,
  },
  ImgAvatar: {
    width: 50,
    height: 50,
    borderRadius: 30,
  },
  imgUpload: {
    resizeMode: 'contain',
    height: 90,
    width: 100,
  },
  headerModalBottom: {
    paddingRight: 10,
    paddingLeft: 10,
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
  titleModalBottom: {
    fontSize: 16,
    fontWeight: '500',
  },
  bodyModal: {
    // flex: 1,
    paddingHorizontal: 10,
    marginTop: 16,
  },
  reason: {
    width: windowWidth / 2 - 25,
    textAlign: 'right',
  },
  textMediumGrey: {
    color: '#757575',
  },
  commonDetail: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    fontSize: 14,
    marginBottom: 12,
    fontFamily: 'Roboto',
  },
  attachment: {
    borderColor: '#c4c4c4',
    borderStyle: 'dashed',
    borderWidth: 0.5,
    borderRadius: 4,
    height: 60,
    width: '50%',
    justifyContent: 'center',
    alignItems: 'center',
    padding: 8,
  },
  checkbox: {
    alignSelf: 'center',
    height: 16,
    width: 16,
    marginRight: 4,
  },
  commentHistories: {
    flexDirection: 'row',
    marginBottom: 10,
  },
  avatarApprove: {
    width: 32,
    height: 32,
    borderRadius: 4,
  },
  avatarComment: {
    width: 32,
    height: 32,
    borderRadius: 32,
  },
  commentBox: {
    backgroundColor: '#e5eaf0',
    width: '88%',
    marginLeft: 8,
    paddingHorizontal: 12,
    paddingVertical: 8,
    borderTopRightRadius: 4,
    borderBottomRightRadius: 4,
    borderBottomLeftRadius: 4,
  },
  commentText: {
    marginLeft: 8,
    width: '100%',
    color: '#959595',
    fontSize: 12,
    borderBottomColor: '#5c65dc',
    borderBottomWidth: 1,
    paddingLeft: 8,
    paddingRight: 28,
    paddingVertical: 10,
  },
  bottomModal: {
    width: '100%',
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    paddingHorizontal: 8,
    marginTop: 20,
    // flex: 1
  },
  bodyHeight: {
    // flex: 2
  },
  btnAccept: {
    flexDirection: 'row',
    paddingHorizontal: 8,
    paddingVertical: 12,
    backgroundColor: '#5d78ff',
    borderRadius: 4,
  },
  btnCancel: {
    paddingHorizontal: 8,
    paddingVertical: 12,
  },
  btnReject: {
    flexDirection: 'row',
    paddingHorizontal: 8,
    paddingVertical: 12,
    marginRight: 8,
  },
  wrapperComment: {
    borderColor: '#5d78ff',
    borderStyle: 'dashed',
    borderWidth: 0.5,
    borderRadius: 4,
    height: 60,
    width: '81%',
    padding: 8,
  },
  commentInput: {
    fontSize: 13,
  },
  takeTimeStyle: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'flex-end',
    borderBottomColor: '#444',
    borderBottomWidth: 0.2,
    height: 24,
  },
});
export default OnLeaveModalDetail;