Skip to content

Commit

Permalink
feat: replace button with select
Browse files Browse the repository at this point in the history
  • Loading branch information
hegeaal committed Oct 18, 2023
1 parent ac6f777 commit db52db2
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 47 deletions.
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/l10n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@
"requestDataInfo": "Do you want to request data, APIs, or anything else you can do it here. You will be redirected to datalandsbyen.no.",
"newestToOldest": "Newest to Oldest",
"mostVotes": "Most Votes",
"mostViews": "Most Views"
"mostViews": "Most Views",
"view": "View"
}
}
3 changes: 2 additions & 1 deletion src/l10n/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@
"requestDataInfo": "Ønsker du å etterspørre data, APIer eller annet du kan gjøre det her. Du blir sendt til datalandsbyen.no.",
"newestToOldest": "Nyeste til eldste",
"mostVotes": "Flest stemmer",
"mostViews": "Flest visninger"
"mostViews": "Flest visninger",
"view": "Visning"
}
}
3 changes: 2 additions & 1 deletion src/l10n/nn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@
"requestDataInfo": "Ynskjer du å etterspørre data, APIer eller anna kan du gjere det her. Du blir sendt til datalandsbyen.no.",
"newestToOldest": "Nyeste til eldste",
"mostVotes": "Flest stemmer",
"mostViews": "Flest visningar"
"mostViews": "Flest visningar",
"view": "Visning"
}
}
57 changes: 36 additions & 21 deletions src/pages/requests/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { FC, useEffect, useState } from 'react';
import { compose } from 'redux';
import Link from '@fellesdatakatalog/link';
import Button from '@fellesdatakatalog/button';
import Select from 'react-select';
import withCommunity, {
Props as CommunityProps
} from '../../components/with-community';
Expand All @@ -12,6 +13,7 @@ import { formatDate } from '../../lib/date-utils';
import Banner from '../../components/banner';
import localization from '../../lib/localization';
import env from '../../env';
import { SelectOption } from '../../types';

const { FDK_COMMUNITY_BASE_URI } = env;
interface Props extends CommunityProps {}
Expand All @@ -27,6 +29,21 @@ const RequestsPage: FC<Props> = ({
const notDeletedRequests = topics?.filter(topic => topic.deleted === 0);
const [search, setSearch] = useState('');

const sortOptions: SelectOption[] = [
{
value: 'timestamp',
label: localization.requestsPage.newestToOldest
},
{
value: 'upvotes',
label: localization.requestsPage.mostVotes
},
{
value: 'topic.viewcount',
label: localization.requestsPage.mostViews
}
];

return (
<>
<Banner title={localization.requestsPage.title} />
Expand Down Expand Up @@ -54,28 +71,26 @@ const RequestsPage: FC<Props> = ({
</SC.Button>
</SC.FirstRow>
<SC.FirstRow>
<SC.Row>
<Button
onClick={() => searchRequestsRequested(search, 'timestamp')}
>
{localization.requestsPage.newestToOldest}
</Button>
<Button onClick={() => searchRequestsRequested(search, 'upvotes')}>
{localization.requestsPage.mostVotes}
</Button>
<Button
onClick={() => searchRequestsRequested(search, 'topic.viewcount')}
>
{localization.requestsPage.mostViews}
</Button>
</SC.Row>
<SC.Row>
<input
type='text'
onChange={event => setSearch(event.target.value)}
<div>
<p>{localization.requestsPage.view}</p>
<Select
options={sortOptions}
onChange={value => searchRequestsRequested(search, value?.value)}
defaultValue={sortOptions[0]}
/>
<Button onClick={() => searchRequestsRequested(search)}>Søk</Button>
</SC.Row>
</div>
<div>
<p>Fritekssøk i titler</p>
<SC.Row>
<input
type='text'
onChange={event => setSearch(event.target.value)}
/>
<Button onClick={() => searchRequestsRequested(search)}>
Søk
</Button>
</SC.Row>
</div>
</SC.FirstRow>
<SC.RequestsTitleRow>
<SC.RequestTitle>
Expand Down

0 comments on commit db52db2

Please sign in to comment.