tambah listing file di client portal

This commit is contained in:
2024-02-05 16:57:52 +07:00
parent a9c14088c6
commit b9a9b53918
4 changed files with 163 additions and 1 deletions

View File

@@ -215,6 +215,7 @@ class CorporateMemberController extends Controller
'requestLogMedicalPlans:request_log_daily_monitoring_id,plan,type'
],
'service:code,name',
'files',
])
->find($request_log_id, ['id', 'submission_date', 'discharge_date', 'member_id', 'service_code', 'organization_id']);

View File

@@ -15,6 +15,33 @@ class DataServiceMonitoring extends JsonResource
*/
public function toArray($request)
{
$files = [];
$filesFinalLogResult = [];
$filesFinalLogDiagnosis = [];
$filesFinalLogKondisi = [];
if (count($this->files)>0){
foreach ($this->files as $key => $value) {
if($value->type == 'final-log-result'){
array_push($filesFinalLogResult, $value);
};
if($value->type == 'final-log-diagnosis'){
array_push($filesFinalLogDiagnosis, $value);
}
if($value->type == 'final-log-kondisi'){
array_push($filesFinalLogDiagnosis, $value);
}
}
$files = [
'result' => $filesFinalLogResult,
'diagnosis' => $filesFinalLogDiagnosis,
'kondisi' => $filesFinalLogKondisi,
];
}
return [
'companyName' => $this->member->currentCorporate->name ?? null,
'serviceCode' => $this->service_code ?? null,
@@ -24,6 +51,7 @@ class DataServiceMonitoring extends JsonResource
'phoneNumber' => $this->person->phone ?? null,
'email' => $this->member->email ?? ($this->member->person->email ?? null),
'serviceName' => $this->service->name ?? ($this->service_code ?? null),
'files' => $files,
'benefits' => collect($this->requestLogBenefits)->map(function ($requestLogBenefit) {
return [
'amountIncurred' => $requestLogBenefit->amount_incurred,

View File

@@ -200,7 +200,7 @@ class Member extends Model
public function requestLogs()
{
return $this->hasMany(RequestLog::class);
return $this->hasMany(RequestLog::class, 'member_id', 'id');
}
/* -------------------------------------------------------------------------- */

View File

@@ -129,6 +129,23 @@ type ServiceMonitoringProps = {
mainDiagnose: string;
comparativeDiagnosis: string;
serviceName: string;
files: {
result: {
type: string;
original_name: string;
url: string;
}[];
diagnosis: {
type: string;
original_name: string;
url: string;
}[];
kondisi: {
type: string;
original_name: string;
url: string;
}[];
};
benefits: {
amountIncurred: number;
amountApproved: number;
@@ -439,6 +456,122 @@ export default function ServiceMonitoring() {
</Typography>
</Grid>
</Grid>
<Grid item container xs={12} spacing={1.5}>
<Grid item xs={12}>
<Typography variant="subtitle2" color={'grey.600'}>
{loading ? (
<Skeleton animation={'wave'} width={200} />
) : (
'Files Result'
)}
</Typography>
</Grid>
<Grid item>
{loading ? (
<Skeleton animation="wave" width={300} />
) : data && data.files && data.files.result.length > 0 ?
(
data.files.result.map((file, index) =>
(
(
<Stack direction="column" spacing={2} key={index}>
<Stack direction="row" spacing={1} sx={{color: '#19BBBB'}}>
<a
href={file.url}
download={file.original_name ? file.original_name : 'test'}
style={{ cursor: 'pointer', textDecoration: 'none', color: '#19BBBB' }}
target="_blank"
>
<Typography variant="body2" gutterBottom>{file.original_name ? file.original_name : '-'}</Typography>
</a>
</Stack>
</Stack>
)
)
)
) : (
<Typography variant="subtitle1" color={'grey.800'}>
-
</Typography>
)}
</Grid>
<Grid item xs={12}>
<Typography variant="subtitle2" color={'grey.600'}>
{loading ? (
<Skeleton animation={'wave'} width={200} />
) : (
'Files Diagnosis'
)}
</Typography>
</Grid>
<Grid item>
{loading ? (
<Skeleton animation="wave" width={300} />
) : data && data.files && data.files.diagnosis.length > 0 ?
(
data.files.diagnosis.map((file, index) =>
(
(
<Stack direction="column" spacing={2} key={index}>
<Stack direction="row" spacing={1} sx={{color: '#19BBBB'}}>
<a
href={file.url}
download={file.original_name ? file.original_name : 'test'}
style={{ cursor: 'pointer', textDecoration: 'none', color: '#19BBBB' }}
target="_blank"
>
<Typography variant="body2" gutterBottom>{file.original_name ? file.original_name : '-'}</Typography>
</a>
</Stack>
</Stack>
)
)
)
) : (
<Typography variant="subtitle1" color={'grey.800'}>
-
</Typography>
)}
</Grid>
<Grid item xs={12}>
<Typography variant="subtitle2" color={'grey.600'}>
{loading ? (
<Skeleton animation={'wave'} width={200} />
) : (
'Files Kondisi'
)}
</Typography>
</Grid>
<Grid item>
{loading ? (
<Skeleton animation="wave" width={300} />
) : data && data.files && data.files.kondisi.length > 0 ?
(
data.files.kondisi.map((file, index) =>
(
(
<Stack direction="column" spacing={2} key={index}>
<Stack direction="row" spacing={1} sx={{color: '#19BBBB'}}>
<a
href={file.url}
style={{ cursor: 'pointer', textDecoration: 'none', color: '#19BBBB' }}
target="_blank"
>
<Typography variant="body2" gutterBottom>{file.original_name ? file.original_name : '-'}</Typography>
</a>
</Stack>
</Stack>
)
)
)
) : (
<Typography variant="subtitle1" color={'grey.800'}>
-
</Typography>
)}
</Grid>
</Grid>
</Grid>
</Grid>
</Card>