From 39c38c737114dc7f946b1895b2a4ba27a5546c60 Mon Sep 17 00:00:00 2001
From: HampusM <hampus@hampusmat.com>
Date: Tue, 6 Jul 2021 13:07:07 +0200
Subject: Migrated frontend to typescript

---
 packages/client/src/views/RepositoryCommit.vue | 28 ++++++++++++++------------
 1 file changed, 15 insertions(+), 13 deletions(-)

(limited to 'packages/client/src/views/RepositoryCommit.vue')

diff --git a/packages/client/src/views/RepositoryCommit.vue b/packages/client/src/views/RepositoryCommit.vue
index a2caa74..50ec9ad 100644
--- a/packages/client/src/views/RepositoryCommit.vue
+++ b/packages/client/src/views/RepositoryCommit.vue
@@ -49,16 +49,18 @@
 	</div>
 </template>
 
-<script>
-import BaseBreadcrumb from "@/components/BaseBreadcrumb";
-import CommitPatch from "@/components/CommitPatch";
-import Loading from "vue-loading-overlay";
-import BaseErrorMessage from "@/components/BaseErrorMessage";
-import { ref } from "vue";
+<script lang="ts">
+import { defineComponent, Ref, ref } from "vue";
 import { format } from "date-fns";
-import fetchData from "@/util/fetch";
+import fetchData from "../util/fetch";
+
+import BaseBreadcrumb from "../components/BaseBreadcrumb.vue";
+import CommitPatch from "../components/CommitPatch.vue";
+import Loading from "vue-loading-overlay";
+import BaseErrorMessage from "../components/BaseErrorMessage.vue";
+import { getParam } from "../util/util";
 
-export default {
+export default defineComponent({
 	name: "RepositoryCommit",
 	components: {
 		BaseBreadcrumb,
@@ -68,10 +70,10 @@ export default {
 	},
 	setup() {
 		const commit = ref(null);
-		const is_loading = ref(true);
-		const fetch_failed = ref(null);
+		const is_loading: Ref<boolean> = ref(true);
+		const fetch_failed: Ref<string> = ref("");
 
-		const fetchCommit = async(repository, commit_id) => {
+		const fetchCommit = async(repository: string, commit_id: string) => {
 			const commit_data = await fetchData(`repos/${repository}/log/${commit_id}`, fetch_failed, is_loading, "commit");
 
 			if(commit_data) {
@@ -83,9 +85,9 @@ export default {
 		return { commit, is_loading, fetch_failed, fetchCommit };
 	},
 	created() {
-		this.fetchCommit(this.$router.currentRoute._rawValue.params.repo, this.$router.currentRoute._rawValue.params.commit);
+		this.fetchCommit(getParam(this.$route.params, "repo"), getParam(this.$route.params, "commit"));
 	}
-};
+});
 </script>
 
 <style lang="scss">
-- 
cgit v1.2.3-18-g5258

