Skip to content

Commit

Permalink
fix filter
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Feb 28, 2024
1 parent 8578790 commit 719293a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
15 changes: 1 addition & 14 deletions components/datasets/DataAlter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,10 @@ import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/router';
import Modal from 'react-modal';
import { tabbedInterface } from 'utils/index';
import { formatFilterName } from 'pages/datasets';

Modal.setAppElement('#__next');

function formatFilterName(name: string) {
if (name == 'fiscal_year') {
return 'fiscal year';
} else if (name == 'buyer_name') return 'buyer name';
else if (
name == 'tender/mainProcurementCategory' ||
name == 'tender_mainprocurementcategory'
)
return 'category';
else if (name == 'tender/stage') return 'tender stage';
else if (name == 'tender_status') return 'status';
else return name;
}

const sort = [
{
id: 'tender_bid_opening_date:asc',
Expand Down
13 changes: 1 addition & 12 deletions components/datasets/Filter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react';
import { Cross } from 'components/icons/shared';
import { truncate } from 'lodash';
import { formatFilterName } from 'pages/datasets';

const dataObj = {};
const filterSearch = {};
Expand Down Expand Up @@ -82,18 +83,6 @@ const Filter = ({ data, newFilters, fq }) => {
}, 100);
}

function formatFilterName(name: string) {
if (name == 'fiscal_year') {
return 'fiscal year';
} else if (name == 'organization' || name == 'buyer_name')
return 'buyer name';
else if (name == 'tender_mainprocurementcategory') return 'type';
else if (name == 'tender/mainProcurementCategory') return 'category';
else if (name == 'tender/stage') return 'tender stage';
else if (name == 'tender_status') return 'status';
else return name;
}

function handleFilterChange(e: any) {
const selectedFilter = e.target as HTMLInputElement;
const type = selectedFilter.dataset.type;
Expand Down
14 changes: 10 additions & 4 deletions pages/datasets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ type Props = {
facets: any;
};

// const list =
// '"fiscalYear", "organization", "tender_mainprocurementcategory", "tender_status"';
const newList = '"organization"';
const filterList = '"organization", "fiscalYear", "mainProcurementCategory"';
export function formatFilterName(name: string) {
if (name == 'fiscalYear') {
return 'fiscal year';
} else if (name == 'organization' || name == 'buyer_name')
return 'buyer name';
else if (name == 'mainProcurementCategory') return 'category';
else return name;
}

const defaultSort = 'tender_bid_opening_date:asc';

Expand Down Expand Up @@ -284,7 +290,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
const variables = convertToCkanSearchQuery(query);

// fetch fatcets values
const facets = await getFilters(newList, variables, 'tender_dataset');
const facets = await getFilters(filterList, variables, 'tender_dataset');

// fetch datasets
const data = await fetchDatasets('tender_dataset', variables);
Expand Down

0 comments on commit 719293a

Please sign in to comment.