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
Completed Mine Task #89
Changes from 2 commits
74cb1b3
ae3c57e
aa1f377
6570ddc
e84e22b
5445555
a7dfa4b
4844faa
4e30f27
cd87580
cd351f1
6418e06
44a2aac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.card { | ||
border: 0.2em solid black; | ||
border-radius: 0.5em; | ||
padding: 1em; | ||
display: flex; | ||
flex-direction: column; | ||
flex-wrap: wrap; | ||
margin-bottom: 2em; | ||
cursor: pointer; | ||
} | ||
|
||
.prTitle { | ||
color: #041484; | ||
font-size: 1.5rem; | ||
font-weight: bold; | ||
|
||
width: 100%; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.cardFooter { | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
justify-content: space-between; | ||
align-items: right; | ||
width: 100%; | ||
} | ||
|
||
|
||
.statusLable { | ||
color: grey; | ||
font-weight: bold; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { FC } from 'react'; | ||
import classNames from '@/components/tasks/mine_card/card.module.scss'; | ||
import { task } from '@/components/constants/types'; | ||
|
||
type Props = { | ||
content: task, | ||
}; | ||
|
||
const informationElement = (title: string, value: string) => ( | ||
<span className={classNames.statusElement}> | ||
<span className={classNames.statusLable}>{`${title}: `}</span> | ||
<strong>{value}</strong> | ||
</span> | ||
); | ||
|
||
const Card: FC<Props> = ({ content }) => { | ||
const { | ||
title, | ||
startedOn, | ||
status, | ||
} = content; | ||
|
||
return ( | ||
<div className={classNames.card}> | ||
<span className={classNames.prTitle}>{title}</span> | ||
{informationElement('Started', startedOn)} | ||
{informationElement('Status', status)} | ||
|
||
</div> | ||
); | ||
}; | ||
|
||
export default Card; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,58 @@ | ||
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/mine_card'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like we don't need the mine_card component as described in previous comment |
||
import useFetch from '@/hooks/useFetch'; | ||
import classNames from '@/styles/tasks.module.scss'; | ||
import { task } from '@/components/constants/types'; | ||
|
||
const Mine: FC = () => ( | ||
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} />); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could shift the arrow fn body to the next line OR |
||
|
||
const Mine: FC = () => { | ||
let [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>} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. both the lines are shown...
Please show only error in case of error |
||
{ | ||
isLoading | ||
? ( | ||
<p>Loading...</p> | ||
) : ( | ||
|
||
<> | ||
{ | ||
Object.keys(tasks).length > 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess just |
||
? ( | ||
<div> | ||
{CardList(tasks)} | ||
</div> | ||
) : 'No Tasks Found' | ||
} | ||
</> | ||
) | ||
} | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an extreme amount of white spaces <div className={classNames.container}>
{!!error && <p>Something went wrong, please contact admin!</p>}
{isLoading ? (
<p>Loading...</p>
) : (
tasks.length > 0 ? <div>{CardList(tasks)}</div> : "No Tasks Found"
)}
</div> |
||
</Layout> | ||
); | ||
); | ||
}; | ||
|
||
export default Mine; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could convert this into a component instead of a function