Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip/change routes #349

Merged
merged 8 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 21 additions & 59 deletions apps/container/src/components/SingleComment/SingleComment.vue
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
<template>
<v-container>
<v-row align="start" justify="start">
<v-col
sm=""
order="1"
class="mr-3 justify-center pa-0 flex-grow-0 flex-shrink-1"
>
<div
:style="conceptStyle"
class="text-white d-flex align-center justify-center rounded-lg"
>
<v-col sm="" order="1" class="mr-3 justify-center pa-0 flex-grow-0 flex-shrink-1">
<div :style="conceptStyle" class="text-white d-flex align-center justify-center rounded-lg">
{{ comment?.enrollment.conceito }}
</div>
<p class="text-primary" style="white-space: nowrap">
{{ season }}
</p>
</v-col>
<v-col
cols="12"
sm=""
order="3"
order-sm="2"
class="comment-text-container mr-2 pa-0"
:style="`max-height: ${expanded || smAndDown ? 'unset' : '80px'}`"
>
<v-col cols="12" sm="" order="3" order-sm="2" class="comment-text-container mr-2 pa-0"
:style="`max-height: ${expanded || smAndDown ? 'unset' : '80px'}`">
<div>
<div class="d-flex align-center text-primary">
<v-chip
v-if="isEAD"
density="compact"
class="px-2 mr-1"
style="font-size: 12px"
>EAD</v-chip
>
<v-chip v-if="isEAD" density="compact" class="px-2 mr-1" style="font-size: 12px">EAD</v-chip>
<p class="text-subtitle-2">
{{ comment?.subject.name }}
</p>
Expand All @@ -41,50 +22,29 @@
<p ref="commentText">
{{ comment?.comment }}
</p>
<button
class="show-more text-primary text-subtitle-2 text-uppercase"
:style="`display:${expanded || smAndDown ? 'none' : 'block'}`"
@click="showMore"
>
<button class="show-more text-primary text-subtitle-2 text-uppercase"
:style="`display:${expanded || smAndDown ? 'none' : 'block'}`" @click="showMore">
mostrar mais
<v-icon>mdi-chevron-down</v-icon>
</button>
</div>
</v-col>
<v-col
sm=""
order="2"
order-sm="3"
class="pa-0 justify-start text-subtitle-2 text-next-light-gray flex-grow-0 flex-shrink-1"
>
<v-col sm="" order="2" order-sm="3"
class="pa-0 justify-start text-subtitle-2 text-next-light-gray flex-grow-0 flex-shrink-1">
<div class="d-flex">
<v-btn
:aria-label="(like ? 'Remover' : 'Deixar') + ' like'"
:loading="isPendingLike || isPendingRemoveLike"
@click="like ? mutateRemoveLike() : mutateLike()"
class="icon-button text-subtitle-2"
variant="text"
:icon="like ? 'mdi-thumb-up' : 'mdi-thumb-up-outline'"
:color="like ? 'primary' : ''"
>
<v-btn :aria-label="(like ? 'Remover' : 'Deixar') + ' like'" :loading="isPendingLike || isPendingRemoveLike"
@click="like ? mutateRemoveLike() : mutateLike()" class="icon-button text-subtitle-2" variant="text"
:icon="like ? 'mdi-thumb-up' : 'mdi-thumb-up-outline'" :color="like ? 'primary' : ''">
<v-icon size="small" class="mr-1" />
{{ likeCount }}
</v-btn>
<v-btn
:aria-label="
(recommendation ? 'Remover' : 'Deixar') + ' recomendação'
"
:loading="isPendingRecommendation || isPendingRemoveRecommendation"
@click="
<v-btn :aria-label="(recommendation ? 'Remover' : 'Deixar') + ' recomendação'
" :loading="isPendingRecommendation || isPendingRemoveRecommendation" @click="
recommendation
? mutateRemoveRecommendation()
: mutateRecommendation()
"
class="ml-1 icon-button text-subtitle-2"
variant="text"
:icon="recommendation ? 'mdi-medal' : 'mdi-medal-outline'"
:color="recommendation ? 'primary' : ''"
>
" class="ml-1 icon-button text-subtitle-2" variant="text"
:icon="recommendation ? 'mdi-medal' : 'mdi-medal-outline'" :color="recommendation ? 'primary' : ''">
<v-icon size="small" class="mr-1" />
{{ recommendationCount }}
</v-btn>
Expand Down Expand Up @@ -153,7 +113,7 @@ const { mutate: mutateRecommendation, isPending: isPendingRecommendation } =
},
onError: (error: AxiosError<RequestError>) => {
ElMessage({
message: error.response?.data.error,
message: error.response?.data.message,
type: 'error',
showClose: true,
});
Expand Down Expand Up @@ -204,8 +164,8 @@ const season = computed(() => {

return formatSeason(
(year ?? props.comment.enrollment.year) +
':' +
(quad ?? props.comment.enrollment.quad),
':' +
(quad ?? props.comment.enrollment.quad),
);
});

Expand Down Expand Up @@ -239,12 +199,14 @@ onMounted(() => {
flex-direction: column;
position: relative;
}

.show-more {
position: absolute;
width: 100%;
top: 60px;
background-image: linear-gradient(to right, transparent, white 40%);
}

.v-btn--icon.v-btn--density-default.icon-button {
height: 36px;
width: 36px;
Expand Down
13 changes: 2 additions & 11 deletions apps/container/src/views/Settings/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,10 @@
Conta do Facebook associada
</a>

<a :href="addFacebookAccount" target="_blank" class="links-settings add-account" v-else-if="user">
<v-icon color="ufabcnext-blue" class="mr-2">mdi-plus-circle-outline</v-icon>
Associar à uma conta do Facebook
</a>

<a href="#" class="links-settings" v-if="user?.oauth?.google">
<v-icon color="ufabcnext-green">mdi-check</v-icon>
Conta do Google associada
</a>

<a :href="addGoogleAccount" target="_blank" class="links-settings add-account" v-else-if="user">
<v-icon color="ufabcnext-blue" class="mr-2">mdi-plus-circle-outline</v-icon>
Associar à uma conta do Google
Expand Down Expand Up @@ -120,15 +114,12 @@ const userLogin = computed(() => {
return user.value?.email?.replace('@aluno.ufabc.edu.br', '');
});

const apiPath = api.defaults.baseURL?.replace('/v1', '');
const apiPath = api.defaults.baseURL?.replace('/v2', '');

const addGoogleAccount = computed(() => {
return apiPath + 'connect/google?userId=' + user.value?._id;
return `${apiPath}login/google?userId=${user.value?._id}`;
});

const addFacebookAccount = computed(() => {
return apiPath + 'connect/facebook?userId=' + user.value?._id;
});

const createdAt = computed(() => {
if (user.value?.createdAt) {
Expand Down
6 changes: 3 additions & 3 deletions apps/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -888,10 +888,10 @@ <h4>Criador da Extensão da Matrícula</h4>
const resolveEndpoint = (origin) => {
if (origin === 'file://') {
// local backend
return 'http://localhost:8011/v1/connect/google';
return 'http://localhost:5000/login/google';
} else if (origin.includes('dev')) {
// staging url
return 'https://api.ufabcnext.com/connect/google';
return 'https://api.v2.ufabcnext.com/login/google';
} else {
// production url
return 'https://api.ufabcnext.com/connect/google';
Expand Down Expand Up @@ -954,7 +954,7 @@ <h4>Criador da Extensão da Matrícula</h4>
Entrar localmente
</a>`;

const isLocal = !window.location.origin.includes('file://');
const isLocal = window.location.origin.includes('file://');
Joabesv marked this conversation as resolved.
Show resolved Hide resolved
if (isLocal) {
const devLoginContainer = document.querySelector('#dev-login');
devLoginContainer.insertAdjacentHTML('afterend', devLoginBtn);
Expand Down
4 changes: 2 additions & 2 deletions packages/services/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { authStore } from 'stores';

const resolveEndpoint = (env?: string) =>
({
development: 'http://localhost:8011/v1',
staging: 'https://api.ufabcnext.com/v1',
development: 'http://localhost:5000/v2',
staging: 'https://api.v2.ufabcnext.com/v2',
production: 'https://api.ufabcnext.com/v1',
})[env!] || 'https://api.ufabcnext.com/v1';

Expand Down
10 changes: 5 additions & 5 deletions packages/services/src/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export const Comments = {
api.get<Comment>(`/comments/enrollment/${enrollmentId}`),
create: (data: CreateCommentRequest) => api.post('/comments/', data),
update: ({ id, comment }: UpdateCommentRequest) =>
api.put('/comments/' + id, { comment }),
like: (id: string) => api.post(`/reactions/${id}`, { kind: 'like' }),
api.put(`/comments/${id}`, { comment }),
like: (id: string) => api.post(`/comments/reactions/${id}`, { kind: 'like' }),
recommendation: (id: string) =>
api.post(`/reactions/${id}`, { kind: 'recommendation' }),
removeLike: (id: string) => api.delete(`/reactions/${id}/like`),
api.post(`/comments/reactions/${id}`, { kind: 'recommendation' }),
removeLike: (id: string) => api.delete(`/comments/reactions/${id}/like`),
removeRecommendation: (id: string) =>
api.delete(`/reactions/${id}/recommendation`),
api.delete(`/comments/reactions/${id}/recommendation`),
};
4 changes: 2 additions & 2 deletions packages/services/src/enrollments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { Enrollment } from 'types';
import { api } from './api';

export const Enrollments = {
list: () => api.get<Enrollment[]>('/enrollments'),
get: (id: string) => api.get<Enrollment>('/enrollments/' + id),
list: () => api.get<Enrollment[]>('/entities/enrollments'),
get: (id: string) => api.get<Enrollment>(`/entities/enrollments/${id}`),
};
6 changes: 3 additions & 3 deletions packages/services/src/performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ type HistoriesGraduations = {
};

export const Performance = {
getCrHistory: () => api.get<QuadInformation[]>('users/me/grades'),
getCrDistribution: () => api.get<CrDistributionData[]>('stats/grades'),
getCrHistory: () => api.get<QuadInformation[]>('courseStats/user/grades'),
getCrDistribution: () => api.get<CrDistributionData[]>('courseStats/grades'),
getHistoriesGraduations: () =>
api.get<HistoriesGraduations>('historiesGraduations'),
api.get<HistoriesGraduations>('courseStats/history'),
};
8 changes: 4 additions & 4 deletions packages/services/src/reviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import { api } from './api';

export const Reviews = {
searchTeachers: async (q: string) =>
api.get<SearchTeacher>('/teachers/search', {
api.get<SearchTeacher>('/entities/teachers/search', {
params: { q },
}),
searchSubjects: async (q: string) =>
api.get<SearchSubject>('/subjects/search', {
api.get<SearchSubject>('/entities/subjects/search', {
params: { q },
}),
getTeacher: async (id: string) =>
api.get<TeacherReview>(`/reviews/teachers/${id}`),
api.get<TeacherReview>(`/entities/teachers/reviews/${id}`),
getSubject: async (id: string) =>
api.get<SubjectInfo>(`/reviews/subjects/${id}`),
api.get<SubjectInfo>(`/entities/subjects/reviews/${id}`),
};
10 changes: 5 additions & 5 deletions packages/services/src/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ export type StatsParams = {

export const StatsSubjects = {
getAllClasses: (params: StatsParams) =>
api.get<PageableReturn<StatsClass>>('/stats/disciplinas', { params }),
api.get<PageableReturn<StatsClass>>('public/stats/components', { params }),
getAllCourses: (params: StatsParams) =>
api.get<PageableReturn<StatsCourse>>('/stats/disciplinas/courses', {
api.get<PageableReturn<StatsCourse>>('public/stats/components/courses', {
params,
}),
getAllSubjects: (params: StatsParams) =>
api.get<PageableReturn<StatsSubject>>('/stats/disciplinas/disciplines', {
api.get<PageableReturn<StatsSubject>>('public/stats/components/component', {
params,
}),
getAllCoursesNames: () => api.get<CourseName[]>('/histories/courses'),
getOverview: (params: Pick<StatsParams, 'season'>) =>
api.get<StatsOverview>('/stats/disciplinas/overview', { params }),
api.get<StatsOverview>('public/stats/components/overview', { params }),
getUsage: (params: Pick<StatsParams, 'season'>) =>
api.get<StatsUsage>('/stats/usage', { params }),
api.get<StatsUsage>('public/stats/usage', { params }),
};
6 changes: 3 additions & 3 deletions packages/services/src/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export type UserConfirmResponse = {
export const Users = {
completeSignup: (params: UserSignup) => api.put('/users/complete', params),
confirmSignup: (token: string) =>
api.post<UserConfirmResponse>('/account/confirm', { token }),
resendEmail: () => api.post('/users/me/resend'),
api.post<UserConfirmResponse>('/users/confirm', { token }),
resendEmail: () => api.post('/users/resend'),
recovery: (email: string) => api.post('/users/me/recover', { email }),
delete: () => api.delete('/users/me/delete'),
delete: () => api.delete('/users/remove'),
info: () => api.get<User>('/users/info'),
facebookAuth: (params: FacebookAuth) =>
api.post<FacebookConfirmResponse>('/facebook/sync', params),
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/request-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export type RequestError = {
name: string;
type: string;
error: string;
message: string;
};
5 changes: 3 additions & 2 deletions packages/utils/src/season.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import dayjs from 'dayjs';
export const getSeason = (date = dayjs()) => {
const year = date.year();
const month = date.month();

let quad;
if (month < 4) {
if (month < 3) {
quad = 1;
} else if (month < 8) {
} else if (month < 7) {
quad = 2;
} else {
quad = 3;
Expand Down
Loading