Added check for submission.
This commit is contained in:
parent
e0433753ea
commit
a8168768a8
|
@ -89,17 +89,20 @@ A high-level overview of the submission process is as follows:
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref, Ref } from 'vue';
|
import { onMounted, ref, Ref } from 'vue';
|
||||||
import { getGymFromRoute } from 'src/router/gym-routing';
|
import {getGymFromRoute, getGymRoute} from 'src/router/gym-routing';
|
||||||
import SlimForm from 'components/SlimForm.vue';
|
import SlimForm from 'components/SlimForm.vue';
|
||||||
import api from 'src/api/main';
|
import api from 'src/api/main';
|
||||||
import { Gym } from 'src/api/main/gyms';
|
import { Gym } from 'src/api/main/gyms';
|
||||||
import { Exercise } from 'src/api/main/exercises';
|
import { Exercise } from 'src/api/main/exercises';
|
||||||
|
import {useRouter} from 'vue-router';
|
||||||
|
|
||||||
interface Option {
|
interface Option {
|
||||||
value: string;
|
value: string;
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const gym: Ref<Gym | undefined> = ref<Gym>();
|
const gym: Ref<Gym | undefined> = ref<Gym>();
|
||||||
const exercises: Ref<Array<Exercise> | undefined> = ref<Array<Exercise>>();
|
const exercises: Ref<Array<Exercise> | undefined> = ref<Array<Exercise>>();
|
||||||
const exerciseOptions: Ref<Array<Option>> = ref([]);
|
const exerciseOptions: Ref<Array<Option>> = ref([]);
|
||||||
|
@ -116,6 +119,8 @@ let submissionModel = ref({
|
||||||
const selectedVideoFile: Ref<File | undefined> = ref<File>();
|
const selectedVideoFile: Ref<File | undefined> = ref<File>();
|
||||||
const weightUnits = ['KG', 'LBS'];
|
const weightUnits = ['KG', 'LBS'];
|
||||||
|
|
||||||
|
const submitting = ref(false);
|
||||||
|
|
||||||
// TODO: Make it possible to pass the gym to this via props instead.
|
// TODO: Make it possible to pass the gym to this via props instead.
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -143,6 +148,7 @@ function validateForm() {
|
||||||
|
|
||||||
async function onSubmitted() {
|
async function onSubmitted() {
|
||||||
if (!selectedVideoFile.value || !gym.value) throw new Error('Invalid state.');
|
if (!selectedVideoFile.value || !gym.value) throw new Error('Invalid state.');
|
||||||
|
submitting.value = true;
|
||||||
submissionModel.value.videoId = await api.gyms.submissions.uploadVideoFile(
|
submissionModel.value.videoId = await api.gyms.submissions.uploadVideoFile(
|
||||||
gym.value,
|
gym.value,
|
||||||
selectedVideoFile.value
|
selectedVideoFile.value
|
||||||
|
@ -157,6 +163,8 @@ async function onSubmitted() {
|
||||||
submission.id
|
submission.id
|
||||||
);
|
);
|
||||||
console.log(completedSubmission);
|
console.log(completedSubmission);
|
||||||
|
submitting.value = false;
|
||||||
|
await router.push(getGymRoute(gym.value));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue