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

Merge develop in main #112

Merged
merged 31 commits into from Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
74cb1b3
Adding mine
saxenaaman628 Mar 17, 2021
ae3c57e
Completed Mine Task
saxenaaman628 Mar 19, 2021
2df18ac
[feature] Added pagination to PRs
correaswebert Mar 22, 2021
58aebb4
[fix] address issues mentioned for PRs components
correaswebert Mar 25, 2021
4075e20
Merge branch 'develop' of https://github.com/Real-Dev-Squad/website-s…
correaswebert Mar 25, 2021
7c0f930
[fix] indentation issues
correaswebert Mar 27, 2021
aa1f377
Adding mine
saxenaaman628 Mar 17, 2021
6570ddc
Completed Mine Task
saxenaaman628 Mar 19, 2021
e84e22b
Changes Done
saxenaaman628 Mar 31, 2021
5445555
Test
saxenaaman628 Apr 1, 2021
a7dfa4b
Handled error
saxenaaman628 Apr 7, 2021
4844faa
Handled error
saxenaaman628 Apr 7, 2021
4e30f27
Handled error
saxenaaman628 Apr 7, 2021
7e1c7c9
Keep the accordion open by default
Rucha1499 Apr 7, 2021
22aa2d7
Merge pull request #108 from Rucha1499/feat/active-task-open
whyDontI Apr 7, 2021
cd87580
Removed mine_card
saxenaaman628 Apr 8, 2021
cd351f1
Remove Mine_card
saxenaaman628 Apr 8, 2021
6418e06
Remove Mine_card
saxenaaman628 Apr 8, 2021
44a2aac
Update mine.tsx
saxenaaman628 Apr 8, 2021
a5dc91e
Merge pull request #89 from saxenaaman628/mine
whyDontI Apr 10, 2021
6489db4
Error handling
whyDontI Apr 10, 2021
e2861d1
Merge branch 'develop' of https://github.com/Real-Dev-Squad/website-s…
whyDontI Apr 10, 2021
44fe8d5
develop
whyDontI Apr 10, 2021
c46a9b1
Merge branch 'develop' of https://github.com/Real-Dev-Squad/website-s…
whyDontI Apr 10, 2021
6c8eab7
Merge pull request #91 from correaswebert/pagination
whyDontI Apr 10, 2021
5c70b0d
added horizontal margins
kamara-moses Apr 10, 2021
3d22751
issue/93 - Accordion width updated and centered in the parent(task co…
sebuelias Apr 10, 2021
1e54d21
Merge pull request #111 from sebuelias/fix/93/Accordion-width
whyDontI Apr 10, 2021
875a3dd
Merge branch 'develop' of https://github.com/Real-Dev-Squad/website-s…
whyDontI Apr 10, 2021
9fa16be
Decrease padding
whyDontI Apr 10, 2021
e7663e5
Merge pull request #109 from kamara-moses/develop
whyDontI Apr 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/Accordion/Accordion.module.scss
@@ -1,7 +1,7 @@
.container {
border-radius: 10px;
margin-bottom: 1rem;
min-width: 800px;
width: 750px;

@media (max-width: 767px) {
min-width: 300px;
Expand All @@ -21,6 +21,7 @@
cursor: pointer;
border: none;
text-transform: capitalize;
margin: 0 10px;

&:focus {
outline: none;
Expand All @@ -32,7 +33,7 @@
}

.content {
padding: 2rem;
padding: 1rem;
display: flex;
justify-content: center;
display: none;
Expand Down
5 changes: 3 additions & 2 deletions src/components/Accordion/index.tsx
Expand Up @@ -3,10 +3,11 @@ import styles from '@/components/Accordion/Accordion.module.scss';

type Props = {
title: string,
open: boolean
};

const Accordion: FC<Props> = ({ title, children }) => {
const [isOpen, setIsOpen] = useState(false);
const Accordion: FC<Props> = ({ title, open = true, children }) => {
const [isOpen, setIsOpen] = useState(open);

function toggle() {
setIsOpen(!isOpen);
Expand Down
2 changes: 2 additions & 0 deletions src/components/Layout/index.tsx
Expand Up @@ -34,6 +34,8 @@ const Layout: FC<Props> = ({ children }) => (
<div className={styles.header}>
{navBarContent('Tasks', '/')}
|
{navBarContent('Mine', '/mine')}
|
{navBarContent('DS', '/challenges')}
|
{navBarContent('Open PRs', '/openPRs')}
Expand Down
19 changes: 19 additions & 0 deletions src/components/PullRequestList/PullRequestList.module.scss
@@ -0,0 +1,19 @@
.center_text {
font-size: 1.5em;
text-align: center;
}

.pagination {
display: flex;
justify-content: center;
}

.pagination_btn {
margin: 1rem;
padding: 1rem;
font-size: 1.5em;
cursor: pointer;
border: none;
background-color: #bfbfbf;
border-radius: 5px;
}
110 changes: 110 additions & 0 deletions src/components/PullRequestList/index.tsx
@@ -0,0 +1,110 @@
import { FC, useState, useEffect } from 'react';
import Head from '@/components/head';
import Layout from '@/components/Layout';
import PullRequest from '@/components/pullRequests';
import CardShimmer from '@/components/Loaders/cardShimmer';
import axios from 'axios';
import styles from './PullRequestList.module.scss';

type pullRequestType = {
title: string;
username: string;
createdAt: string;
updatedAt: string;
url: string;
};

type PullRequestListProps = {
prType: string;
};

const PullRequestList: FC<PullRequestListProps> = ({ prType }) => {
const [pullRequests, setPullRequests] = useState<pullRequestType[]>([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState('');
const [page, setPage] = useState(1);

const prUrl = `${process.env.NEXT_PUBLIC_BASE_URL}/pullrequests/${prType}?page=${page}`;

const fetchPRs = async () => {
try {
setLoading(true);
const response = await axios.get(prUrl);
setPullRequests(response.data.pullRequests);

if (!response.data.pullRequests.length) {
setError(`No more ${prType} PRs...`);
} else {
setError('');
}
} catch (err) {
setPullRequests([]);
setError('Error fetching pull requests!');
} finally {
setLoading(false);
}
};

const handlePrev = () => {
setPage(page > 1 ? page - 1 : 1);
};

const handleNext = () => {
setPage(pullRequests.length ? page + 1 : page);
};

useEffect(() => {
fetchPRs();
}, [page]);

const getPRs = () => pullRequests.map((pullRequest: pullRequestType) => {
const {
title, username, createdAt, updatedAt, url: link,
} = pullRequest;
return (
<PullRequest
key={link}
title={title}
username={username}
createdAt={createdAt}
updatedAt={updatedAt}
url={link}
/>
);
});

return (
<Layout>
<Head title="PRs" />

<div className="container">
{loading
? [...Array(10)].map((e: number) => <CardShimmer key={e} />)
: getPRs()}
</div>
{error ? <p className={styles.center_text}>{error}</p> : ''}

<div className={styles.pagination}>
<button
className={styles.pagination_btn}
type="button"
onClick={handlePrev}
disabled={page <= 1}
>
Prev
</button>

<button
className={styles.pagination_btn}
type="button"
onClick={handleNext}
disabled={pullRequests.length === 0}
>
Next
</button>
</div>
</Layout>
);
};

export default PullRequestList;
4 changes: 2 additions & 2 deletions src/pages/index.tsx
Expand Up @@ -49,10 +49,10 @@ const Index: FC = () => {
{
Object.keys(filteredTask).length > 0
? Object.keys(filteredTask).map((key) => (
<Accordion title={key} key={key}>
<Accordion open title={key} key={key}>
{renderCardList(filteredTask[key])}
</Accordion>
)) : 'No Tasks Found'
)) : (!error && 'No Tasks Found')
}
</>
)
Expand Down
58 changes: 52 additions & 6 deletions src/pages/mine.tsx
@@ -1,11 +1,57 @@
import { FC } from 'react';
import { FC, useState, useEffect } from 'react';
import Head from '@/components/head';
import Layout from '@/components/Layout';
import Card from '@/components/tasks/card';
import useFetch from '@/hooks/useFetch';
import classNames from '@/styles/tasks.module.scss';
import { task } from '@/components/constants/types';

const Mine: FC = () => (
<Layout>
<Head title="Mine" />
</Layout>
);
const TASKS_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/task/self`;

function CardList(tasks: task[]) {
return tasks.map(
(item: task) => <Card content={item} key={item.id} />,
);
}

const Mine: FC = () => {
const [tasks, setTasks] = useState<task[]>([]);
const {
response,
error,
isLoading,
} = useFetch(TASKS_URL);

useEffect(() => {
if ('tasks' in response) { setTasks(response.tasks); }
}, [isLoading, response]);
return (
<Layout>
<Head title="Mine" />
<div className={classNames.container}>
{
!!error
&& <p>Something went wrong, please contact admin!</p>
}
{
isLoading
? (
<p>Loading...</p>
) : (
<>
{
tasks.length > 0
? (
<div>
{CardList(tasks)}
</div>
) : (!error && 'No Tasks Found')
}
</>
)
}
</div>
</Layout>
);
};
export default Mine;
77 changes: 3 additions & 74 deletions src/pages/openPRs.tsx
@@ -1,77 +1,6 @@
import { FC, useState, useEffect } from 'react';
import Head from '@/components/head';
import Layout from '@/components/Layout';
import PullRequest from '@/components/pullRequests';
import fetch from '@/helperFunctions/fetch';
import CardShimmer from '@/components/Loaders/cardShimmer';
import { FC } from 'react';
import PullRequestList from '@/components/PullRequestList';

type pullRequestType = {
title: string;
username: string;
createdAt: string;
updatedAt: string;
url: string;
};

const openPRs: FC = () => {
const [pullRequests, setPullRequests] = useState<pullRequestType[]>([]);
const [loading, setLoading] = useState(false);

useEffect(() => {
(async () => {
setLoading(true);
const response = await fetch({
url: `${process.env.NEXT_PUBLIC_BASE_URL}/pullrequests/open`,
});
setPullRequests(response.data.pullRequests);
setLoading(false);
})();
}, []);

const getPRs = () => pullRequests.map((pullRequest: pullRequestType) => {
const {
title, username, createdAt, updatedAt, url: link,
} = pullRequest;
return (
<>
<PullRequest
key={link}
title={title}
username={username}
createdAt={createdAt}
updatedAt={updatedAt}
url={link}
/>
</>
);
});

return (
<Layout>
<Head title="Open PRs" />

<div className="container">
{
loading ? (
<>
<CardShimmer />
<CardShimmer />
<CardShimmer />
<CardShimmer />
<CardShimmer />
<CardShimmer />
<CardShimmer />
<CardShimmer />
<CardShimmer />
<CardShimmer />
</>
) : (
getPRs())
}

</div>
</Layout>
);
};
const openPRs: FC = () => <PullRequestList prType="open" />;

export default openPRs;
31 changes: 3 additions & 28 deletions src/pages/stale-pr.tsx
@@ -1,31 +1,6 @@
import { FC, useState, useEffect } from 'react';
import Head from '@/components/head';
import Section from '@/components/pullRequests/section';
import Layout from '@/components/Layout';
import fetch from '@/helperFunctions/fetch';
import { FC } from 'react';
import PullRequestList from '@/components/PullRequestList';

const stalePR: FC = () => {
const [pullRequests, setPullRequests] = useState<[]>([]);

useEffect(() => {
(async () => {
const res = await fetch({
url: `${process.env.NEXT_PUBLIC_BASE_URL}/pullrequests/stale`,
});
setPullRequests(res.data.pullRequests);
})();
}, []);

return (
<div>
<Layout>
<Head title="Stale PRs" />
<div className="container">
<Section heading="Stale PRs" content={pullRequests} />
</div>
</Layout>
</div>
);
};
const stalePR: FC = () => <PullRequestList prType="stale" />;

export default stalePR;
1 change: 1 addition & 0 deletions src/styles/tasks.module.scss
@@ -1,6 +1,7 @@
.container {
display: flex;
flex-direction: column;
align-items: center;
flex-wrap: nowrap;
text-align: center;
}
Expand Down