Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make requests clickable #1787

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/pages/requests/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React, { FC, useEffect } from 'react';
import { compose } from 'redux';
import withCommunity, {
Props as CommunityProps
} from '../../components/with-community';
import { compose } from 'redux';
import withErrorBoundary from '../../components/with-error-boundary';
import ErrorPage from '../error-page';
import SC from './styled';
import { formatDate } from '../../lib/date-utils';
import env from '../../env';

const { FDK_COMMUNITY_BASE_URI } = env;

interface Props extends CommunityProps {}

Expand All @@ -18,6 +21,10 @@ const RequestsPage: FC<Props> = ({
getCommunityRequests();
}, []);

const notDeletedRequests = requests?.topics?.filter(
topic => topic.deleted === 0
);

return (
<main id='content' className='container'>
<SC.RequestsTitleRow>
Expand All @@ -26,10 +33,14 @@ const RequestsPage: FC<Props> = ({
<SC.RequestInfo>Antall stemmer</SC.RequestInfo>
<SC.RequestInfo>Antall visninger</SC.RequestInfo>
</SC.RequestsTitleRow>
{requests?.topics &&
requests.topics.map(topic => (
{notDeletedRequests &&
notDeletedRequests.map(topic => (
<SC.RequestRow key={topic.cid}>
<SC.RequestTitle>{topic.title}</SC.RequestTitle>
<SC.RequestLink
href={`${FDK_COMMUNITY_BASE_URI}/topic/${topic.slug}`}
>
{topic.title}
</SC.RequestLink>
<SC.RequestInfo>
{formatDate(new Date(topic.timestampISO))}
</SC.RequestInfo>
Expand Down
10 changes: 9 additions & 1 deletion src/pages/requests/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@ const RequestsTitleRow = styled.div`
padding-left: 37px;
padding-right: 37px;
font-weight: bold;
margin-bottom: 5px;
`;

const RequestTitle = styled.div`
width: 50%;
font-weight: bold;
`;
const RequestLink = styled.a`
width: 50%;
font-weight: bold;
text-decoration: underline;
color: #111 !important;
`;

const RequestInfo = styled.div`
width: 16%;
Expand All @@ -40,5 +47,6 @@ export default {
RequestRow,
RequestsTitleRow,
RequestTitle,
RequestInfo
RequestInfo,
RequestLink
};
2 changes: 2 additions & 0 deletions src/types/domain.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,8 @@ export interface CommunityRequest {
postercount: number;
downvotes: number;
upvotes: number;
deleted: 1 | 0;
slug: string;
}

export interface CommunityTeaser {
Expand Down