Skip to content

Commit

Permalink
Changes Done
Browse files Browse the repository at this point in the history
  • Loading branch information
saxenaaman628 committed Mar 31, 2021
1 parent 6570ddc commit e84e22b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
16 changes: 9 additions & 7 deletions src/components/tasks/mine_card/index.tsx
Expand Up @@ -6,12 +6,14 @@ type Props = {
content: task,
};

const informationElement = (title: string, value: string) => (
<span className={classNames.statusElement}>
<span className={classNames.statusLable}>{`${title}: `}</span>
<strong>{value}</strong>
</span>
);
function informationElement(title: string, value: string) {
return (
<span className={classNames.statusElement}>
<span className={classNames.statusLable}>{`${title}: `}</span>
<strong>{value}</strong>
</span>
);
}

const Card: FC<Props> = ({ content }) => {
const {
Expand All @@ -25,7 +27,7 @@ const Card: FC<Props> = ({ content }) => {
<span className={classNames.prTitle}>{title}</span>
{informationElement('Started', startedOn)}
{informationElement('Status', status)}

</div>
);
};
Expand Down
34 changes: 15 additions & 19 deletions src/pages/mine.tsx
@@ -1,4 +1,4 @@
import { FC,useState, useEffect } from 'react';
import { FC, useState, useEffect } from 'react';
import Head from '@/components/head';
import Layout from '@/components/Layout';
import Card from '@/components/tasks/mine_card';
Expand All @@ -8,39 +8,37 @@ import { task } from '@/components/constants/types';

const TASKS_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/tasks/self`;


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

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

useEffect(() => {
if ('tasks' in response) {
setTasks(response.tasks);

}
if ('tasks' in response) { setTasks(response.tasks); }
}, [isLoading, response]);
return(
<Layout>
<Head title="Mine" />
<div className={classNames.container}>
return (
<Layout>
<Head title="Mine" />
<div className={classNames.container}>
{!!error && <p>Something went wrong, please contact admin!</p>}
{
isLoading
? (
<p>Loading...</p>
) : (

<>
{
Object.keys(tasks).length > 0
? (
tasks.length > 0
? (
<div>
{CardList(tasks)}
</div>
Expand All @@ -50,9 +48,7 @@ const Mine: FC = () => {
)
}
</div>
</Layout>
</Layout>
);
};

export default Mine;

0 comments on commit e84e22b

Please sign in to comment.