Skip to content

Commit

Permalink
KB-111 Lecturer public rating
Browse files Browse the repository at this point in the history
  • Loading branch information
niravzi committed Oct 10, 2024
1 parent 781e618 commit a26089e
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 96 deletions.
19 changes: 17 additions & 2 deletions src/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ declare namespace ECampus {
interface PaginationModel {
pageNumber: number;
pageCount: number;
}
};

type Subdivision = {
id: number;
name: string;
};
}

declare namespace Intellect {
Expand Down Expand Up @@ -60,14 +65,24 @@ declare namespace Intellect {
};
};

type ExperienceType = 'publications' | 'exploration' | 'exploration_results' | 'confs' | 'profile';
type ExperienceType = 'publications' | 'exploration' | 'exploration_results' | 'confs' | 'profile' | 'rating';
type SearchMode = 'overall' | 'alphabetic' | 'subdivision' | 'interests';
type SearchParams = 'startsWith' | 'subdivision' | 'interests';

type TeacherExperience = {
[key in ExperienceType]: ExperienceItem;
};


type Rating = {
subdivision: ECampus.Subdivision;
overallRating?: number;
studyYear: string;
educationalMethodologicalRating?: number;
scientificInnovativeRating?: number;
organizationalEducationalRating?: number;
};

type Tab = {
label: string;
type: Intellect.SearchMode;
Expand Down
10 changes: 8 additions & 2 deletions src/api/teacher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Http, { API_BASE_URL } from './index';

import { parseSearchParams } from '@/utils';

type ExperienceResultPromise = Promise<ECampus.ApiResponse<Intellect.ExperienceItem>>;
Expand Down Expand Up @@ -28,7 +29,7 @@ const getKRExecutions = (teacherId: string): ExperienceResultPromise => {
return Http.get(`/v2/persons/${teacherId}/researches/carrying-out`);
};

const getKRResults = (teacherId: string, key: Intellect.ExperienceType): ExperienceResultPromise => {
const getKRResults = (teacherId: string): ExperienceResultPromise => {
return Http.get(`/v2/persons/${teacherId}/researches/results`);
};

Expand All @@ -44,7 +45,7 @@ export const getExperienceByTeacherId = async (teacherId: string): Promise<Intel
const results = await Promise.all<ExperienceResultPromise>([
getPublications(teacherId),
getKRExecutions(teacherId),
getKRResults(teacherId, 'exploration_results'),
getKRResults(teacherId),
getConferences(teacherId),
]);

Expand All @@ -67,8 +68,13 @@ export const getInterests = (limit?: number): Promise<string[]> => {
return Http.get('/v2/scientific-interests' + param);
};

export const getRatings = (teacherId: string): Promise<Intellect.Rating[]> => {
return Http.get(`/v2/persons/${teacherId}/rating`);
};

export default {
getExperienceByTeacherId,
getTeacherByTeacherId,
getInterests,
getRatings,
};
21 changes: 11 additions & 10 deletions src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import Image from 'next/image';

import React from 'react';
import avatarStub from '@/assets/img/avatar-stub.png';

type Props = {
Expand All @@ -9,14 +8,16 @@ type Props = {

const Avatar: React.FC<Props> = ({ img }) => {
return (
<Image
className="block w-170 h-[200px] avatar"
src={img || avatarStub}
alt="avatar"
width={0}
height={0}
sizes="100vw"
/>
<div className="w-[170px] h-[200px]">
<Image
className="object-cover w-full h-full border-[1px] border-solid border-[#eee] rounded-[5px]"
src={img || avatarStub}
alt="avatar"
width={0}
height={0}
sizes="100vw"
/>
</div>
);
};

Expand Down
36 changes: 36 additions & 0 deletions src/components/Ratings/Ratings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';

interface RatingsProps {
ratings: Intellect.Rating[];
}

export const Ratings = ({ ratings }: RatingsProps) => {
return (
<div className="w-full overflow-x-scroll">
<table className="-ml-6 -mr-6 border-separate whitespace-nowrap border-spacing-x-6 border-spacing-y-2">
<thead className="text-sm text-left text-primary">
<tr className="border-2 border-solid border-neutral-950">
<th>Навчальний рік</th>
<th>Рейтинг з навчально-методичної роботи</th>
<th>Рейтинг з науково-інноваційної роботи</th>
<th>Рейтинг з організаційно-виховної роботи</th>
<th>Загальний рейтинг</th>
<th>Кафедра</th>
</tr>
</thead>
<tbody className="text-xs text-neutral-600">
{ratings.map(rating => (
<tr key={rating.studyYear}>
<td>{rating.studyYear}</td>
<td>{rating.educationalMethodologicalRating}</td>
<td>{rating.scientificInnovativeRating}</td>
<td>{rating.organizationalEducationalRating}</td>
<td>{rating.overallRating}</td>
<td>{rating.subdivision.name}</td>
</tr>
))}
</tbody>
</table>
</div>
);
};
22 changes: 10 additions & 12 deletions src/components/TabList/TabList.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
import styles from './TabList.module.css';
import React from 'react';

type Props = {
interface TabListProps<T extends string> {
children: React.ReactNode;
tabs: Record<Intellect.ExperienceType, string>;
selectTab?: (a: any) => void;
tabs: Record<T, string>;
selectTab: (tab: T) => void;
className: string;
tabActive: any;
tabActive: T;
};

const TabList: React.FC<Props> = ({
const TabList = <T extends string>({
children,
tabs,
selectTab = (newTab: any) => {
console.log('SelectTab received ' + newTab);
},
selectTab,
className = '',
tabActive,
}) => {
}: TabListProps<T>) => {
return (
<div className={className}>
<div className="overflow-x-auto overflow-y-hidden scrollbar-hidden">
<div className="flex text-xs text-neutral-400 border-b-1 border-neutral-200 pb-2 items-end gap-17 min-w-700">
<div className="flex items-end pb-2 text-xs text-neutral-400 border-b-1 border-neutral-200 gap-17 min-w-700">
{Object.keys(tabs).map((tab) => (
<div
className={'cursor-pointer ' + (tab === tabActive ? styles['active-tab'] : '')}
onClick={() => selectTab(tab)}
onClick={() => selectTab(tab as T)}
key={tab}
>
{tabs[tab as Intellect.ExperienceType]}
{tabs[tab as T]}
</div>
))}
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { getInterests } from '@/api/teacher';
import { getFaculties } from '@/api/subdivision';
import { getInterests } from '@/api/teacher';

export const experienceTabs: Record<Intellect.ExperienceType, string> = {
profile: 'Профіль',
publications: 'Публікації',
exploration: 'Виконання науково-дослідних та дослідно-конструкторських робіт',
exploration_results: 'Результати виконання науково-дослідних та дослідно-конструкторських робіт',
confs: 'Конференції, виставки',
rating: 'Рейтинг',
};

export const searchStringParams = {
Expand Down
Loading

0 comments on commit a26089e

Please sign in to comment.