diff --git a/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js b/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js index c582ed39b..f82df61c6 100644 --- a/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js +++ b/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js @@ -73,7 +73,7 @@ const GeneralInfo = (props) => { const [imageLogoError, setImageLogoError] = useState(null); const [edrpouError, setEdrpouError] = useState(null); - const { data, error, isLoading } = useSWR('http://127.0.0.1:8000/api/regions/', fetcher); + const { data: fetchedRegions, error, isLoading } = useSWR('http://127.0.0.1:8000/api/regions/', fetcher); useEffect(() => { props.currentFormNameHandler(props.curForm); @@ -111,7 +111,7 @@ const GeneralInfo = (props) => { const onUpdateOneSelectField = e => { setUser((prevState) => { - const selectedRegion = data.find((el) => el.value === e.target.value); + const selectedRegion = fetchedRegions.find((el) => el.value === e.target.value); return { ...prevState, [e.target.name]: selectedRegion.key }; }); }; @@ -236,12 +236,14 @@ const GeneralInfo = (props) => { {!isLoading && el.key === user.regions)? data.find((el) => el.key === user.regions).value : ''} + value={fetchedRegions.find((el) => el.key === user.regions) + ? fetchedRegions.find((el) => el.key === user.regions).value + : ''} /> } diff --git a/FrontEnd/src/components/ProfilePage/ProfilePage.js b/FrontEnd/src/components/ProfilePage/ProfilePage.js index d4e162b7e..a87c7f7da 100644 --- a/FrontEnd/src/components/ProfilePage/ProfilePage.js +++ b/FrontEnd/src/components/ProfilePage/ProfilePage.js @@ -3,7 +3,7 @@ import Description from './ProfilePageComponents/Description'; import ProfileContent from './ProfilePageComponents/ProfileContent'; import { useState } from 'react'; import BreadCrumbs from '../BreadCrumbs/BreadCrumbs'; -import useSWR from 'swr'; + const USER = { 'email': 'ex@gmail.com', @@ -54,19 +54,6 @@ const USER = { 'Youtube': '', }; -// const fetcher = (...args) => fetch(...args).then(res => res.json()); -const fetcher = async (url, token) => { - const headers = { - Authorization: `Token ${token}`, - }; - const response = await fetch(url, { headers }); - - if (!response.ok) { - throw new Error('Network response was not ok'); - } - return response.json(); - }; - const ProfilePage = () => { const [mainUser, setMainUser] = useState(USER); const [formName, setFormName] = useState(''); @@ -74,12 +61,6 @@ const ProfilePage = () => { setFormName(currentName); }; - const token = '661d6d53d89502c80fbb3d0408c302e81364a8a3'; - const { data, error } = useSWR(['http://127.0.0.1:8000/api/profiles/1', token], ([url, token]) => fetcher(url, token)) - - console.log('in app', data); - - const profileUpdateHandler = (myUser) => { console.log('in app'); console.log(myUser); diff --git a/forum/settings.py b/forum/settings.py index f987335fc..7746844cf 100644 --- a/forum/settings.py +++ b/forum/settings.py @@ -62,16 +62,16 @@ ] CORS_ALLOW_CREDENTIALS = True -CORS_ALLOW_ALL_ORIGINS = True +CORS_ALLOW_ALL_ORIGINS = False CORS_ORIGIN_WHITELIST = [ - 'http://localhost', + 'http://localhost:3000', 'http://127.0.0.1', 'http://0.0.0.0', ] CORS_ALLOWED_ORIGINS = [ - 'http://localhost', + 'http://localhost:3000', 'http://127.0.0.1', 'http://0.0.0.0', ]