generated from Real-Dev-Squad/website-template
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
74cb1b3
Adding mine
saxenaaman628 ae3c57e
Completed Mine Task
saxenaaman628 aa1f377
Adding mine
saxenaaman628 6570ddc
Completed Mine Task
saxenaaman628 e84e22b
Changes Done
saxenaaman628 5445555
Test
saxenaaman628 a7dfa4b
Handled error
saxenaaman628 4844faa
Handled error
saxenaaman628 4e30f27
Handled error
saxenaaman628 cd87580
Removed mine_card
saxenaaman628 cd351f1
Remove Mine_card
saxenaaman628 6418e06
Remove Mine_card
saxenaaman628 44a2aac
Update mine.tsx
saxenaaman628 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,54 @@ | ||
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> | ||
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; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
both the lines are shown...
Please show only error in case of error