-
Notifications
You must be signed in to change notification settings - Fork 2
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 #5 from Genesis-Solutions/00-components
00 components
- Loading branch information
Showing
13 changed files
with
527 additions
and
108 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,59 +1,19 @@ | ||
import { useDispatch, useSelector } from "react-redux" | ||
import { setUsers } from "./states/generalSlice" | ||
import Card from "./components/Card" | ||
import { useForm } from "react-hook-form" | ||
import { createUser, readUsers } from "./queries/query" | ||
import { useEffect } from "react" | ||
import MapContainer from "./components/MapContainer" | ||
|
||
function App() { | ||
const users = useSelector((state) => state.general.users) | ||
const dispatch = useDispatch() | ||
|
||
const { register, handleSubmit } = useForm() | ||
|
||
const onSubmit = async (data) => { | ||
const response = await createUser(data) | ||
|
||
dispatch(setUsers(response)) | ||
} | ||
|
||
useEffect(() => { | ||
readUsers() | ||
.then((response) => { | ||
|
||
if (response) { | ||
dispatch(setUsers(response)) | ||
} | ||
}) | ||
}, []) | ||
import { BrowserRouter, Route, Routes } from "react-router-dom"; | ||
import Page from "./pages/page"; | ||
import Layout from "./components/Layout"; | ||
|
||
const App = () => { | ||
return ( | ||
<div className="w-full h-full "> | ||
<form className="flex flex-col w-1/6" onSubmit={ handleSubmit(onSubmit) }> | ||
<label htmlFor="username">Username: </label> | ||
<input className="border-2 border-gray-400" type="text" id="username" placeholder="Username" {...register("username")} /> | ||
<label htmlFor="image">Image: </label> | ||
<input type="file" id="image" {...register("urlImg")}/> | ||
<button | ||
className="p-1 border-2 border-black bg-slate-300 " | ||
> | ||
Enviar Usuario | ||
</button> | ||
</form> | ||
|
||
<div> | ||
<ul> | ||
{ users.map((user, id) => ( | ||
<Card key={id} user={ user }/> | ||
)) } | ||
</ul> | ||
</div> | ||
<div> | ||
<MapContainer /> | ||
</div> | ||
<div className="App w-full h-full"> | ||
<BrowserRouter> | ||
<Routes> | ||
<Route element={<Layout />}> | ||
<Route path="/" element={<Page />} /> | ||
</Route> | ||
</Routes> | ||
</BrowserRouter> | ||
</div> | ||
) | ||
} | ||
); | ||
}; | ||
|
||
export default App | ||
export default App; |
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,32 @@ | ||
import React from "react"; | ||
|
||
/** | ||
* This is a component for a button. | ||
* | ||
* @param {string} text - The text the button will display. | ||
* @param {string} type - The type of the button. | ||
* @param {string} colorBg - The color of the background of the button. Example: bg-red-600 | ||
* @param {string} colorHoverBg- The color of the background of the button when hover. Example: hover:bg-red-700 | ||
* @param {function} action- The path that will navigate to. | ||
* @returns {JSX.Element} The JSX element displaying a button. | ||
*/ | ||
|
||
const Button = ({ text, type, colorBg, colorHoverBg, action }) => { | ||
const styles = [ | ||
"w-full", | ||
colorBg, | ||
"text-white", | ||
"text-sm", | ||
"p-2", | ||
"rounded-lg", | ||
colorHoverBg, | ||
]; | ||
|
||
return ( | ||
<button className={styles.join(" ")} type={type} onClick={action}> | ||
{text} | ||
</button> | ||
); | ||
}; | ||
|
||
export default Button; |
Oops, something went wrong.