-
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.
add react-router-dom to options page
- Loading branch information
Showing
14 changed files
with
217 additions
and
155 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
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,5 +1,10 @@ | ||
import { useParams } from "react-router-dom"; | ||
|
||
const SnippetDetails = () => { | ||
return <div>SnippetDetails</div>; | ||
const params = useParams(); | ||
const id = params.id as string; | ||
|
||
return <div>Snippet details for {id}</div>; | ||
}; | ||
|
||
export default SnippetDetails; |
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,4 +1,4 @@ | ||
export { default as Sidebar } from "./SnippetAdd"; | ||
export { default as SnippetList } from "./SnippetList"; | ||
export { default as SnippetAdd } from "./SnippetAdd"; | ||
export { default as SnippetCard } from "./SnippetCard"; | ||
export { default as SnippetDetails } from "./SnippetDetails"; |
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,11 @@ | ||
import { SnippetAdd } from "../components"; | ||
|
||
const Add = () => { | ||
return ( | ||
<div> | ||
<SnippetAdd /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Add; |
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,11 @@ | ||
import { SnippetDetails } from "../components"; | ||
|
||
const Details = () => { | ||
return ( | ||
<div> | ||
<SnippetDetails /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Details; |
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,124 @@ | ||
import { Button, TextField } from "@acme/ui"; | ||
import { Link } from "react-router-dom"; | ||
import type { Snippet } from "../../snippet/model"; | ||
import { useState } from "react"; | ||
import { SnippetList } from "../components"; | ||
|
||
const snippets: Snippet[] = [ | ||
{ | ||
title: "Book Summary", | ||
prompt: "Provide a detailed summary of the book [title] by [author]", | ||
parameters: [ | ||
{ | ||
title: "title", | ||
type: "string", | ||
}, | ||
{ | ||
title: "author", | ||
type: "string", | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
title: "Movie Review", | ||
prompt: | ||
"Write a critical review of the film [title] directed by [director]", | ||
parameters: [ | ||
{ | ||
title: "title", | ||
type: "string", | ||
}, | ||
{ | ||
title: "director", | ||
type: "string", | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
title: "Recipe", | ||
prompt: | ||
"Provide the ingredients and step-by-step instructions to make [dish]", | ||
parameters: [ | ||
{ | ||
title: "dish", | ||
type: "string", | ||
}, | ||
], | ||
}, | ||
{ | ||
title: "Product Description", | ||
prompt: | ||
"Write a detailed product description for [product] highlighting its key features and benefits", | ||
parameters: [ | ||
{ | ||
title: "product", | ||
type: "string", | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
title: "Business Pitch", | ||
prompt: | ||
"Create a one minute elevator pitch for [business] to use when introducing the business", | ||
parameters: [ | ||
{ | ||
title: "business", | ||
type: "string", | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
title: "Research Summary", | ||
prompt: | ||
"Summarize the key findings from the research paper [title] by [author]", | ||
parameters: [ | ||
{ | ||
title: "title", | ||
type: "string", | ||
}, | ||
{ | ||
title: "author", | ||
type: "string", | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
// Search snippet using query | ||
const useSearchSnippet = () => { | ||
const [search, setSearch] = useState(""); | ||
|
||
// Handle input field changes | ||
const onSearchChange = (value: string) => { | ||
setSearch(value); | ||
}; | ||
|
||
return { search, onSearchChange }; | ||
}; | ||
|
||
const Index = () => { | ||
const { search, onSearchChange } = useSearchSnippet(); | ||
|
||
return ( | ||
<> | ||
<div className="my-4 py-3 flex flex-wrap justify-between gap-x-4 gap-y-2 items-end"> | ||
<TextField | ||
onChange={onSearchChange} | ||
className="w-full" | ||
placeholder="Find Snippet" | ||
/> | ||
|
||
<Button className="self-auto" component={Link} to="/add"> | ||
+ Add New | ||
</Button> | ||
</div> | ||
<SnippetList search={search} snippets={snippets} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Index; |
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,4 @@ | ||
export { default as Add } from "./add"; | ||
export { default as Home } from "./home"; | ||
export { default as Details } from "./details"; | ||
export { default as NotFound } from "./not-found"; |
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 { Button, PageMessage } from "@acme/ui"; | ||
import { Link } from "react-router-dom"; | ||
|
||
const NotFound = () => { | ||
return ( | ||
<PageMessage title="Not Found" message="Oops, Don't Wander too far"> | ||
<Link to="/"> | ||
<Button>Back to home</Button> | ||
</Link> | ||
</PageMessage> | ||
); | ||
}; | ||
|
||
export default NotFound; |
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,15 @@ | ||
import { Home, Add, Details, NotFound } from "./pages"; | ||
import { Routes, Route } from "react-router-dom"; | ||
|
||
const routes = () => { | ||
return ( | ||
<Routes> | ||
<Route path="/" element={<Home />} /> | ||
<Route path="/add" element={<Add />} /> | ||
<Route path="/details/:id" element={<Details />} /> | ||
<Route path="*" element={<NotFound />} /> | ||
</Routes> | ||
); | ||
}; | ||
|
||
export default routes; |
Oops, something went wrong.