Skip to content

Commit

Permalink
FIX: markers admin part
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Same-kotto authored and Maxime Same-kotto committed Sep 7, 2023
1 parent 9a8577d commit 5fad9ff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/component/AdminMarkerModal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { Button, Container, TextField, Typography, IconButton} from "@mui/material";
import { Button, Container, TextField, Typography, IconButton, Input} from "@mui/material";
import "../styles/component/MarkerModal.css"
import CloseIcon from '@mui/icons-material/Close';
import { useState } from "react";
Expand Down Expand Up @@ -78,6 +78,15 @@ export const AdminMarkerModal = ({closeModal, onSubmit, defaultValue}) => {
<br/>
<TextField onChange={handleChange} name="latitude" defaultValue={formData.latitude} label="Latitude"/>
<br/>
<TextField onChange={handleChange} name="hauteur" defaultValue={formData.latitude} label="Hauteur"/>
<br/>
<TextField onChange={handleChange} name="status" defaultValue={formData.latitude} label="Status"/>
<br/>
Model 3D
<Input type="file"/>
<br/>
Texture
<Input type="file"/>
{errors && <div className="modal-error">{`Please include: ${errors}`}</div>}
<Button className="modal-btn" onClick={handleSubmit}>Soumettre</Button>
</form>
Expand Down
4 changes: 2 additions & 2 deletions src/component/AdminMarkerTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const AdminMarkerTable = ({ rows, editMarker, deleteMarker }) => {
const [rowToEdit, setRowToEdit] = React.useState(null);

const deleteRow = (targetId) => {
deleteMarker(markerStates.markers[targetId]);
deleteMarker(rows[targetId]);
};

const editRow = (id) => {
Expand All @@ -28,7 +28,7 @@ export const AdminMarkerTable = ({ rows, editMarker, deleteMarker }) => {
};

const submitForm = (newRow) => {
markerStates.markers.map((marker, id) => {
rows.map((marker, id) => {
if (id === rowToEdit) {
editMarker(newRow);
}
Expand Down
6 changes: 6 additions & 0 deletions src/component/MarkerModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export const MarkerModal = ({closeModal, onSubmit, defaultValue}) => {
<br/>
<TextField onChange={handleChange} name="latitude" defaultValue={formData.latitude} label="Latitude"/>
<br/>
<TextField onChange={handleChange} name="hauteur" defaultValue={formData.latitude} label="Hauteur"/>
<br/>
<TextField onChange={handleChange} name="model_3D" defaultValue={formData.latitude} label="Model 3D"/>
<br/>
<TextField onChange={handleChange} name="texture" defaultValue={formData.latitude} label="Texture"/>
<br/>
{errors && <div className="modal-error">{`Please include: ${errors}`}</div>}
<Button className="modal-btn" onClick={handleSubmit}>Soumettre</Button>
</form>
Expand Down
8 changes: 7 additions & 1 deletion src/view/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function Admin() {
{ isFocus: false, component: "OrganisationsTable", name: "Organisations" },
{ isFocus: false, component: "ContactTable", name: "Contact" },
{ isFocus: false, component: "NewsletterTable", name: "Newsletter" },
{isFocus: false, component: "MarkersTable", name: "Markers"},
]);
const [table, setTable] = useState(<></>);
const token = localStorage.getItem("token");
Expand Down Expand Up @@ -227,7 +228,6 @@ export default function Admin() {
/>
);
else if (name === "MarkersTable") {
console.log(markers);
return (
<AdminMarkerTable
rows={markers}
Expand Down Expand Up @@ -276,6 +276,12 @@ export default function Admin() {
>
Organisations
</Button>
<Button
title="Markers"
onClick={() => setMenuFocus("Markers")}
>
Markers
</Button>
</Container>
<Container style={{ padding: "20px" }}>{table}</Container>
</Container>
Expand Down

0 comments on commit 5fad9ff

Please sign in to comment.