Skip to content

Commit

Permalink
Merge pull request #113 from jabardigitalservice/refactor/integration…
Browse files Browse the repository at this point in the history
…-popup-input-id-span

refactor : integration popup input id span
  • Loading branch information
marsellavaleria19 authored Oct 3, 2023
2 parents 2db5168 + d62843d commit 233532f
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 17 deletions.
7 changes: 4 additions & 3 deletions components/Aduan/Detail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
:data-dialog="dataDialog"
:show-popup="isShowPopupInputIdSpan"
@close="closePopupHandle()"
@submit="submitInputIdSpanHandle"
/>
<DialogConfirmation
:data-dialog="dataDialog"
Expand Down Expand Up @@ -322,13 +323,13 @@ export default {
try {
const response = await this.$axios.get(`/warga/complaints/${this.$route.params.id}`)
const dataDetailComplaint = response.data.data
dataDetailComplaint.complaint_status = this.complaintStatus[dataDetailComplaint?.complaint_status_id]
if (this.typeAduan.aduanDialihkanSpanLapor.id === this.typeAduanPage) {
dataDetailComplaint.complaint_status_id = (!dataDetailComplaint.diverted_to_span_at && !dataDetailComplaint.sp4n_created_at) || 'no-id-span'
dataDetailComplaint.complaint_status_id = !dataDetailComplaint.sp4n_id ? 'no-id-span' : dataDetailComplaint.complaint_status_id
}
this.detailComplaint = {
...dataDetailComplaint,
created_at: formatDate(dataDetailComplaint?.created_at, 'dd/MM/yyyy - HH:mm'),
complaint_status: this.complaintStatus[dataDetailComplaint?.complaint_status_id]
created_at: formatDate(dataDetailComplaint?.created_at, 'dd/MM/yyyy - HH:mm')
}

this.listPhoto = dataDetailComplaint?.photos
Expand Down
22 changes: 13 additions & 9 deletions components/Aduan/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<!-- eslint-disable-next-line vue/valid-v-slot -->
<template #item.action="{item}">
<BaseTableAction
:list-menu-pop-over="menuTableActionHandle()"
:list-menu-pop-over="menuTableActionHandle(item?.status_id)"
@detail="goToPageDetailHandle(item)"
@verify="showPopupVerificationHandle(item,'verification')"
@failed="showPopupVerificationHandle(item,'failed')"
Expand All @@ -108,9 +108,9 @@
</template>
</BaseTabGroup>
<DialogConfirmation :data-dialog="dataDialog" :show-popup="isShowPopupConfirmationVerification" @close="closePopupHandle()" @submit="submitPopupVerificationHandle" />
<DialogInformation :data-dialog="dataDialog" :show-popup="isShowPopupInformation" :icon-popup="iconPopup" @close="closePopupInformationHandle()" @submit="submitPopupVerificationHandle" />
<DialogInformation :data-dialog="dataDialog" :show-popup="isShowPopupInformation" :icon-popup="iconPopup" @close="closePopupInformationHandle()" @submit="submitRetryHandle" />
<DialogInputTextArea :data-dialog="dataDialog" :show-popup="isShowPopupConfirmationFailedVerification" @close="closePopupHandle()" @submit="submitPopupVerificationHandle" />
<DialogInputText :data-dialog="dataDialog" :show-popup="isShowPopupInputIdSpan" @close="closePopupHandle()" />
<DialogInputText :data-dialog="dataDialog" :show-popup="isShowPopupInputIdSpan" @close="closePopupHandle()" @submit="submitInputIdSpanHandle" />
<DialogLoading :show-popup="isLoading" />
</div>
</template>
Expand Down Expand Up @@ -148,9 +148,9 @@ export default {
return {
menuTableAction: [
{ menu: 'Lihat Detail Aduan', value: 'detail', typeAduan: ['all'] },
{ menu: 'Terverifikasi', value: 'verify', typeAduan: [typeAduan.aduanMasuk.props] },
{ menu: 'Gagal Diverifikasi', value: 'failed', typeAduan: [typeAduan.aduanMasuk.props] },
{ menu: 'Tambahkan ID SP4N Lapor', value: 'add-span', typeAduan: [typeAduan.aduanDialihkanSpanLapor.props] }
{ menu: 'Terverifikasi', value: 'verify', typeAduan: [typeAduan.aduanMasuk.props], complaintStatus: 'unverified' },
{ menu: 'Gagal Diverifikasi', value: 'failed', typeAduan: [typeAduan.aduanMasuk.props], complaintStatus: 'unverified' },
{ menu: 'Tambahkan ID SP4N Lapor', value: 'add-span', typeAduan: [typeAduan.aduanDialihkanSpanLapor.props], complaintStatus: 'no-id-span' }
],
listDataComplaint: [],
listDataCategory: [],
Expand Down Expand Up @@ -199,6 +199,7 @@ export default {
const listDataStatisticComplaint = responseListStatisticComplaint.data.data
this.listStatisticComplaint = listDataStatisticComplaint.filter(item => this.complaintStatus[item.id].typeAduan.includes(this.typeAduanPage) && item.id === this.complaintStatus[item.id].id)
const { data } = responseListComplaint.data
this.listDataComplaint = data?.data || []
if (this.listDataComplaint.length) {
this.pagination.disabled = false
Expand All @@ -219,12 +220,15 @@ export default {
computed: {
listData () {
return this.listDataComplaint.map((item) => {
if (this.typeAduan.aduanDialihkanSpanLapor.props === this.typeAduanPage) {
item.complaint_status_id = !item.sp4n_id ? 'no-id-span' : item.complaint_status_id
}
return {
...item,
category: item.complaint_category.name,
status: this.complaintStatus[item.complaint_status.id].name,
created_at: formatDate(item.created_at || '', 'dd/MM/yyyy HH:mm'),
status_id: item.complaint_status.id,
status_id: item.complaint_status_id,
sp4n_id: item.sp4n_id || 'Belum ada',
diverted_to_span_at: item.diverted_to_span_at ? formatDate(item.diverted_to_span_at || '', 'dd/MM/yyyy HH:mm') : 'Belum ada',
sp4n_created_at: item.sp4n_created_at ? formatDate(item.sp4n_created_at || '', 'dd/MM/yyyy HH:mm') : 'Belum ada'
Expand Down Expand Up @@ -353,8 +357,8 @@ export default {
return 'text-gray-900'
}
},
menuTableActionHandle () {
return this.menuTableAction.filter(item => item.typeAduan.includes('all') || item.typeAduan.includes(this.typeAduanPage))
menuTableActionHandle (complaintStatus) {
return this.menuTableAction.filter(item => item.typeAduan.includes('all') || (item.typeAduan.includes(this.typeAduanPage) && complaintStatus === item.complaintStatus))
},
getTotalStatistic () {
const total = this.listStatisticComplaint.reduce((accumulator, object) => {
Expand Down
4 changes: 2 additions & 2 deletions components/Base/Dialog/Footer/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export default {
}
},
methods: {
submitButtonHandle (dataDialog = null) {
submitButtonHandle () {
if (!this.showCancelButton) {
this.$emit('close')
} else {
this.$emit('submit', dataDialog)
this.$emit('submit')
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/Dialog/InputText/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default {
this.isSubmit = true
const isDataValid = await this.$refs.form.validate()
if (isDataValid) {
this.$emit('submit', { ...this.dataDialog, note: this.fieldInputText, status: 'failed' })
this.$emit('submit', { subDescription: this.dataDialog.subDescription, valueText: this.fieldInputText })
this.fieldInputText = ''
this.isInputDirty = false
this.isSubmit = false
Expand Down
65 changes: 63 additions & 2 deletions mixins/popup-aduan-masuk.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export default {
name: ''
},
complaintNote: '',
isLoading: false
isLoading: false,
typeDialog: '',
idApi: ''
}
},
methods: {
Expand All @@ -40,19 +42,51 @@ export default {
labelButton: 'Verifikasi Aduan Ini'
})
this.isShowPopupConfirmationVerification = true
this.typeDialog = 'verificationComplaint'
} else {
this.setDataDialog({
title: 'Konfirmasi Gagal Diverifikasi',
description: 'No. Aduan',
labelButton: 'Konfirmasi'
})
this.isShowPopupConfirmationFailedVerification = true
this.typeDialog = 'failedComplaint'
}
},
showPopupInputIdSpanHandle (dataComplaint) {
this.setDataDialog({ title: 'Tambahkan ID SP4N Lapor', description: 'No.Aduan', subDescription: dataComplaint.complaint_id, labelInput: 'ID SP4N Lapor', placeholder: 'Masukkan ID SP4N Lapor', labelButton: 'Tambahkan' })
this.idApi = dataComplaint.id
this.typeDialog = 'addIdSpan'
this.setDataDialog({
...this.setDataDialogConfirmation('Tambahkan ID SP4N Lapor',
'No.Aduan', dataComplaint.complaint_id, 'Tambahkan'),
labelInput: 'ID SP4N Lapor',
placeholder: 'Masukkan ID SP4N Lapor'
})
this.isShowPopupInputIdSpan = true
},
submitInputIdSpanHandle (item) {
this.isShowPopupInputIdSpan = false
let dataDialogInformation = { }
dataDialogInformation = {
...this.setDataDialogInformation('ID SP4N Lapor', item.subDescription),
success: this.setSucessFailedInformationHandle('ID SP4N Lapor berhasil ditambah', true),
failed: this.setSucessFailedInformationHandle('ID SP4N Lapor gagal ditambah', false)
}
this.integrationPopupHandle(dataDialogInformation, { sp4n_id: item.valueText }, 'add-sp4n')
},
setDataDialogConfirmation (title, description, subDescription, labelButton) {
return { title, description, subDescription, labelButton }
},
setDataDialogInformation (title, subDescription) {
return { title, subDescription }
},
setSucessFailedInformationHandle (description, success = true) {
if (success) {
return { description, labelButton: 'Saya Mengerti', showCancelButton: false }
} else {
return { description, labelButton: 'Coba Lagi' }
}
},
async submitPopupVerificationHandle (paramDialog) {
this.isShowPopupConfirmationVerification = false
this.isShowPopupConfirmationFailedVerification = false
Expand Down Expand Up @@ -81,6 +115,33 @@ export default {
}
this.isShowPopupInformation = true
},
async integrationPopupHandle (paramDialog, paramsInputRequest, pathApi) {
this.dataDialog.title = paramDialog.title
this.dataDialog.subDescription = paramDialog.subDescription
this.isLoading = true
try {
await this.$axios.patch(`/warga/complaints/${this.idApi}/${pathApi}`, { ...paramsInputRequest, user_id: this.$auth?.user?.identifier })
this.setDataDialog({ ...paramDialog.success })
this.setIconPopup({ name: 'check-mark-circle', fill: '#069550' })
} catch {
this.setDataDialog({ ...paramDialog.failed })
this.setIconPopup({ name: 'times-circle', fill: '#EF5350' })
} finally {
this.isLoading = false
}
this.isShowPopupInformation = true
},
submitRetryHandle () {
switch (this.typeDialog) {
case 'verificationComplaint':
return this.submitPopupVerificationHandle(this.dataDialog)
case 'failedComplaint':
return this.submitPopupVerificationHandle(this.dataDialog)
case 'addIdSpan' : {
return this.submitInputIdSpanHandle(this.dataDialog)
}
}
},
setDataDialog (newDataDialog) {
this.dataDialog = { ...this.dataDialog, ...newDataDialog }
},
Expand Down

0 comments on commit 233532f

Please sign in to comment.