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 Dropdown from "react-bootstrap/Dropdown";
|
||||||
import classes from "../../../Static/styles.module.css";
|
import classes from "../../../Static/styles.module.css";
|
||||||
import ToggleButton from "react-bootstrap/esm/ToggleButton";
|
import ToggleButton from "react-bootstrap/esm/ToggleButton";
|
||||||
import ToggleButtonGroup from "react-bootstrap/esm/ToggleButtonGroup";
|
import ToggleButtonGroup from "react-bootstrap/esm/ToggleButtonGroup";
|
||||||
import filterClasses from "./Filter.module.css";
|
|
||||||
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
@ -11,11 +10,6 @@ const Filter = (props) => {
|
|||||||
const [levels, setLevels] = useState([]);
|
const [levels, setLevels] = useState([]);
|
||||||
const [standards, setStandards] = 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
|
// get the filters values to this component
|
||||||
const handelOnFilterChange = (val) => {
|
const handelOnFilterChange = (val) => {
|
||||||
props.setStandardsFilter(val);
|
props.setStandardsFilter(val);
|
||||||
@ -24,14 +18,17 @@ const Filter = (props) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
axios
|
axios
|
||||||
.get("http://127.0.0.1:8000/client_api/levels/")
|
.get("http://localhost:8000/data_api/levels/")
|
||||||
.then((response) => setLevels(response.data))
|
.then((response) => {
|
||||||
|
setLevels(response.data);
|
||||||
|
console.log(response.data);
|
||||||
|
})
|
||||||
.catch((error) => console.log(error));
|
.catch((error) => console.log(error));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
axios
|
axios
|
||||||
.get("http://127.0.0.1:8000/client_api/standards/")
|
.get("http://localhost:8000/data_api/standards/")
|
||||||
.then((response) => setStandards(response.data))
|
.then((response) => setStandards(response.data))
|
||||||
.catch((error) => console.log(error));
|
.catch((error) => console.log(error));
|
||||||
}, []);
|
}, []);
|
||||||
@ -47,7 +44,7 @@ const Filter = (props) => {
|
|||||||
id={level.id}
|
id={level.id}
|
||||||
className={classes["level-" + level.levelNumber]}
|
className={classes["level-" + level.levelNumber]}
|
||||||
>
|
>
|
||||||
{level.levelName}
|
{level.levelTitle}
|
||||||
</Dropdown.Toggle>
|
</Dropdown.Toggle>
|
||||||
|
|
||||||
<Dropdown.Menu className="w-100">
|
<Dropdown.Menu className="w-100">
|
||||||
@ -60,7 +57,7 @@ const Filter = (props) => {
|
|||||||
>
|
>
|
||||||
{standards
|
{standards
|
||||||
.filter(
|
.filter(
|
||||||
(standard) => standard.standardLevel === level.levelNumber
|
(standard) => standard.levelNumber === level.levelNumber
|
||||||
)
|
)
|
||||||
.map((standard, index) => (
|
.map((standard, index) => (
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
@ -69,7 +66,7 @@ const Filter = (props) => {
|
|||||||
variant="outline-secondary"
|
variant="outline-secondary"
|
||||||
key={standard.id}
|
key={standard.id}
|
||||||
id={`std-btn-${standard.id}`}
|
id={`std-btn-${standard.id}`}
|
||||||
className={classes[`list-items-${standard.standardLevel}`]}
|
className={classes[`list-items-${standard.levelNumber}`]}
|
||||||
value={standard.standardTitle}
|
value={standard.standardTitle}
|
||||||
>
|
>
|
||||||
{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