Skip to content

Commit

Permalink
Merge pull request #57 from ckan-project/dev
Browse files Browse the repository at this point in the history
[feat] 인기순 필터 적용 및 주제 필터 적용시 페이지 리셋
  • Loading branch information
minSsan authored May 29, 2024
2 parents 4a73212 + 340121f commit 9c7c897
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/app/(default)/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import {
QUICK_MENU,
SERVER_PARAMS_KEY,
} from "../../constants/dataset-search-params";
import { SortValueType } from "../../shared/types/dataset";

const DATA_COUNT = 2379;

const POPULAR_SORT_VALUE: SortValueType = "인기순";

export default function Main({ populars, news }) {
const dataCount = useIncreaseCount(DATA_COUNT);

Expand Down Expand Up @@ -88,7 +91,7 @@ export default function Main({ populars, news }) {
<DataBoard
title="인기 데이터"
dataList={populars}
url={`search-result?${SERVER_PARAMS_KEY.SORT}=스크랩순`}
url={`search-result?${SERVER_PARAMS_KEY.SORT}=${POPULAR_SORT_VALUE}`}
/>

{/* 신규데이터 */}
Expand Down
8 changes: 7 additions & 1 deletion src/constants/dataset-search-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ export const ORGANIZATION_VALUES = [

export const DATA_TYPES = ["csv", "xls", "xlsx", "pdf", "docx", "json"] as const;

export const SORT_VALUES = ["최신순", "스크랩순", "조회순", "다운로드순"] as const;
export const SORT_VALUES = [
"최신순",
"스크랩순",
"조회순",
"다운로드순",
"인기순",
] as const;

export const SERVER_PARAMS_KEY = {
KEYWORD: "keyword",
Expand Down
4 changes: 3 additions & 1 deletion src/shared/types/dataset.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { DATA_TYPES, ORGANIZATION_VALUES } from "../../constants";
import { DATA_TYPES, ORGANIZATION_VALUES, SORT_VALUES } from "../../constants";

export type Organization = (typeof ORGANIZATION_VALUES)[number];

export type DataType = (typeof DATA_TYPES)[number];

export type SortValueType = (typeof SORT_VALUES)[number];

export interface DatasetChartType {
x_axis_name: string;
x_label: string[];
Expand Down
5 changes: 4 additions & 1 deletion src/utils/search/update-query-string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use client";

import { SERVER_PARAMS_KEY } from "../../constants/dataset-search-params";

interface UpdateQueryStringProps {
type: "create" | "append" | "remove";
name: string;
Expand All @@ -23,7 +25,8 @@ export function updateQueryString(props: UpdateQueryStringProps): string {
params.set(name, value);
return params.toString();

case "append":
case "append": // 주제 필터 추가 -> 첫 번째 페이지로 리셋
params.set(SERVER_PARAMS_KEY.PAGE, `0`);
params.append(name, value);
return params.toString();

Expand Down

0 comments on commit 9c7c897

Please sign in to comment.