Files
jhipster-question-bank/src/main/webapp/app/entities/exam-attempt/exam-attempt-details.component.ts
T

46 lines
1.3 KiB
TypeScript

import { type Ref, defineComponent, inject, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import { useAlertService } from '@/shared/alert/alert.service';
import { useDateFormat } from '@/shared/composables';
import { type IExamAttempt } from '@/shared/model/exam-attempt.model';
import ExamAttemptService from './exam-attempt.service';
export default defineComponent({
name: 'ExamAttemptDetails',
setup() {
const dateFormat = useDateFormat();
const examAttemptService = inject('examAttemptService', () => new ExamAttemptService());
const alertService = inject('alertService', () => useAlertService(), true);
const route = useRoute();
const router = useRouter();
const previousState = () => router.go(-1);
const examAttempt: Ref<IExamAttempt> = ref({});
const retrieveExamAttempt = async examAttemptId => {
try {
const res = await examAttemptService().find(examAttemptId);
examAttempt.value = res;
} catch (error) {
alertService.showHttpError(error.response);
}
};
if (route.params?.examAttemptId) {
retrieveExamAttempt(route.params.examAttemptId);
}
return {
...dateFormat,
examAttempt,
previousState,
t$: useI18n().t,
};
},
});