frontend approval
This commit is contained in:
@@ -33,7 +33,7 @@ class RequestLogShowResource extends JsonResource
|
|||||||
$corporateId = $requestLog['member']['current_plan']['corporate_id'] ?? 0;
|
$corporateId = $requestLog['member']['current_plan']['corporate_id'] ?? 0;
|
||||||
$member_id = $requestLog['member_id'];
|
$member_id = $requestLog['member_id'];
|
||||||
$planMember = MemberPlan::where('member_id', $member_id)->get('plan_id');
|
$planMember = MemberPlan::where('member_id', $member_id)->get('plan_id');
|
||||||
|
|
||||||
$planId = Plan::whereIn('id', $planMember)->where('service_code', $requestLog['service_code'])->first();
|
$planId = Plan::whereIn('id', $planMember)->where('service_code', $requestLog['service_code'])->first();
|
||||||
$benefit = CorporateBenefit::with(['benefit', 'plan'])->where('plan_id', $planId->id)->get()->toArray();
|
$benefit = CorporateBenefit::with(['benefit', 'plan'])->where('plan_id', $planId->id)->get()->toArray();
|
||||||
$benefitDetailLog = RequestLogBenefit::with('benefit')->where('request_log_id', $requestLog['id'])->get()->toArray();
|
$benefitDetailLog = RequestLogBenefit::with('benefit')->where('request_log_id', $requestLog['id'])->get()->toArray();
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ export default function DialogEditFinalLOG({requestLog, setOpenDialog, openDialo
|
|||||||
// Add more options as needed
|
// Add more options as needed
|
||||||
];
|
];
|
||||||
|
|
||||||
console.log(formData.type_of_member)
|
// console.log(formData.type_of_member)
|
||||||
|
|
||||||
const getContent = () => (
|
const getContent = () => (
|
||||||
<Stack spacing={1} marginTop={2}>
|
<Stack spacing={1} marginTop={2}>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { yupResolver } from '@hookform/resolvers/yup';
|
||||||
|
import { NumericFormat } from "react-number-format";
|
||||||
import {
|
import {
|
||||||
Container,
|
Container,
|
||||||
Grid,
|
Grid,
|
||||||
@@ -12,11 +15,17 @@ import {
|
|||||||
AccordionSummary,
|
AccordionSummary,
|
||||||
AccordionDetails,
|
AccordionDetails,
|
||||||
IconButton,
|
IconButton,
|
||||||
|
Divider,
|
||||||
|
ButtonBase
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
// components
|
// components
|
||||||
import Page from '../../../components/Page';
|
import Page from '../../../components/Page';
|
||||||
|
import Iconify from '@/components/Iconify';
|
||||||
|
import { FormProvider, RHFDatepicker, RHFSelect, RHFTextField } from '@/components/hook-form';
|
||||||
|
import RHFTextFieldMoney from '@/components/hook-form/v2/RHFTextFieldMoney';
|
||||||
// utils
|
// utils
|
||||||
import useSettings from '../../../hooks/useSettings';
|
import useSettings from '../../../hooks/useSettings';
|
||||||
|
import { useFieldArray, useForm } from 'react-hook-form';
|
||||||
// react
|
// react
|
||||||
import { useNavigate, useParams, useLocation } from 'react-router-dom';
|
import { useNavigate, useParams, useLocation } from 'react-router-dom';
|
||||||
import { useEffect, useState, useRef, useMemo } from 'react';
|
import { useEffect, useState, useRef, useMemo } from 'react';
|
||||||
@@ -33,6 +42,7 @@ import { Accordion } from '@mui/material';
|
|||||||
import { Delete, EditOutlined, ExpandMore } from '@mui/icons-material';
|
import { Delete, EditOutlined, ExpandMore } from '@mui/icons-material';
|
||||||
import {BenefitData } from '../FinalLog/Model/Types'
|
import {BenefitData } from '../FinalLog/Model/Types'
|
||||||
import AddIcon from '@mui/icons-material/Add';
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
|
import { LoadingButton } from '@mui/lab';
|
||||||
|
|
||||||
// Import Card Detail Final LOG
|
// Import Card Detail Final LOG
|
||||||
import CardDetail from '../Components/CardDetail';
|
import CardDetail from '../Components/CardDetail';
|
||||||
@@ -70,6 +80,19 @@ export default function Detail() {
|
|||||||
const [requestLog, setRequestLog] = useState<DetailFinalLogType>();
|
const [requestLog, setRequestLog] = useState<DetailFinalLogType>();
|
||||||
const [isReversal, setIsReversal] = useState(false);
|
const [isReversal, setIsReversal] = useState(false);
|
||||||
|
|
||||||
|
const defaultValues: any = {nominal : 0};
|
||||||
|
const validationSchema = Yup.object().shape({nominal: Yup.number().typeError('Nominal harus berupa angka').required('Nominal harus diisi')})
|
||||||
|
|
||||||
|
const methods = useForm<any>({
|
||||||
|
resolver: yupResolver(validationSchema),
|
||||||
|
defaultValues
|
||||||
|
});
|
||||||
|
|
||||||
|
const { handleSubmit, reset, watch, setValue, formState: { isDirty, isSubmitting, errors } } = methods;
|
||||||
|
|
||||||
|
const onSubmit = async (data: any) => {
|
||||||
|
alert('Nominal: ' + data.nominal);
|
||||||
|
}
|
||||||
|
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
@@ -146,9 +169,27 @@ export default function Detail() {
|
|||||||
// Handle Delete File LOG
|
// Handle Delete File LOG
|
||||||
const [pathFile, setPathFile] = useState('')
|
const [pathFile, setPathFile] = useState('')
|
||||||
const [dialogDeleteFIleLog, setDialogDeleteFileLog] = useState(false)
|
const [dialogDeleteFIleLog, setDialogDeleteFileLog] = useState(false)
|
||||||
|
|
||||||
// Handle Upload File LOG
|
// Handle Upload File LOG
|
||||||
const [dialogUploadFileLog, setDialogUploadFileLog] = useState(false)
|
const [dialogUploadFileLog, setDialogUploadFileLog] = useState(false)
|
||||||
|
|
||||||
|
|
||||||
|
const fileDiagnosaInput = useRef<HTMLInputElement>(null);
|
||||||
|
const [fileDiagnosas, setFileDiagnosas] = useState<any>([]);
|
||||||
|
const handleDiagnosaInputChange = (event:any) => {
|
||||||
|
if (event.target.files[0]) {
|
||||||
|
setFileDiagnosas([...fileDiagnosas, ...event.target.files]);
|
||||||
|
} else {
|
||||||
|
console.log('NO FILE');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const removeDiagnosaFiles = (filesState:any, index:any) => {
|
||||||
|
setFileDiagnosas(
|
||||||
|
filesState.filter((file:any, fileIndex:any) => {
|
||||||
|
return fileIndex != index;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page title='Detail'>
|
<Page title='Detail'>
|
||||||
@@ -323,6 +364,146 @@ export default function Detail() {
|
|||||||
</DialogHospitalCare>
|
</DialogHospitalCare>
|
||||||
</Grid> */}
|
</Grid> */}
|
||||||
|
|
||||||
|
{/* Surat persetujuan Tindakan */}
|
||||||
|
<Grid item xs={12}>
|
||||||
|
<Card sx={{ p: 3 }}>
|
||||||
|
<Stack direction="row" justifyContent="space-between" alignItems="flex-start" sx={{ mb: 3 }}>
|
||||||
|
<Typography variant="subtitle1" sx={{ color: '#19BBBB', fontWeight: 'bold' }}>
|
||||||
|
Tindakan Persetujuan
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{!isReversal && (
|
||||||
|
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<Stack spacing={2}>
|
||||||
|
<Stack spacing={2} sx={{ mb: 3 }}>
|
||||||
|
<Typography variant="body1" fontWeight="bold">
|
||||||
|
Upload Tindakan Persetujuan
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
{fileDiagnosas?.map((file: any, index: number) => (
|
||||||
|
<Stack
|
||||||
|
key={index}
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
|
<Typography variant="body2" color="text.secondary">
|
||||||
|
{file.name}
|
||||||
|
</Typography>
|
||||||
|
<Iconify
|
||||||
|
icon="eva:trash-2-outline"
|
||||||
|
color="darkred"
|
||||||
|
sx={{ cursor: "pointer" }}
|
||||||
|
onClick={() => removeDiagnosaFiles(fileDiagnosas, index)}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<ButtonBase
|
||||||
|
sx={{
|
||||||
|
p: 2,
|
||||||
|
border: "2px dashed #F9FAFB",
|
||||||
|
bgcolor: "#F4F6F8",
|
||||||
|
borderRadius: 2,
|
||||||
|
width: "100%",
|
||||||
|
height: 60,
|
||||||
|
}}
|
||||||
|
onClick={() => fileDiagnosaInput.current?.click()}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
display="flex"
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="center"
|
||||||
|
gap={1}
|
||||||
|
>
|
||||||
|
<Iconify icon="icon-park-outline:upload-one" fontSize="2rem" />
|
||||||
|
<Typography variant="body2" fontWeight="bold">
|
||||||
|
Upload Tindakan Persetujuan
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
ref={fileDiagnosaInput}
|
||||||
|
style={{ display: "none" }}
|
||||||
|
multiple
|
||||||
|
onChange={handleDiagnosaInputChange}
|
||||||
|
accept="application/pdf,image/*"
|
||||||
|
/>
|
||||||
|
</ButtonBase>
|
||||||
|
</Stack>
|
||||||
|
<RHFTextFieldMoney
|
||||||
|
id='nominal'
|
||||||
|
name={`nominal`}
|
||||||
|
label="Nominal"
|
||||||
|
required
|
||||||
|
placeholder="Nominal"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LoadingButton
|
||||||
|
type="submit" // ✅ supaya ikut submit
|
||||||
|
variant="contained"
|
||||||
|
sx={{ marginTop: 2, p: 2, backgroundColor: "#19BBBB" }}
|
||||||
|
loading={false}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</LoadingButton>
|
||||||
|
</Stack>
|
||||||
|
</FormProvider>
|
||||||
|
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* FILE YANG SUDAH TERUPLOAD */}
|
||||||
|
{requestLog?.files?.map((documentType, index) => (
|
||||||
|
<Stack
|
||||||
|
key={index}
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
alignItems="center"
|
||||||
|
sx={{ mb: 2 }}
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href={documentType.url}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
style={{ textDecoration: 'none', color: '#19BBBB' }}
|
||||||
|
>
|
||||||
|
<Typography variant="body2">
|
||||||
|
{documentType.original_name || '-'}
|
||||||
|
</Typography>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{!isReversal && (
|
||||||
|
<IconButton
|
||||||
|
onClick={() => {
|
||||||
|
setDialogDeleteFileLog(true);
|
||||||
|
setPathFile(documentType.path);
|
||||||
|
}}
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<Delete color="error" fontSize="small" />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{/* DIALOG */}
|
||||||
|
<DialogDeleteFileLog
|
||||||
|
id={requestLog?.id}
|
||||||
|
path={pathFile}
|
||||||
|
setOpenDialog={setDialogDeleteFileLog}
|
||||||
|
openDialog={dialogDeleteFIleLog}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<DialogUploadFileFinalLog
|
||||||
|
id={requestLog?.id}
|
||||||
|
setOpenDialog={setDialogUploadFileLog}
|
||||||
|
openDialog={dialogUploadFileLog}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
{/* Benefit */}
|
{/* Benefit */}
|
||||||
<Grid item xs={12} md={12}>
|
<Grid item xs={12} md={12}>
|
||||||
<Card sx={{padding:2}} >
|
<Card sx={{padding:2}} >
|
||||||
|
|||||||
Reference in New Issue
Block a user