Fix Upload Files
This commit is contained in:
@@ -69,10 +69,40 @@ class ClaimRequestController extends Controller
|
|||||||
|
|
||||||
if ($request->hasFile('result_files')) {
|
if ($request->hasFile('result_files')) {
|
||||||
foreach ($request->result_files as $file) {
|
foreach ($request->result_files as $file) {
|
||||||
$pathFile = File::storeFile('claim', $newClaimRequest->id, $file);
|
$pathFile = File::storeFile('claim-result', $newClaimRequest->id, $file);
|
||||||
$newClaimRequest->files()->updateOrCreate([
|
$newClaimRequest->files()->updateOrCreate([
|
||||||
'type' => 'result',
|
'type' => 'claim-result',
|
||||||
'name' => File::getFileName('claim', $newClaimRequest->id, $file),
|
'name' => File::getFileName('claim-result', $newClaimRequest->id, $file),
|
||||||
|
'original_name' => $file->getClientOriginalName(),
|
||||||
|
'extension' => $file->getClientOriginalExtension(),
|
||||||
|
'path' => $pathFile,
|
||||||
|
'created_by' => auth()->user()->id,
|
||||||
|
'updated_by' => auth()->user()->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->hasFile('diagnosa_files')) {
|
||||||
|
foreach ($request->result_files as $file) {
|
||||||
|
$pathFile = File::storeFile('claim-diagnosis', $newClaimRequest->id, $file);
|
||||||
|
$newClaimRequest->files()->updateOrCreate([
|
||||||
|
'type' => 'claim-diagnosis',
|
||||||
|
'name' => File::getFileName('claim-diagnosis', $newClaimRequest->id, $file),
|
||||||
|
'original_name' => $file->getClientOriginalName(),
|
||||||
|
'extension' => $file->getClientOriginalExtension(),
|
||||||
|
'path' => $pathFile,
|
||||||
|
'created_by' => auth()->user()->id,
|
||||||
|
'updated_by' => auth()->user()->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->hasFile('kondisi_files')) {
|
||||||
|
foreach ($request->result_files as $file) {
|
||||||
|
$pathFile = File::storeFile('claim-kondisi', $newClaimRequest->id, $file);
|
||||||
|
$newClaimRequest->files()->updateOrCreate([
|
||||||
|
'type' => 'claim-kondisi',
|
||||||
|
'name' => File::getFileName('claim-kondisi', $newClaimRequest->id, $file),
|
||||||
'original_name' => $file->getClientOriginalName(),
|
'original_name' => $file->getClientOriginalName(),
|
||||||
'extension' => $file->getClientOriginalExtension(),
|
'extension' => $file->getClientOriginalExtension(),
|
||||||
'path' => $pathFile,
|
'path' => $pathFile,
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ class File extends Model
|
|||||||
'import-temp' => 'import-temp/',
|
'import-temp' => 'import-temp/',
|
||||||
'avatar' => 'user-avatar/',
|
'avatar' => 'user-avatar/',
|
||||||
'dataDiri' => 'data-diri/',
|
'dataDiri' => 'data-diri/',
|
||||||
'claim' => 'claim/'
|
'claim-result' => 'claim/',
|
||||||
|
'claim-diagnosis' => 'claim/',
|
||||||
|
'claim-kondisi' => 'claim/',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function fileable()
|
public function fileable()
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ import { UserCurrentCorporateContext } from '../../contexts/UserCurrentCorporate
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
const itemList = [
|
const itemList = [
|
||||||
{ info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '08:00 WIB' },
|
{ info: 'Mohon lengkapi dokumen Alison Born', date: 'Selasa, 13 Februari 23', time: '09:43 WIB' },
|
||||||
{ info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '09:00 WIB' },
|
|
||||||
{ info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '10:00 WIB' },
|
|
||||||
{ info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '11:00 WIB' },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ const ItemStyle = styled(Card)(({ theme }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const itemList = [
|
const itemList = [
|
||||||
{ info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '08:00 WIB' },
|
{ info: 'Mohon lengkapi dokumen Alison Born', date: 'Selasa, 13 Februari 23', time: '09:43 WIB' },
|
||||||
{ info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '09:00 WIB' },
|
|
||||||
{ info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '10:00 WIB' },
|
|
||||||
{ info: 'Mohon lengkapi dokumen Mahen sadarsa', date: 'Selasa, 20 April 22', time: '11:00 WIB' },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|||||||
@@ -25,6 +25,48 @@ export default function FormRequestClaim({ member, handleSubmitSuccess }) {
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Files Diagnosa
|
||||||
|
|
||||||
|
const fileDiagnosaInput = useRef<HTMLInputElement>(null);
|
||||||
|
const [fileDiagnosas, setFileDiagnosas] = useState([]);
|
||||||
|
|
||||||
|
const handleDiagnosaInputChange = (event) => {
|
||||||
|
if (event.target.files[0]) {
|
||||||
|
setFileDiagnosas([...fileDiagnosas, ...event.target.files]);
|
||||||
|
} else {
|
||||||
|
console.log('NO FILE');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const removeDiagnosaFiles = (filesState, index) => {
|
||||||
|
setFileDiagnosas(
|
||||||
|
filesState.filter((file, fileIndex) => {
|
||||||
|
return fileIndex != index;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Files Result Kondisi
|
||||||
|
|
||||||
|
const fileKondisiInput = useRef<HTMLInputElement>(null);
|
||||||
|
const [fileKondisis, setFileKondisis] = useState([]);
|
||||||
|
|
||||||
|
const handleKondisiInputChange = (event) => {
|
||||||
|
if (event.target.files[0]) {
|
||||||
|
setFileKondisis([...fileKondisis, ...event.target.files]);
|
||||||
|
} else {
|
||||||
|
console.log('NO FILE');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const removeKondisiFiles = (filesState, index) => {
|
||||||
|
setFileKondisis(
|
||||||
|
filesState.filter((file, fileIndex) => {
|
||||||
|
return fileIndex != index;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Files Result Hasil Penunjang
|
// Files Result Hasil Penunjang
|
||||||
|
|
||||||
@@ -53,9 +95,11 @@ export default function FormRequestClaim({ member, handleSubmitSuccess }) {
|
|||||||
function submitRequest() {
|
function submitRequest() {
|
||||||
setSubmitLoading(true);
|
setSubmitLoading(true);
|
||||||
const formData = makeFormData({
|
const formData = makeFormData({
|
||||||
'member_id' : member.id,
|
member_id: member.id,
|
||||||
'result_files' : fileHasilPenunjangs
|
result_files: fileHasilPenunjangs,
|
||||||
})
|
diagnosa_files: fileDiagnosas,
|
||||||
|
kondisi_files: fileKondisis
|
||||||
|
});
|
||||||
axios
|
axios
|
||||||
.post('/claim-requests', formData)
|
.post('/claim-requests', formData)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@@ -110,53 +154,160 @@ export default function FormRequestClaim({ member, handleSubmitSuccess }) {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Stack sx={{ marginTop: 2 }}>
|
<Stack
|
||||||
<Typography variant="body1" fontWeight={600}>
|
divider={<Divider orientation="horizontal" flexItem />}
|
||||||
Hasil Penunjang
|
spacing={4}
|
||||||
</Typography>
|
sx={{ marginY: 2 }}
|
||||||
{/* <Typography variant="body2">Hasil Lab, </Typography> */}
|
>
|
||||||
<Stack
|
{/* -------------------------------Upload Dokumen Kondisi------------------------------- */}
|
||||||
divider={<Divider orientation="horizontal" flexItem />}
|
<Stack sx={{ marginTop: 2 }}>
|
||||||
spacing={1}
|
<Typography variant="body1" fontWeight={600}>
|
||||||
sx={{ marginY: 2 }}
|
<Iconify icon="eva:file-text-fill"></Iconify> Dokumen Kondisi
|
||||||
>
|
</Typography>
|
||||||
{fileHasilPenunjangs &&
|
{/* <Typography variant="body2">Hasil Lab, </Typography> */}
|
||||||
fileHasilPenunjangs.map((file, index) => (
|
<Stack
|
||||||
<Stack direction="row" justifyContent={'space-between'} key={index}>
|
divider={<Divider orientation="horizontal" flexItem />}
|
||||||
<Typography>{file.name}</Typography>
|
spacing={1}
|
||||||
<Iconify
|
sx={{ marginY: 2 }}
|
||||||
icon="eva:trash-2-outline"
|
>
|
||||||
color={'darkred'}
|
{fileKondisis &&
|
||||||
onClick={() => {
|
fileKondisis.map((file, index) => (
|
||||||
removeFiles(fileHasilPenunjangs, index);
|
<Stack direction="row" justifyContent={'space-between'} key={index}>
|
||||||
}}
|
<Typography sx={{ color: "text.secondary" }}>{file.name}</Typography>
|
||||||
></Iconify>
|
<Iconify
|
||||||
</Stack>
|
icon="eva:trash-2-outline"
|
||||||
))}
|
color={'darkred'}
|
||||||
{/* <Stack direction="row" justifyContent={'space-between'}>
|
onClick={() => {
|
||||||
<Typography>Nama File .pdf</Typography>
|
removeKondisiFiles(fileKondisis, index);
|
||||||
<Iconify icon="eva:trash-2-outline" color={'darkred'}></Iconify>
|
}}
|
||||||
</Stack> */}
|
></Iconify>
|
||||||
|
</Stack>
|
||||||
|
))}
|
||||||
|
{/* <Stack direction="row" justifyContent={'space-between'}>
|
||||||
|
<Typography>Nama File .pdf</Typography>
|
||||||
|
<Iconify icon="eva:trash-2-outline" color={'darkred'}></Iconify>
|
||||||
|
</Stack> */}
|
||||||
|
</Stack>
|
||||||
|
{/* { JSON.stringify(filesResult) } */}
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
id="file"
|
||||||
|
ref={fileKondisiInput}
|
||||||
|
style={{ display: 'none' }}
|
||||||
|
multiple
|
||||||
|
onChange={handleKondisiInputChange}
|
||||||
|
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
|
||||||
|
/>
|
||||||
|
<LoadingButton
|
||||||
|
variant="outlined"
|
||||||
|
onClick={() => {
|
||||||
|
fileKondisiInput.current.click();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Iconify icon="eva:plus-fill" />
|
||||||
|
Add Result
|
||||||
|
</LoadingButton>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{/* -------------------------------Upload Dokumen Diagnosa------------------------------- */}
|
||||||
|
<Stack sx={{ marginTop: 2 }}>
|
||||||
|
<Typography variant="body1" fontWeight={600}>
|
||||||
|
<Iconify icon="eva:file-text-fill"></Iconify> Dokumen Diagnosa
|
||||||
|
</Typography>
|
||||||
|
{/* <Typography variant="body2">Hasil Lab, </Typography> */}
|
||||||
|
<Stack
|
||||||
|
divider={<Divider orientation="horizontal" flexItem />}
|
||||||
|
spacing={1}
|
||||||
|
sx={{ marginY: 2 }}
|
||||||
|
>
|
||||||
|
{fileDiagnosas &&
|
||||||
|
fileDiagnosas.map((file, index) => (
|
||||||
|
<Stack direction="row" justifyContent={'space-between'} key={index}>
|
||||||
|
<Typography sx={{ color: "text.secondary" }}>{file.name}</Typography>
|
||||||
|
<Iconify
|
||||||
|
icon="eva:trash-2-outline"
|
||||||
|
color={'darkred'}
|
||||||
|
onClick={() => {
|
||||||
|
removeDiagnosaFiles(fileDiagnosas, index);
|
||||||
|
}}
|
||||||
|
></Iconify>
|
||||||
|
</Stack>
|
||||||
|
))}
|
||||||
|
{/* <Stack direction="row" justifyContent={'space-between'}>
|
||||||
|
<Typography>Nama File .pdf</Typography>
|
||||||
|
<Iconify icon="eva:trash-2-outline" color={'darkred'}></Iconify>
|
||||||
|
</Stack> */}
|
||||||
|
</Stack>
|
||||||
|
{/* { JSON.stringify(filesResult) } */}
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
id="file"
|
||||||
|
ref={fileDiagnosaInput}
|
||||||
|
style={{ display: 'none' }}
|
||||||
|
multiple
|
||||||
|
onChange={handleDiagnosaInputChange}
|
||||||
|
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
|
||||||
|
/>
|
||||||
|
<LoadingButton
|
||||||
|
variant="outlined"
|
||||||
|
onClick={() => {
|
||||||
|
fileDiagnosaInput.current.click();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Iconify icon="eva:plus-fill" />
|
||||||
|
Add Result
|
||||||
|
</LoadingButton>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{/* -------------------------------Upload Dokumen Hasil Penunjang------------------------------- */}
|
||||||
|
<Stack sx={{ marginTop: 2 }}>
|
||||||
|
<Typography variant="body1" fontWeight={600}>
|
||||||
|
<Iconify icon="eva:file-text-fill"></Iconify> Dokumen Hasil Penunjang
|
||||||
|
</Typography>
|
||||||
|
{/* <Typography variant="body2">Hasil Lab, </Typography> */}
|
||||||
|
<Stack
|
||||||
|
divider={<Divider orientation="horizontal" flexItem />}
|
||||||
|
spacing={1}
|
||||||
|
sx={{ marginY: 2 }}
|
||||||
|
>
|
||||||
|
{fileHasilPenunjangs &&
|
||||||
|
fileHasilPenunjangs.map((file, index) => (
|
||||||
|
<Stack direction="row" justifyContent={'space-between'} key={index}>
|
||||||
|
<Typography sx={{ color: "text.secondary" }}>{file.name}</Typography>
|
||||||
|
<Iconify
|
||||||
|
icon="eva:trash-2-outline"
|
||||||
|
color={'darkred'}
|
||||||
|
onClick={() => {
|
||||||
|
removeFiles(fileHasilPenunjangs, index);
|
||||||
|
}}
|
||||||
|
></Iconify>
|
||||||
|
</Stack>
|
||||||
|
))}
|
||||||
|
{/* <Stack direction="row" justifyContent={'space-between'}>
|
||||||
|
<Typography>Nama File .pdf</Typography>
|
||||||
|
<Iconify icon="eva:trash-2-outline" color={'darkred'}></Iconify>
|
||||||
|
</Stack> */}
|
||||||
|
</Stack>
|
||||||
|
{/* { JSON.stringify(filesResult) } */}
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
id="file"
|
||||||
|
ref={fileHasilPenunjangInput}
|
||||||
|
style={{ display: 'none' }}
|
||||||
|
multiple
|
||||||
|
onChange={handleResultInputChange}
|
||||||
|
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
|
||||||
|
/>
|
||||||
|
<LoadingButton
|
||||||
|
variant="outlined"
|
||||||
|
onClick={() => {
|
||||||
|
fileHasilPenunjangInput.current.click();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Iconify icon="eva:plus-fill" />
|
||||||
|
Add File
|
||||||
|
</LoadingButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
{/* { JSON.stringify(filesResult) } */}
|
|
||||||
<input
|
|
||||||
type="file"
|
|
||||||
id="file"
|
|
||||||
ref={fileHasilPenunjangInput}
|
|
||||||
style={{ display: 'none' }}
|
|
||||||
multiple
|
|
||||||
onChange={handleResultInputChange}
|
|
||||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
|
|
||||||
/>
|
|
||||||
<LoadingButton
|
|
||||||
variant="outlined"
|
|
||||||
onClick={() => {
|
|
||||||
fileHasilPenunjangInput.current.click();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Iconify icon="eva:plus-fill" />
|
|
||||||
Add Result
|
|
||||||
</LoadingButton>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
|
|||||||
Reference in New Issue
Block a user