Skip to content

Commit

Permalink
feat: make requests clickable (#1787)
Browse files Browse the repository at this point in the history
  • Loading branch information
hegeaal committed Oct 20, 2023
1 parent d528e5a commit f9d6e55
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
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

0 comments on commit f9d6e55

Please sign in to comment.