From e84e22b79254f2165ca694fe2a72a449c8146419 Mon Sep 17 00:00:00 2001 From: Aman Date: Wed, 31 Mar 2021 13:04:14 +0530 Subject: [PATCH] Changes Done --- src/components/tasks/mine_card/index.tsx | 16 ++++++----- src/pages/mine.tsx | 34 +++++++++++------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/components/tasks/mine_card/index.tsx b/src/components/tasks/mine_card/index.tsx index 68e0e7efb..bf75cb1b6 100644 --- a/src/components/tasks/mine_card/index.tsx +++ b/src/components/tasks/mine_card/index.tsx @@ -6,12 +6,14 @@ type Props = { content: task, }; -const informationElement = (title: string, value: string) => ( - - {`${title}: `} - {value} - -); +function informationElement(title: string, value: string) { + return ( + + {`${title}: `} + {value} + + ); +} const Card: FC = ({ content }) => { const { @@ -25,7 +27,7 @@ const Card: FC = ({ content }) => { {title} {informationElement('Started', startedOn)} {informationElement('Status', status)} - + ); }; diff --git a/src/pages/mine.tsx b/src/pages/mine.tsx index 887a07fd6..bc1b47fbd 100644 --- a/src/pages/mine.tsx +++ b/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'; @@ -8,12 +8,14 @@ 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) => ); +function CardList(tasks: task[]) { + return tasks.map( + (item: task) => , + ); +} const Mine: FC = () => { - let [tasks, setTasks] = useState([]); + const [tasks, setTasks] = useState([]); const { response, error, @@ -21,26 +23,22 @@ const Mine: FC = () => { } = useFetch(TASKS_URL); useEffect(() => { - if ('tasks' in response) { - setTasks(response.tasks); - - } + if ('tasks' in response) { setTasks(response.tasks); } }, [isLoading, response]); - return( - - -
+ return ( + + +
{!!error &&

Something went wrong, please contact admin!

} { isLoading ? (

Loading...

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