Skip to content

Commit

Permalink
Merge pull request #253 from jabardigitalservice/int/add-reservation
Browse files Browse the repository at this point in the history
set function for post reservation data
  • Loading branch information
rizfirman authored May 17, 2024
2 parents 8c4eb55 + 1d22004 commit b9d0edf
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 4 deletions.
161 changes: 157 additions & 4 deletions components/Sribaduga/DialogTambahReservasi/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
placeholder="Pilih Kategori Instansi"
class="add-reservation-select mb-4"
:error-message="errors[0]"
:options="listKategoriInstansi"
/>
</ValidationProvider>
Expand Down Expand Up @@ -312,6 +313,7 @@
placeholder="Pilih Provinsi"
class="add-reservation-select mb-4"
:error-message="errors[0]"
:options="getProvinceList"
/>
</ValidationProvider>
Expand All @@ -335,6 +337,8 @@
placeholder="Pilih Kota/Kabupaten"
class="add-reservation-select mb-4"
:error-message="errors[0]"
:disabled="disablecityList"
:options="getCityList"
/>
</ValidationProvider>
<label
Expand Down Expand Up @@ -395,6 +399,10 @@
<script>
import { mapState } from 'vuex'
import { ValidationProvider, ValidationObserver } from 'vee-validate'
import axios from 'axios'
import { formatDate } from '~/utils'
import { listKategoriInstansi } from '@/constant/sribaduga.js'
export default {
name: 'DialogTambahReservasi',
components: {
Expand Down Expand Up @@ -429,6 +437,11 @@ export default {
cityValue: '',
instanceAddress: '',
errorTicket: '',
provinceList: [],
cityList: [],
disablecityList: true,
reservationDate: null,
listKategoriInstansi,
}
},
computed: {
Expand Down Expand Up @@ -462,6 +475,22 @@ export default {
this.childrenCatagory + this.matureCatagory + this.foreignerCatagory
)
},
getProvinceList() {
return this.provinceList.map((provinceData) => {
return {
label: provinceData.name,
value: provinceData.id,
}
})
},
getCityList() {
return this.cityList.map((cityData) => {
return {
label: cityData.name,
value: cityData.id,
}
})
},
},
watch: {
Expand All @@ -474,6 +503,23 @@ export default {
}
},
},
dateValue: {
handler(val) {
this.reservationDate = val.rawDateData
},
},
provinsiValue: {
handler(val) {
if (val) {
this.disablecityList = false
this.getDataCityList()
}
},
},
},
mounted() {
this.getDataProvinceList()
},
methods: {
Expand Down Expand Up @@ -550,10 +596,117 @@ export default {
this.getTotalTicket > 0 &&
this.errorTicket === ''
) {
this.$store.commit('add_reservation/setIsOpenForm', false)
this.$store.commit('add_reservation/setRefetchCalendar', true)
this.errorTicket = ''
this.clearForm()
try {
const payload = {
attractionID: 'c64143d6-d630-4ccf-8529-483b9b737a52',
reservationDate: formatDate(this.reservationDate, 'yyyy-MM-dd'),
visitorType: 'reservation', // updated to regular & reservation
paymentMethod: 'admin',
session: Number(this.orderAndSessionValue?.session.id),
updateProfile: false,
categories: [
{
id: 'children',
name: 'Anak-anak',
qty: this.childrenCatagory,
},
{
id: 'regular',
name: 'Dewasa',
qty: this.matureCatagory,
},
{
id: 'foreigner',
name: 'Wisatawan Mancanegara',
qty: this.foreignerCatagory,
},
].filter((category) => category.qty > 0),
customerData: [
{
questionId: 'name',
question: 'Nama Lengkap',
answer: this.fullName,
},
{
questionId: 'phone',
question: 'No. Tlp',
answer: this.phoneNumber,
},
{
questionId: 'instance-category',
question: 'Kategori Instansi',
answer: this.instanceCatagory,
},
{
questionId: 'instance-name',
question: 'Nama Instansi',
answer: this.instanceName,
},
{
questionId: 'provinceId',
question: 'Provinsi',
answer: this.provinsiValue,
},
{
questionId: 'cityId',
question: 'Kota/Kabupaten',
answer: this.cityValue,
},
{
questionId: 'address-detail',
question: 'Detail Alamat Instansi',
answer: this.instanceAddress,
},
],
}
await this.$axios.post('/ticket/tms/admin/orders', payload)
this.$store.commit('add_reservation/setIsOpenForm', false)
this.$store.commit('add_reservation/setRefetchCalendar', true)
this.errorTicket = ''
this.clearForm()
} catch (error) {
console.log(error)
}
}
},
async getDataProvinceList() {
try {
const provinceResponse = await axios.get(
`${this.$config.urlMainService}/area/province`,
{
headers: {
'Api-Key': `${this.$config.apiKey}`,
},
}
)
const { data } = provinceResponse.data
this.provinceList = data
} catch (error) {
console.error(error)
}
},
async getDataCityList() {
try {
const cityResponse = await axios.get(
`${this.$config.urlMainService}/area/city`,
{
headers: {
'Api-Key': `${this.$config.apiKey}`,
},
params: {
provinceId: this.provinsiValue,
},
}
)
const { data } = cityResponse.data
this.cityList = data
} catch (error) {
console.error(error)
}
},
},
Expand Down
30 changes: 30 additions & 0 deletions constant/sribaduga.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,36 @@ export const listKategoriTiketSribaduga = [
label: 'Wisatawan Mancanegara',
},
]
export const listKategoriInstansi = [
{
value: 'TK/RA',
label: 'TK/RA',
},
{
value: 'SD/MI',
label: 'SD/MI',
},
{
value: 'SMP/MTS',
label: 'SMP/MTS',
},
{
value: 'SMA/SMK/MA',
label: 'SMA/SMK/MA',
},
{
value: 'Perguruan Tinggi',
label: 'Perguruan Tinggi',
},
{
value: 'Umum',
label: 'Umum',
},
{
value: 'Wisatawan Mancanegara',
label: 'Wisatawan Mancanegara',
},
]

export const statusSribaduga = {
all: { ...listStatusSribaduga[0] },
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export default {
publicRuntimeConfig: {
apiKey: process.env.API_KEY,
keyclockBaseUrl: process.env.KEYCLOCK_BASE_URL,
urlMainService: process.env.URL_MAIN_SERVICE,
axios: {
browserBaseURL:
process.env.BROWSER_BASE_URL + '/' + process.env.VERSION_ENDPOINT,
Expand Down

0 comments on commit b9d0edf

Please sign in to comment.