Skip to content

Commit

Permalink
feat(upload): add random seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
fu050409 committed May 21, 2024
1 parent c4bedf8 commit c4f827b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/Upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ const msg = ref<string | null>(null);
const status = ref<boolean | null>(null);
const account = accountStore.account;
// Generate random number between min and max
const random = (min: any, max: any) => Math.floor(Math.random() * (max - min + 1) + min)
async function upload() {
status.value = null;
if (!mileage.value || !datetime.value) {
status.value = false;
msg.value = 'Please fill in all fields';
return;
}
datetime.value.setSeconds(random(0, 59))
const result: { status: boolean; msg: string } = await invoke("upload", {
account: accountStore.account,
mileage: mileage.value,
Expand Down Expand Up @@ -53,13 +57,14 @@ const datetime = ref<Date | null>(null);
<span class="pi pi-minus"></span>
</template>
</InputNumber>
<Calendar placeholder="Select Date" v-model="datetime" showTime hourFormat="24" />
<Calendar placeholder="Select Date" v-model="datetime" showTime hourFormat="24" showIcon />
<Message class="w-full" :severity="status === null ? 'info' : status === true ? 'success' : 'error'"
v-if="msg" @close="msg = null">{{ msg
}}
</Message>
<div class="flex justify-between items-center">
<Button label="Logout" @click="accountStore.account = null; $router.push('/')" severity="secondary"></Button>
<Button label="Logout" @click="accountStore.account = null; $router.push('/')"
severity="secondary"></Button>
<Button type="submit" label="Upload" @click="upload"></Button>
</div>
</div>
Expand Down

0 comments on commit c4f827b

Please sign in to comment.