Update
This commit is contained in:
parent
7b5ede438a
commit
0bd9c7a348
@ -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}
|
||||
</Dropdown.Toggle>
|
||||
|
||||
<Dropdown.Menu className="w-100">
|
||||
@ -60,7 +57,7 @@ const Filter = (props) => {
|
||||
>
|
||||
{standards
|
||||
.filter(
|
||||
(standard) => standard.standardLevel === level.levelNumber
|
||||
(standard) => standard.levelNumber === level.levelNumber
|
||||
)
|
||||
.map((standard, index) => (
|
||||
<ToggleButton
|
||||
@ -69,7 +66,7 @@ const Filter = (props) => {
|
||||
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}
|
||||
|
13
src/Context/URLContext.js
Normal file
13
src/Context/URLContext.js
Normal file
@ -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 (
|
||||
<URLContext.Provider value={{ url: url }}>{children}</URLContext.Provider>
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user