-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add new plan card * feat: differentiate the different ip's in the database * feat: add a new room in database * feat: dislay name of room in api * feat: sorted all data by ip * feat: put the data in cardPlanElement * feat:change button for selected month, change function add room, change plan style * feat: add floor plan elements with sensors * feat: add a circle to the svg with the esp coordinates in the database
- Loading branch information
Showing
17 changed files
with
462 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/src/contexts/SampleContext.tsx | ||
/test.http | ||
|
||
# Logs | ||
|
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
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,4 @@ | ||
export const SampleContext = { | ||
urlData: "http://postgrest.memoires-info.com", | ||
urlLogin: "http://login.memoires-info.com" | ||
}; |
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
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 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,70 @@ | ||
import {useState} from "react"; | ||
import {SampleContext} from "@/contexts/SampleContext.tsx"; | ||
import {getToken} from "@/contexts/lib.tsx"; | ||
|
||
export default function AddRoomElement() { | ||
const apiAuthToken = getToken(); | ||
|
||
const [roomName, setRoomName] = useState(''); | ||
const [newIp, setNewIp] = useState(''); | ||
const [error, setError] = useState<string>(""); | ||
|
||
const addRoom = () => { | ||
if (roomName && newIp) { | ||
fetch(`${SampleContext.urlData}/esp`, { | ||
method: 'POST', | ||
headers: { | ||
'Authorization': `Bearer ${apiAuthToken}`, | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
ip: newIp, | ||
name: roomName | ||
}) | ||
}) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error('Erreur lors de la requête'); | ||
} | ||
console.log('Requête POST réussie'); | ||
}) | ||
.catch(error => { | ||
console.error('Une erreur s\'est produite:', error); | ||
}); | ||
setNewIp("") | ||
setRoomName("") | ||
setError("") | ||
} else setError("veuillez remplir le champ") | ||
|
||
} | ||
|
||
return ( | ||
<> | ||
<form className="flex gap-8 h-8" onSubmit={(e) => { | ||
e.preventDefault(); | ||
addRoom(); | ||
}}> | ||
<input | ||
value={roomName} | ||
autoComplete={"roomName"} | ||
onChange={(e) => setRoomName(e.target.value)} | ||
className="mt-5 tracking-wide font-semibold text-white-500 w-full px-4 py-4 rounded-lg transition-all duration-300 ease-in-out flex items-center justify-center focus:shadow-outline focus:outline-none" | ||
type="text" placeholder="Room name"/> | ||
|
||
<input | ||
value={newIp} | ||
autoComplete={"newIp"} | ||
onChange={(e) => setNewIp(e.target.value)} | ||
className="mt-5 tracking-wide font-semibold text-white-500 w-full px-4 py-4 rounded-lg transition-all duration-300 ease-in-out flex items-center justify-center focus:shadow-outline focus:outline-none" | ||
type="text" placeholder="New IP"/> | ||
|
||
<button | ||
type="submit" | ||
className="mt-5 tracking-wide font-semibold bg-blue-400 text-white-500 w-full py-4 rounded-lg hover:bg-blue-700 transition-all duration-300 ease-in-out flex items-center justify-center focus:shadow-outline focus:outline-none"> | ||
Add a room | ||
</button> | ||
</form> | ||
{error} | ||
</> | ||
) | ||
} |
Oops, something went wrong.