Skip to content

Commit

Permalink
remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
ddianaoo committed Sep 20, 2023
1 parent 1549a24 commit 569db69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 };
});
};
Expand Down Expand Up @@ -236,12 +236,14 @@ const GeneralInfo = (props) => {
{!isLoading &&
<OneSelectChip
name='regions'
options={data}
options={fetchedRegions}
label={LABELS.regions}
updateHandler={onUpdateOneSelectField}
requredField={false}
defaultValue="Оберіть"
value={data.find((el) => 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
: ''}
/>
}
</div>
Expand Down
21 changes: 1 addition & 20 deletions FrontEnd/src/components/ProfilePage/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -54,32 +54,13 @@ 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('');
const currentFormNameHandler = (currentName) => {
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);
Expand Down
6 changes: 3 additions & 3 deletions forum/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
Expand Down

0 comments on commit 569db69

Please sign in to comment.