Skip to content

Commit

Permalink
fix: add default value for githubId and name fields and fix reset bug (
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoro444 authored Dec 19, 2023
1 parent 44264ea commit 2d77c56
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client/src/modules/Score/components/ScoreTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export function ScoreTable(props: Props) {
setCourseTasks(sortedTasks);
setColumns(
getColumns({
githubId,
name,
cityName,
mentor,
handleSettings: () => setIsVisibleSettings(true),
Expand Down
6 changes: 5 additions & 1 deletion client/src/modules/Score/data/getColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Link from 'next/link';

type Props = {
taskColumns: Record<string, any>[];
githubId?: string | string[];
name?: string | string[];
cityName?: string | string[];
mentor?: string | string[];
handleSettings: () => void;
Expand All @@ -19,7 +21,7 @@ const getSearchProps = (key: string) => ({
});

export function getColumns(props: Props): ColumnType<ScoreStudentDto>[] {
const { cityName, mentor, handleSettings, taskColumns } = props;
const { githubId, name, cityName, mentor, handleSettings, taskColumns } = props;

return [
{
Expand All @@ -37,6 +39,7 @@ export function getColumns(props: Props): ColumnType<ScoreStudentDto>[] {
key: 'githubId',
dataIndex: 'githubId',
sorter: 'githubId',
defaultFilteredValue: githubId ? (isArray(githubId) ? githubId : [githubId]) : undefined,
width: 150,
render: (value: string) => (
<div>
Expand All @@ -54,6 +57,7 @@ export function getColumns(props: Props): ColumnType<ScoreStudentDto>[] {
dataIndex: 'name',
width: 150,
sorter: 'name',
defaultFilteredValue: name ? (isArray(name) ? name : [name]) : undefined,
render: (value, record) => (
<Link prefetch={false} href={`/profile?githubId=${record.githubId}`}>
{value}
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/Score/hooks/useScorePaging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ScoreOrder, ScoreTableFilters } from './types';

export function useScorePaging(router: NextRouter, courseService: CourseService, activeOnly: boolean) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { ['mentor.githubId']: mentor, cityName, ...currentQuery } = router.query;
const { githubId, name, ['mentor.githubId']: mentor, cityName, ...currentQuery } = router.query;

const setQueryParams = useCallback(
(query: ParsedUrlQuery) => {
Expand Down

0 comments on commit 2d77c56

Please sign in to comment.