-
Notifications
You must be signed in to change notification settings - Fork 1
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
[ITG-64,ITG-41,ITG-42] Routing and GET task implementation #6
Merged
tgargula
merged 6 commits into
develop
from
feature/ITG-64-przekierowanie-do-szczegolow-zadania
Apr 4, 2022
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c602472
feat(bode): implement GET /tasks/task_id
tgargula 7e9c46b
feat(cabra): implement routing
tgargula 5c6e361
Merge branch 'develop' into feature/ITG-64-przekierowanie-do-szczegol…
tgargula 87908ee
feat: improve caching
tgargula 1915442
Merge branch 'feature/ITG-64-przekierowanie-do-szczegolow-zadania' of…
tgargula 846bd63
apply PR suggestions
tgargula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,26 +1,20 @@ | ||
import { QueryClient, QueryClientProvider } from "react-query"; | ||
import tw, { styled } from "twin.macro"; | ||
import { Route, Routes } from "react-router-dom"; | ||
|
||
import RandomGoat from "./components/RandomGoat"; | ||
import TaskForm from "./components/TaskForm"; | ||
import TasksList from "./components/TasksList"; | ||
import HomePage from "./pages/Home"; | ||
import NotFoundPage from "./pages/NotFound"; | ||
import TaskDetailsPage from "./pages/TaskDetails"; | ||
|
||
const queryClient = new QueryClient(); | ||
const Container = styled.div` | ||
${tw`flex flex-col items-center h-screen py-10 overflow-auto max-h-screen`} | ||
${tw`bg-gradient-to-b from-blue-700 to-fuchsia-500`} | ||
`; | ||
|
||
export default function App() { | ||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<Container> | ||
<div tw="w-[90%] max-w-xl space-y-6 relative z-10"> | ||
<TaskForm /> | ||
<TasksList /> | ||
</div> | ||
</Container> | ||
<RandomGoat /> | ||
<Routes> | ||
<Route path="/" element={<HomePage />}></Route> | ||
<Route path="/task/:id" element={<TaskDetailsPage />}></Route> | ||
<Route path="*" element={<NotFoundPage />}></Route> | ||
</Routes> | ||
</QueryClientProvider> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import tw, { styled } from "twin.macro"; | ||
|
||
import RandomGoat from "./components/RandomGoat"; | ||
import TaskForm from "./components/TaskForm"; | ||
import TasksList from "./components/TasksList"; | ||
|
||
const Container = styled.div` | ||
${tw`flex flex-col items-center h-screen py-10 overflow-auto max-h-screen`} | ||
${tw`bg-gradient-to-b from-blue-700 to-fuchsia-500`} | ||
`; | ||
tgargula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default function HomePage() { | ||
return ( | ||
<> | ||
<Container> | ||
<div tw="w-[90%] max-w-xl space-y-6 relative z-10"> | ||
<TaskForm /> | ||
<TasksList /> | ||
</div> | ||
</Container> | ||
<RandomGoat /> | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import tw, { styled } from "twin.macro"; | ||
|
||
import { Link } from "react-router-dom"; | ||
import RandomGoat from "./components/RandomGoat"; | ||
|
||
const Container = styled.div` | ||
${tw`flex flex-col items-center h-screen py-10 overflow-auto max-h-screen`} | ||
${tw`bg-gradient-to-b from-blue-700 to-fuchsia-500`} | ||
`; | ||
|
||
export default function NotFoundPage() { | ||
return ( | ||
<Container> | ||
<Link to="/">Take me home</Link> | ||
<RandomGoat /> | ||
</Container> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import tw, { styled } from "twin.macro"; | ||
import { useNavigate, useParams } from "react-router-dom"; | ||
|
||
import { ITask } from "../types/task"; | ||
import Task from "./components/Task"; | ||
import axios from "axios"; | ||
import { useQuery } from "react-query"; | ||
|
||
const Container = styled.div` | ||
${tw`flex flex-col items-center h-screen py-10 overflow-auto max-h-screen`} | ||
${tw`bg-gradient-to-b from-blue-700 to-fuchsia-500`} | ||
`; | ||
|
||
export default function TaskDetailsPage() { | ||
const navigate = useNavigate(); | ||
const { id } = useParams(); | ||
const { data, isLoading } = useQuery( | ||
"task", | ||
() => axios.get<ITask>(`/tasks/${id}`), | ||
{ onError: () => navigate("/not-found", { replace: true }), retry: 1 } | ||
); | ||
|
||
if (isLoading || data?.data?.id !== id) return <Container>Loading</Container>; | ||
|
||
return ( | ||
<> | ||
tgargula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Container> | ||
<button tw="text-purple-800 font-black" onClick={() => navigate(-1)}> | ||
{"<"} go back | ||
</button> | ||
{data ? ( | ||
<div tw="w-[90%] max-w-xl space-y-6 relative z-10"> | ||
<Task task={data.data} detailsLink={false}></Task> | ||
</div> | ||
) : ( | ||
<div>Loading</div> | ||
)} | ||
</Container> | ||
</> | ||
); | ||
} |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import "twin.macro"; | ||
|
||
import { ITask } from "../../types/task"; | ||
import { Link } from "react-router-dom"; | ||
|
||
interface Props { | ||
task: ITask; | ||
detailsLink: boolean; | ||
} | ||
|
||
export default function Task({ task, detailsLink }: Props) { | ||
return ( | ||
<div tw="rounded-xl w-full bg-white shadow-2xl text-blue-800 text-xl p-4 md:text-2xl flex justify-between items-center"> | ||
{task.title} | ||
{detailsLink ? ( | ||
<Link | ||
tw="underline text-blue-600 text-lg hover:text-purple-800" | ||
to={`/task/${task.id}` } | ||
state={{ task }} | ||
> | ||
Details | ||
</Link> | ||
) : null} | ||
</div> | ||
); | ||
} |
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
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.
DataError
is caught and also responds with 404 (line 32)@bkulawska please, test if your implementation of
DELETE
works. I got some errors in anabort
function when I tried to passmessage
kwarg as you did.