Fakultas Ilmu Komputer UI

Commit 5f5cdf27 authored by Irwanto's avatar Irwanto
Browse files

Merge branch 'pbi-monitoring-case' into 'staging'

PBI monitoring case

See merge request !25
parents 4f4c24b0 92efd513
Pipeline #43019 passed with stages
in 12 minutes and 42 seconds
......@@ -162,7 +162,13 @@ const ContactInvestigationFormStep4 = () => {
const investigationResponse = formData.is_edit ?
await main.editInvestigationCase(investigationCaseData, formData.id) :
await main.createInvestigationCase(investigationCaseData);
console.log(investigationResponse)
if (!formData.is_edit && form.fields.is_referral_needed.value) {
await main.createMonitoringCase({
"investigation_case": investigationResponse.data.id,
})
}
setIsLoading(false);
global.setCache(initialCacheState);
navigation.navigate('contact-investigation-finish');
......
......@@ -30,7 +30,10 @@ const MonitoringMedicalCheck = () => {
outcome: form.fields.checked.value ? form.fields.check_result.value : null
}, global.cache.monitoringCaseFormData.investigation_case.id);
const checkDate: Date = form.fields.check_date.value;
const checkDateString = checkDate.toISOString().slice(0, 10);
const monitoringResp = await global.services.main.updateMonitoringCase({
checking_date: form.fields.checked.value ? checkDateString : null,
is_checked: form.fields.checked.value,
}, global.cache.monitoringCaseFormData.id);
......
......@@ -36,7 +36,6 @@ const MonitoringMedicalResume = () => {
medication_outcome: form.fields.result.value
}, global.cache.monitoringCaseFormData.id);
console.log(resp)
if (resp.status == 200) {
navigation.navigate('monitoring-finish');
}
......
......@@ -188,6 +188,18 @@ export default function useMainService(token: string) {
return fetchWithAuthentication(endpoint.slice(0, -1), Method.GET);
}
async function createMonitoringCase(body: object) {
const endPoint = END_POINTS.MONITORING_CASES([
null,
null,
])
return fetchWithAuthentication(
endPoint,
Method.POST,
body,
);
}
async function listMonitoringCases(page: number) {
if (page === 1) {
const endpoint = END_POINTS.MONITORING_CASES([null, null]);
......@@ -233,6 +245,7 @@ export default function useMainService(token: string) {
listPositiveCases,
filterPositiveCase,
// Monitoring Case
createMonitoringCase,
listMonitoringCases,
filterMonitoringCase,
updateMonitoringCase,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment