From 0bd9c7a348ab9933e0ca2d83b3467fbaf321e9a7 Mon Sep 17 00:00:00 2001 From: louai98 Date: Thu, 30 Nov 2023 15:11:35 +0100 Subject: [PATCH] Update --- src/Components/Layout/Filter/Filter.js | 23 ++++++++++------------- src/Context/URLContext.js | 13 +++++++++++++ 2 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 src/Context/URLContext.js diff --git a/src/Components/Layout/Filter/Filter.js b/src/Components/Layout/Filter/Filter.js index 218b742..be411e3 100644 --- a/src/Components/Layout/Filter/Filter.js +++ b/src/Components/Layout/Filter/Filter.js @@ -1,9 +1,8 @@ -import React, { useEffect, useState } from "react"; +import React, { useContext, useEffect, useState } from "react"; import Dropdown from "react-bootstrap/Dropdown"; import classes from "../../../Static/styles.module.css"; import ToggleButton from "react-bootstrap/esm/ToggleButton"; import ToggleButtonGroup from "react-bootstrap/esm/ToggleButtonGroup"; -import filterClasses from "./Filter.module.css"; import axios from "axios"; @@ -11,11 +10,6 @@ const Filter = (props) => { const [levels, setLevels] = useState([]); const [standards, setStandards] = useState([]); - // Function to clear selected standards - const clearSelectedStandards = () => { - props.setStandardsFilter([]); // Set standardsFilter to an empty array - }; - // get the filters values to this component const handelOnFilterChange = (val) => { props.setStandardsFilter(val); @@ -24,14 +18,17 @@ const Filter = (props) => { useEffect(() => { axios - .get("http://127.0.0.1:8000/client_api/levels/") - .then((response) => setLevels(response.data)) + .get("http://localhost:8000/data_api/levels/") + .then((response) => { + setLevels(response.data); + console.log(response.data); + }) .catch((error) => console.log(error)); }, []); useEffect(() => { axios - .get("http://127.0.0.1:8000/client_api/standards/") + .get("http://localhost:8000/data_api/standards/") .then((response) => setStandards(response.data)) .catch((error) => console.log(error)); }, []); @@ -47,7 +44,7 @@ const Filter = (props) => { id={level.id} className={classes["level-" + level.levelNumber]} > - {level.levelName} + {level.levelTitle} @@ -60,7 +57,7 @@ const Filter = (props) => { > {standards .filter( - (standard) => standard.standardLevel === level.levelNumber + (standard) => standard.levelNumber === level.levelNumber ) .map((standard, index) => ( { variant="outline-secondary" key={standard.id} id={`std-btn-${standard.id}`} - className={classes[`list-items-${standard.standardLevel}`]} + className={classes[`list-items-${standard.levelNumber}`]} value={standard.standardTitle} > {standard.standardTitle} diff --git a/src/Context/URLContext.js b/src/Context/URLContext.js new file mode 100644 index 0000000..e9da22c --- /dev/null +++ b/src/Context/URLContext.js @@ -0,0 +1,13 @@ +import { createContext } from "react"; + +const URLContext = createContext(); + +export default URLContext; + +export const URLProvider = ({ children }) => { + // const url = "http://localhost:8000/admin_api"; + const url = "http://localhost:8000"; + return ( + {children} + ); +};