Skip to content

Commit

Permalink
refactor: update for new api routes
Browse files Browse the repository at this point in the history
  • Loading branch information
supersonictw committed Oct 29, 2024
1 parent e7993ea commit 0d3205a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
36 changes: 21 additions & 15 deletions src/views/AdminJoinView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
<li>申請時間:{{ dateParsedCreatedAt }}</li>
</ul>
<ul class="mb-3">
<li>IP 位址:{{ application.ip_address }}</li>
<li>IP 位址:{{ application.ipAddress }}</li>
<li>IP 地理資訊:
<ul class="pl-3">
<li>國家:{{ application.ip_geolocation.country }}</li>
<li>城市:{{ application.ip_geolocation.city }}</li>
<li>時區:{{ application.ip_geolocation.timezone }}</li>
<li>國家:{{ application.ipGeolocation.country }}</li>
<li>城市:{{ application.ipGeolocation.city }}</li>
<li>時區:{{ application.ipGeolocation.timezone }}</li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -66,7 +66,7 @@
</li>
</ul>
</p>
<div v-if="!application.approval_by" class="flex justify-end mt-4">
<div v-if="!application.commitBy" class="flex justify-end mt-4">
<button
class="flex items-center justify-center bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 mx-1 rounded-full"
@click="approval">
Expand All @@ -79,7 +79,7 @@
</button>
</div>
<p v-else class="mt-2 text-amber-600">
已由 {{ application.approval_by }} 於 {{ dateParsedApprovalAt }} 許可
已由 {{ application.commitBy }} 於 {{ dateParsedApprovalAt }} 簽署 {{ application.commitState ? '許可' : '否決' }}
</p>
</div>
</div>
Expand Down Expand Up @@ -133,18 +133,24 @@ export default {
}
},
async approval() {
const options = {params: {code: this.query}};
const options = {params: {
code: this.query,
state: "true",
}};
try {
await this.$axios.patch("application", null, options)
await this.$axios.patch("applications", null, options)
await this.submit()
} catch (e) {
console.error(e)
}
},
async reject() {
const options = {params: {code: this.query}};
const options = {params: {
code: this.query,
state: "false",
}};
try {
await this.$axios.delete("application", options)
await this.$axios.patch("applications", null, options)
this.application = {}
} catch (e) {
console.error(e)
Expand All @@ -154,24 +160,24 @@ export default {
computed: {
uaParsed() {
const {
user_agent: uaString,
userAgent: uaString,
} = this.application;
return uaParser(uaString);
},
dateParsedCreatedAt() {
const {
created_at: createdAt,
createdAt,
} = this.application;
return this.dateToHuman(
createdAt * 1000,
createdAt,
);
},
dateParsedApprovalAt() {
const {
approval_at: approvalAt,
commitAt,
} = this.application;
return this.dateToHuman(
approvalAt * 1000,
commitAt,
);
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/AdminRoomView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default {
return;
}
try {
const xhr = await this.$axios.get('/admin-room');
const xhr = await this.$axios.get('/admin-rooms');
this.url = xhr.data.url;
this.password = xhr.data.password;
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/JoinChatView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default {
form.set('slug', this.code);
form.set('captcha', this.captcha);
try {
const xhr = await this.$axios.post('application', form)
const xhr = await this.$axios.post("applications", form)
this.ready = true;
this.secret = xhr.data.code;
} catch (e) {
Expand Down

0 comments on commit 0d3205a

Please sign in to comment.