update bugs upload file

This commit is contained in:
2023-09-27 15:04:34 +07:00
parent 23ce443b52
commit 975c5169e3
5 changed files with 17 additions and 9 deletions

View File

@@ -109,7 +109,7 @@ class ClaimRequestController extends Controller
}
if ($request->hasFile('kondisi_files')) {
foreach ($request->result_files as $file) {
foreach ($request->kondisi_files as $file) {
$pathFile = File::storeFile('claim-kondisi', $newClaimRequest->id, $file);
$newClaimRequest->files()->updateOrCreate([
'type' => 'claim-kondisi',
@@ -137,7 +137,8 @@ class ClaimRequestController extends Controller
$claimRequest->load([
'histories' => function ($history) {
$history->latest();
}
},
'files',
]);
return Helper::responseJson(data: ClaimRequestShowResource::make($claimRequest));

View File

@@ -3,6 +3,7 @@
namespace Modules\HospitalPortal\Transformers;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Str;
class ClaimRequestShowResource extends JsonResource
{
@@ -25,6 +26,12 @@ class ClaimRequestShowResource extends JsonResource
'histories' => $histories
];
}
// Map Files by type
$filesGroupByType = $this->files->mapToGroups(function($file) {
return [Str::slug($file->type, '_') => $file];
});
$data['files_by_type'] = $filesGroupByType;
return $data;
}

View File

@@ -291,8 +291,8 @@ const DialogDetailClaim = ({ title, openDialog, setOpenDialog, data }: MuiDialog
spacing={1}
sx={{ marginY: 2 }}
>
{claim.files_by_type?.result &&
claim.files_by_type.result.map((file, index) => (
{claim.files_by_type?.claim_result &&
claim.files_by_type.claim_result.map((file, index) => (
<Stack direction="row" justifyContent={'space-between'} key={index}>
<a href={file.url} target="_blank" style={{ textDecoration: 'none' }}>
<Typography sx={{ color: 'text.secondary' }} variant="subtitle2">

View File

@@ -292,8 +292,8 @@ const DialogDetailClaim = ({ title, openDialog, setOpenDialog, data }: MuiDialog
spacing={1}
sx={{ marginY: 2 }}
>
{claim.files_by_type?.result &&
claim.files_by_type.result.map((file, index) => (
{claim.files_by_type?.claim_result &&
claim.files_by_type.claim_result.map((file, index) => (
<Stack direction="row" justifyContent={'space-between'} key={index}>
<a href={file.url} target="_blank" style={{ textDecoration: 'none' }}>
<Typography sx={{ color: 'text.secondary' }} variant="subtitle2">

View File

@@ -210,7 +210,7 @@ export default function FormRequestClaim({ member, handleSubmitSuccess }) {
style={{ display: 'none' }}
multiple
onChange={handleKondisiInputChange}
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain, application/pdf"
/>
<LoadingButton
variant="outlined"
@@ -260,7 +260,7 @@ export default function FormRequestClaim({ member, handleSubmitSuccess }) {
style={{ display: 'none' }}
multiple
onChange={handleDiagnosaInputChange}
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain, application/pdf"
/>
<LoadingButton
variant="outlined"
@@ -310,7 +310,7 @@ export default function FormRequestClaim({ member, handleSubmitSuccess }) {
style={{ display: 'none' }}
multiple
onChange={handleResultInputChange}
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain, application/pdf"
/>
<LoadingButton
variant="outlined"