Skip to content

Commit

Permalink
feat: 체크인 요청 보낼 때에 cafeteriaId 같이 실어서 보냄
Browse files Browse the repository at this point in the history
  • Loading branch information
potados99 committed Feb 16, 2022
1 parent c1ff517 commit 763e57e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 40 deletions.
9 changes: 3 additions & 6 deletions src/features/checkin/CheckIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</div>

<!-- 화면 상단에 위치한 반투명 오버레이 -->
<div @click="openSettings" class="overlay dark-blur-backdrop">
<div @click="openSelection" class="overlay dark-blur-backdrop">
<div class="overlay-section-container">
<div class="overlay-section">
<div class="section-label">예약</div>
Expand All @@ -67,17 +67,14 @@
</div>

<!-- 오버레이를 누르면 나오는, 설정 팝업 -->
<v-dialog v-model="settingsDialog">
<v-dialog v-model="selectionDialog">
<v-card>
<v-toolbar dark color="dark">
<v-btn icon dark>
<v-icon>mdi-cog</v-icon>
</v-btn>
<v-toolbar-title>QR 스캐너 설정</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon dark @click="closeSettings">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-toolbar>

<v-list>
Expand All @@ -99,7 +96,7 @@

<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" block @click="closeSettings">확인</v-btn>
<v-btn color="blue darken-1" block @click="closeSelection">확인</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
Expand Down
4 changes: 2 additions & 2 deletions src/features/checkin/CheckInRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class CheckInRepository {
this.previousEventSource = eventSource;
}

async checkIn(ticket: string, gracefulInTime: boolean) {
await http.post(config.api.endpoints.checkIn, {ticket, gracefulInTime});
async checkIn(ticket: string, cafeteriaId: number, gracefulInTime: boolean) {
await http.post(config.api.endpoints.checkIn, {ticket, cafeteriaId, gracefulInTime});
}
}

Expand Down
56 changes: 56 additions & 0 deletions src/features/checkin/mixins/CafeteriaSelectionMixin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* This file is part of INU Cafeteria.
*
* Copyright 2022 INU Global App Center <potados99@gmail.com>
*
* INU Cafeteria is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* INU Cafeteria is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import Vue from 'vue';
import Cafeteria from '@/features/cafeteria/Cafeteria';

export default Vue.extend({
mounted() {
this.fetchCafeteria();
},

data() {
return {
selectionDialog: true,

allCafeteria: undefined,
selectedCafeteria: undefined,
};
},

methods: {
openSelection() {
this.selectionDialog = true;
},

closeSelection() {
this.selectionDialog = false;
},

async fetchCafeteria() {
const allCafeteria = await Cafeteria.find();
const cafeteriaSupportingBooking = allCafeteria.filter(c => c.supportBooking);

const previouslySelectedId = Number.parseInt(localStorage.getItem('qr-scanner-selected-cafeteria') ?? '1');

this.allCafeteria = cafeteriaSupportingBooking;
this.selectedCafeteria = cafeteriaSupportingBooking.find(c => c.id === previouslySelectedId); // TODO
},
},
});
3 changes: 2 additions & 1 deletion src/features/checkin/mixins/CheckInBaseMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import Vue from 'vue';
import ApiMixin from '@/core/component/common/mixins/ApiMixin';
import ScannerMixin from '@/features/checkin/mixins/ScannerMixin';
import CafeteriaSelectionMixin from '@/features/checkin/mixins/CafeteriaSelectionMixin';

export default Vue.extend({
mixins: [ApiMixin, ScannerMixin],
mixins: [ApiMixin, ScannerMixin, CafeteriaSelectionMixin],
});
30 changes: 0 additions & 30 deletions src/features/checkin/mixins/CheckInContextMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,8 @@ import CheckInRepository from '@/features/checkin/CheckInRepository';
export default Vue.extend({
mixins: [CheckInBaseMixin],

mounted() {
this.fetchCafeteria();
},

data() {
return {
settingsDialog: true,

allCafeteria: undefined,
selectedCafeteria: undefined,

timer: undefined,
context: Context.of({}),
};
},
Expand All @@ -55,24 +45,4 @@ export default Vue.extend({
localStorage.setItem('qr-scanner-selected-cafeteria', selected.id.toString());
},
},

methods: {
openSettings() {
this.settingsDialog = true;
},

closeSettings() {
this.settingsDialog = false;
},

async fetchCafeteria() {
const allCafeteria = await Cafeteria.find();
const cafeteriaSupportingBooking = allCafeteria.filter(c => c.supportBooking);

const previouslySelectedId = Number.parseInt(localStorage.getItem('qr-scanner-selected-cafeteria') ?? '1');

this.allCafeteria = cafeteriaSupportingBooking;
this.selectedCafeteria = cafeteriaSupportingBooking.find(c => c.id === previouslySelectedId); // TODO
},
},
});
5 changes: 4 additions & 1 deletion src/features/checkin/mixins/CheckInRequestMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ export default Vue.extend({
*/
async tryCheckInAndGetError(ticket: string, gracefulInTime: boolean): Promise<HttpError | undefined> {
try {
await CheckInRepository.checkIn(ticket, gracefulInTime);
const cafeteriaId = this.selectedCafeteria?.id;
assert(cafeteriaId);

await CheckInRepository.checkIn(ticket, cafeteriaId, gracefulInTime);

playSound('/sounds/success.mp3').then();

Expand Down

0 comments on commit 763e57e

Please sign in to comment.