-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from it-goats/feature/ITG-64-przekierowanie-do-…
…szczegolow-zadania [ITG-64,ITG-41,ITG-42] Routing and GET task implementation
- Loading branch information
Showing
14 changed files
with
156 additions
and
42 deletions.
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,18 @@ | ||
import "twin.macro"; | ||
|
||
import Layout from "./components/Layout"; | ||
import RandomGoat from "./components/RandomGoat"; | ||
import TaskForm from "./components/TaskForm"; | ||
import TasksList from "./components/TasksList"; | ||
|
||
export default function HomePage() { | ||
return ( | ||
<Layout> | ||
<div tw="w-[90%] max-w-xl space-y-6 relative z-10"> | ||
<TaskForm /> | ||
<TasksList /> | ||
</div> | ||
<RandomGoat /> | ||
</Layout> | ||
); | ||
} |
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,14 @@ | ||
import "twin.macro"; | ||
|
||
import Layout from "./components/Layout"; | ||
import { Link } from "react-router-dom"; | ||
import RandomGoat from "./components/RandomGoat"; | ||
|
||
export default function NotFoundPage() { | ||
return ( | ||
<Layout> | ||
<Link to="/">Take me home</Link> | ||
<RandomGoat /> | ||
</Layout> | ||
); | ||
} |
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,36 @@ | ||
import "twin.macro"; | ||
|
||
import { useNavigate, useParams } from "react-router-dom"; | ||
|
||
import { ITask } from "../types/task"; | ||
import Layout from "./components/Layout"; | ||
import Task from "./components/Task"; | ||
import axios from "axios"; | ||
import { useQuery } from "react-query"; | ||
|
||
export default function TaskDetailsPage() { | ||
const navigate = useNavigate(); | ||
const { id } = useParams(); | ||
const { data, isLoading } = useQuery( | ||
["task", id], | ||
() => axios.get<ITask>(`/tasks/${id}`), | ||
{ onError: () => navigate("/not-found", { replace: true }), retry: 1 } | ||
); | ||
|
||
if (isLoading) return <Layout>Loading</Layout>; | ||
|
||
return ( | ||
<Layout> | ||
<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> | ||
)} | ||
</Layout> | ||
); | ||
} |
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,8 @@ | ||
import tw, { styled } from 'twin.macro'; | ||
|
||
const Layout = 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 Layout; |
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