Skip to content

Commit

Permalink
Fixing post test (#61)
Browse files Browse the repository at this point in the history
* rename.sh modified?

* styles

* some more formatting

* Анонимный отзыв -> Анонимный

* anonymous switch removed

* menu close on scroll

* changed lecturer warning

* fixed review general mark display

* changed token and auth warnings

* added other subject option

* formatting of text and paragraphs

* clean console logs
  • Loading branch information
BatuevIO authored Dec 26, 2024
1 parent 2dd6a05 commit 9452b7e
Show file tree
Hide file tree
Showing 16 changed files with 499 additions and 540 deletions.
3 changes: 0 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<script setup lang="ts">
import { useProfileStore } from '@/store';
import { onMounted } from 'vue';
import { setupAuth } from '@profcomff/api-uilib';
import ToastList from '@/components/ToastList.vue';
const profileStore = useProfileStore();
onMounted(() => {
profileStore.fromUrl();
console.log(document.location.toString());
setupAuth(profileStore.token);
});
</script>

Expand Down
4 changes: 0 additions & 4 deletions src/components/.prettierrc

This file was deleted.

160 changes: 74 additions & 86 deletions src/components/AdminReviewCard.vue
Original file line number Diff line number Diff line change
@@ -1,109 +1,97 @@
<template>
<v-card class="my-1 px-0" rounded>
<template #title>
<div class="text-h6 font-weight-bold">{{ lecturerName }}</div>
</template>
<template #subtitle>
<div class="text-h7">{{ formattedDate }} | {{ "Анонимный отзыв" }}</div>
</template>
<template #text>
<p class="text-subtitle-2">{{ comment.raw.text }}</p>
</template>
<template #actions>
<v-btn
class="font-weight-bold"
color="primary"
variant="text"
@click="approveComment(comment.raw.uuid)"
>
Одобрить
</v-btn>
<v-btn
class="font-weight-bold"
color="#B3261E"
variant="text"
@click="dismissComment(comment.raw.uuid)"
>
Отклонить
</v-btn>
</template>
</v-card>
<v-card class="my-1 px-0" rounded>
<template #title>
<div class="text-h6 font-weight-bold">{{ lecturerName }}</div>
</template>
<template #subtitle>
<div class="text-h7">{{ formattedDate }} | {{ 'Анонимный отзыв' }}</div>
</template>
<template #text>
<p class="text-subtitle-2">{{ comment.raw.text }}</p>
</template>
<template #actions>
<v-btn class="font-weight-bold" color="primary" variant="text" @click="approveComment(comment.raw.uuid)">
Одобрить
</v-btn>
<v-btn class="font-weight-bold" color="#B3261E" variant="text" @click="dismissComment(comment.raw.uuid)">
Отклонить
</v-btn>
</template>
</v-card>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import apiClient from "@/api";
import { ToastType } from "@/models";
import { useToastStore } from "@/store/toastStore";
import { ref, onMounted } from 'vue';
import apiClient from '@/api';
import { ToastType } from '@/models';
import { useToastStore } from '@/store/toastStore';
const props = defineProps({
comment: { type: Object, required: true },
comment: { type: Object, required: true },
});
const emit = defineEmits(["decided"]);
const emit = defineEmits(['decided']);
const toastStore = useToastStore();
const lecturerName = ref("");
const formattedDate = ref("");
const lecturerName = ref('');
const formattedDate = ref('');
onMounted(async () => {
const lecturer = await getLecturerName(props.comment.raw.lecturer_id);
lecturerName.value = lecturer
? [lecturer.last_name, lecturer.first_name, lecturer.middle_name].join(" ")
: "Неизвестный лектор";
formattedDate.value = Intl.DateTimeFormat().format(
Date.parse(props.comment.raw.create_ts),
);
const lecturer = await getLecturerName(props.comment.raw.lecturer_id);
lecturerName.value = lecturer
? [lecturer.last_name, lecturer.first_name, lecturer.middle_name].join(' ')
: 'Неизвестный лектор';
formattedDate.value = Intl.DateTimeFormat().format(Date.parse(props.comment.raw.create_ts));
});
async function getLecturerName(lecturerId: string) {
const { data } = await apiClient.GET("/rating/lecturer/{id}", {
params: { path: { id: Number(lecturerId) } },
});
return data;
const { data } = await apiClient.GET('/rating/lecturer/{id}', {
params: { path: { id: Number(lecturerId) } },
});
return data;
}
async function approveComment(id: string) {
const { response } = await apiClient.PATCH("/rating/comment/{uuid}", {
params: {
path: { uuid: id },
query: { review_status: "approved" },
},
});
if (response.ok) {
toastStore.push({
title: "Отзыв одобрен",
type: ToastType.Info,
});
emit("decided");
} else {
toastStore.push({
title: "Что-то пошло не так при одобрении отзыва",
type: ToastType.Error,
description: response.statusText,
});
}
const { response } = await apiClient.PATCH('/rating/comment/{uuid}', {
params: {
path: { uuid: id },
query: { review_status: 'approved' },
},
});
if (response.ok) {
toastStore.push({
title: 'Отзыв одобрен',
type: ToastType.Info,
});
emit('decided');
} else {
toastStore.push({
title: 'Что-то пошло не так при одобрении отзыва',
type: ToastType.Error,
description: response.statusText,
});
}
}
async function dismissComment(id: string) {
const { response } = await apiClient.PATCH("/rating/comment/{uuid}", {
params: {
path: { uuid: id },
query: { review_status: "dismissed" },
},
});
if (response.ok) {
toastStore.push({
title: "Отзыв отклонен",
type: ToastType.Info,
});
emit("decided");
} else {
toastStore.push({
title: "Что-то пошло не так при отклонении отзыва",
type: ToastType.Error,
description: response.statusText,
});
}
const { response } = await apiClient.PATCH('/rating/comment/{uuid}', {
params: {
path: { uuid: id },
query: { review_status: 'dismissed' },
},
});
if (response.ok) {
toastStore.push({
title: 'Отзыв отклонен',
type: ToastType.Info,
});
emit('decided');
} else {
toastStore.push({
title: 'Что-то пошло не так при отклонении отзыва',
type: ToastType.Error,
description: response.statusText,
});
}
}
</script>
78 changes: 35 additions & 43 deletions src/components/AppRatingBar.vue
Original file line number Diff line number Diff line change
@@ -1,59 +1,51 @@
<template>
<div class="d-flex position-relative">
<v-progress-linear
class="w-50 text-body-2 my-2 text-small"
:size="mobile ? 110 : 130"
height="20"
max="4"
reverse
:model-value="value < 0 ? -value : 0"
:color="color"
></v-progress-linear>
<v-progress-linear
class="w-50 text-body-2 my-2 text-small"
:size="mobile ? 110 : 130"
height="20"
max="4"
:model-value="value > 0 ? value : 0"
:color="color"
></v-progress-linear>
<v-row
class="w-100 position-absolute my-1"
no-gutters
justify="space-between"
align="center"
>
<v-col cols="3">
<span class="text-left ml-1 font-weight-bold">-2</span>
</v-col>
<v-col cols="5">
<div class="text-center font-weight-bold">
{{ label }}: {{ displayValue }}
</div>
</v-col>
<v-col cols="3" class="text-right mr-1 font-weight-bold">+2</v-col>
</v-row>
</div>
<div class="d-flex position-relative">
<v-progress-linear
class="w-50 text-body-2 my-2 text-small"
:size="mobile ? 110 : 130"
height="20"
max="4"
reverse
:model-value="value < 0 ? -value : 0"
:color="color"
></v-progress-linear>
<v-progress-linear
class="w-50 text-body-2 my-2 text-small"
:size="mobile ? 110 : 130"
height="20"
max="4"
:model-value="value > 0 ? value : 0"
:color="color"
></v-progress-linear>
<v-row class="w-100 position-absolute my-1" no-gutters justify="space-between" align="center">
<v-col cols="3">
<span class="text-left ml-1 font-weight-bold">-2</span>
</v-col>
<v-col cols="5">
<div class="text-center font-weight-bold">{{ label }}: {{ displayValue }}</div>
</v-col>
<v-col cols="3" class="text-right mr-1 font-weight-bold">+2</v-col>
</v-row>
</div>
</template>

<script setup lang="ts">
import { useDisplay } from "vuetify";
import { useDisplay } from 'vuetify';
const { mobile } = useDisplay();
const props = defineProps({
value: { type: Number, required: true },
label: { type: String, required: true },
value: { type: Number, required: true },
label: { type: String, required: true },
});
const displayValue =
(props.value > 0 ? "+" : "") + String(props.value.toFixed(2));
const displayValue = (props.value > 0 ? '+' : '') + String(props.value.toFixed(2));
const value = props.value;
let color = "rgb(0, 0, 0)";
let color = 'rgb(0, 0, 0)';
if (value < 0) {
color = "#B3261E66";
color = '#B3261E66';
} else if (value > 0) {
color = "#00004B66";
color = '#00004B66';
}
</script>
67 changes: 30 additions & 37 deletions src/components/LecturerHeaderCard.vue
Original file line number Diff line number Diff line change
@@ -1,48 +1,41 @@
<template>
<v-card class="container" width="100%" variant="flat" rounded="xl">
<template #prepend>
<v-avatar :size="mobile ? 80 : 120" rounded="circle" :image="photo" />
</template>
<template #title>
<div :class="mobile ? 'text-h6' : 'text-h4'">{{ lastName }}</div>
</template>
<template #subtitle>
<div class="text-body-1">{{ firstName }} {{ middleName }}</div>
<div class="text-body-2">
<v-chip-group v-if="subjectsToShow">
<v-chip
v-for="(subject, index) in subjectsToShow"
:key="index"
outlined
size="small"
>
{{ subject }}
</v-chip>
</v-chip-group>
</div>
</template>
</v-card>
<v-card class="container" width="100%" variant="flat" rounded="xl">
<template #prepend>
<v-avatar :size="mobile ? 80 : 120" rounded="circle" :image="photo" />
</template>
<template #title>
<div :class="mobile ? 'text-h6' : 'text-h4'">{{ lastName }}</div>
</template>
<template #subtitle>
<div class="text-body-1">{{ firstName }} {{ middleName }}</div>
<div class="text-body-2">
<v-chip-group v-if="subjectsToShow">
<v-chip v-for="(subject, index) in subjectsToShow" :key="index" outlined size="small">
{{ subject }}
</v-chip>
</v-chip-group>
</div>
</template>
</v-card>
</template>

<script setup lang="ts">
import { PropType } from "vue";
import { useDisplay } from "vuetify";
import { PropType } from 'vue';
import { useDisplay } from 'vuetify';
const { mobile } = useDisplay();
const props = defineProps({
photo: { type: String, required: true },
lastName: { type: String, required: true },
firstName: { type: String, required: true },
middleName: { type: String, required: true },
subjects: {
type: null as unknown as PropType<Array<String> | null>,
required: false,
default: null,
},
photo: { type: String, required: true },
lastName: { type: String, required: true },
firstName: { type: String, required: true },
middleName: { type: String, required: true },
subjects: {
type: null as unknown as PropType<Array<String> | null>,
required: false,
default: null,
},
});
const subjectsToShow = props.subjects
? props.subjects.filter((item: unknown) => item !== null)
: null;
const subjectsToShow = props.subjects ? props.subjects.filter((item: unknown) => item !== null) : null;
</script>
Loading

0 comments on commit 9452b7e

Please sign in to comment.