Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Raajheer1 committed Oct 1, 2024
1 parent e742a29 commit 2649303
Show file tree
Hide file tree
Showing 10 changed files with 387 additions and 111 deletions.
2 changes: 0 additions & 2 deletions src/components/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
</template>

<script setup lang="ts">
import { defineProps } from "vue";
const props = defineProps<{
transparent?: boolean;
}>();
Expand Down
59 changes: 59 additions & 0 deletions src/components/profile/ActionLog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<div class="border-b">
<h3 class="font-bold">Action Log</h3>
</div>
<div class="m-5">
<div v-if="fetching" class="m-5">
<Spinner />
</div>
<div v-else>
<div v-if="actionLogEntries.length === 0">
<h3>No record found. If you believe this was an error please make a ticket.</h3>
</div>
<div v-else class="relative overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right text-gray-500">
<thead class="text-xs text-gray-700 uppercase bg-gray-100">
<tr>
<th scope="col" class="px-6 py-3">Entry</th>
<th scope="col" class="px-6 py-3">Date</th>
<th scope="col" class="px-6 py-3">Added By</th>
</tr>
</thead>
<tbody>
<tr v-for="(ale, idx) in actionLogEntries" :key="idx" class="bg-white border-b">
<th scope="row" class="text-wrap px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
{{ ale.entry }}
</th>
<td class="px-6 py-4">
{{ new Date(ale.created_at).toLocaleDateString() }}
</td>
<td class="px-6 py-4">
{{ ale.created_by }}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import { ActionLog } from "@/types";
import useUserStore from "@/stores/user";
import Spinner from "@/components/animations/Spinner.vue";
const userStore = useUserStore();
const actionLogEntries = ref<ActionLog[]>([]);
const fetching = ref<boolean>(true);
onMounted(async () => {
actionLogEntries.value = await userStore.fetchActionLog(userStore.self.cid);
fetching.value = false;
});
</script>

<style scoped></style>
35 changes: 21 additions & 14 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,32 @@ const routes = [
},
},
{
path: "/facility",
name: "Facility",
component: () => import("@/views/controllers/Facility.vue"),
path: "/pilots",
children: [
{
path: "feedback",
name: "Leave Feedback",
component: () => import("@/views/pilots/LeaveFeedback.vue"),
},
],
meta: {
requiresAuth: true,
},
},
{
path: "/leave-feedback",
name: "Leave Feedback",
component: () => import("@/views/pilots/LeaveFeedback.vue"),
meta: {
requiresAuth: true,
},
},
{
path: "/feedback",
name: "My Feedback",
component: () => import("@/views/controllers/MyFeedback.vue"),
path: "/controllers",
children: [
{
path: "facility",
name: "Facility",
component: () => import("@/views/controllers/Facility.vue"),
},
{
path: "feedback",
name: "My Feedback",
component: () => import("@/views/controllers/MyFeedback.vue"),
},
],
meta: {
requiresAuth: true,
},
Expand Down
17 changes: 14 additions & 3 deletions src/stores/facility.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineStore } from "pinia";
import { API } from "@/utils/api";
import { Facility } from "@/types";
import { Facility, Roster } from "@/types";

interface FacilityState {
facilities: Facility[] | null;
facilities: Facility[];
error: string | null;
fetching: boolean;
hasFetched: boolean;
Expand All @@ -14,7 +14,7 @@ const useFacilityStore = defineStore({
id: "facility",
state: () =>
({
facilities: null,
facilities: [],
error: null,
fetching: false,
hasFetched: false,
Expand All @@ -38,6 +38,17 @@ const useFacilityStore = defineStore({
this.hasFetched = true;
}
},
async fetchRoster(facility: string): Promise<Roster[]> {
this.fetching = true;
try {
const { data } = await API.get(`/v3/facility/${facility}/roster`);
return data;
} catch (e) {
return [];
} finally {
this.fetching = false;
}
},
},
});

Expand Down
7 changes: 6 additions & 1 deletion src/stores/feedback.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineStore } from "pinia";
import { API } from "@/utils/api";
import { Feedback } from "@/types";
import { Feedback, FeedbackRequest } from "@/types";

interface FeedbackState {
myFeedback: Feedback;
Expand Down Expand Up @@ -33,6 +33,11 @@ const useFeedbackStore = defineStore({
this.hasFetched = true;
}
},
async submitFeedback(facility: string, feedback: FeedbackRequest): Promise<void> {
this.loading = API.post(`/v3/facility/${facility}/feedback`, feedback);
await this.loading;
this.loading = null;
},
},
});

Expand Down
11 changes: 10 additions & 1 deletion src/stores/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineStore } from "pinia";
import { API } from "@/utils/api";
import { User } from "@/types";
import { ActionLog, User } from "@/types";
import { getControllerRating, getPilotRating } from "@/utils/rating";
import { notify } from "notiwind";

Expand Down Expand Up @@ -103,6 +103,15 @@ const useUserStore = defineStore({
this.hasFetchedRosters = true;
}
},
async fetchActionLog(cid: number): Promise<ActionLog[]> {
try {
const { data } = await API.get(`/v3/user/${cid}/action-log`);
return data;
} catch (e) {
console.error(e);

Check warning on line 111 in src/stores/user.ts

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Unexpected console statement
return [];
}
},
async logout(): Promise<void> {
this.fetching = true;
try {
Expand Down
25 changes: 24 additions & 1 deletion src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,27 @@ export interface Feedback {
facility: string;
position: number;
comment: string;
notes: string;
feedback: string;
rating: string;
status: string;
created_at: string;
}

export interface FeedbackRequest {
callsign: string;
controller_cid: number;
pilot_cid: number;
position: number;
comment: string;
feedback: string;
rating: string;
status: string;
}

export interface Roster {
id: number;
first_name: string;
last_name: string;
cid: number;
facility: string;
operating_initials: string;
Expand All @@ -78,3 +91,13 @@ export interface Facility {
name: string;
url: string;
}

export interface ActionLog {
id: number;
cid: number;
entry: string;
created_at: string;
created_by: string;
updated_at: string;
updated_by: string;
}
4 changes: 4 additions & 0 deletions src/views/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<div v-else-if="selectedTab == 2" key="2">
<Discord :user="userStore.user" />
</div>
<div v-else-if="selectedTab == 3" key="3">
<ActionLog :user="userStore.user" />
</div>
</transition>
</div>
</Card>
Expand All @@ -42,6 +45,7 @@ import Discord from "@/components/profile/Discord.vue";
import Notifications from "@/components/profile/Notifications.vue";
import Page from "@/components/Page.vue";
import Profile from "@/components/profile/Profile.vue";
import ActionLog from "@/components/profile/ActionLog.vue";
const userStore = useUserStore();
Expand Down
6 changes: 4 additions & 2 deletions src/views/controllers/MyFeedback.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{{ feedback.rating }}
</th>
<td class="px-6 py-4">
{{ feedback.comment }}
{{ feedback.feedback }}
</td>
<td class="px-6 py-4">{{ feedback.facility }} / {{ feedback.position }}</td>
</tr>
Expand All @@ -65,13 +65,15 @@
<script setup lang="ts">
import { onMounted, ref, computed } from "vue";
import useFeedbackStore from "@/stores/feedback";
import useUserStore from "@/stores/user.ts";

Check failure on line 68 in src/views/controllers/MyFeedback.vue

View workflow job for this annotation

GitHub Actions / eslint (20.x)

Unexpected use of file extension "ts" for "@/stores/user.ts"
// Components
import Page from "@/components/Page.vue";
import Card from "@/components/Card.vue";
import Spinner from "@/components/animations/Spinner.vue";
const feedbackStore = useFeedbackStore();
const userStore = useUserStore();
const search = ref<string>("");
Expand Down Expand Up @@ -114,7 +116,7 @@ const feedbackRating = computed(() => {
onMounted(() => {
if (!feedbackStore.hasFetched) {
feedbackStore.fetchFeedback(1293257);
feedbackStore.fetchFeedback(userStore.self.cid);
}
});
</script>
Expand Down
Loading

0 comments on commit 2649303

Please sign in to comment.