Skip to content

Commit 021202f

Browse files
kuduzowkuduzow
andauthored
Исправлена логика появления модального окна и адрес сервера (#296)
Co-authored-by: kuduzow <admin@intocode.ru>
1 parent aeeb2f8 commit 021202f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/components/PatchUserModal.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useState } from 'react';
33
import { useDispatch, useSelector } from 'react-redux';
44
import { selectProfile, updateProfile } from 'features/profile/profileSlice';
55
import styled from 'styled-components';
6+
import { useAuth } from 'common/context/Auth/useAuth';
67

78
const StyledModalHeading = styled.h2`
89
text-align: center;
@@ -15,6 +16,8 @@ const StyledButtonBlock = styled.div`
1516
const PatchUserModal = () => {
1617
const profile = useSelector(selectProfile);
1718

19+
const { token } = useAuth();
20+
1821
const dispatch = useDispatch();
1922

2023
const [userFullName, setUserFullName] = useState('');
@@ -26,8 +29,13 @@ const PatchUserModal = () => {
2629
dispatch(updateProfile({ id, userFullName, userEmail }));
2730
};
2831

32+
// eslint-disable-next-line no-console
33+
console.log(profile);
34+
2935
const isModalOpened = !profile.fullName || !profile.email;
3036

37+
if (!token || profile.loading) return null;
38+
3139
return (
3240
<div>
3341
<Modal open={isModalOpened} footer={null} destroyOnClose>

src/features/profile/profileSlice.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const updateProfile = createAsyncThunk(
1919
'profile/patch',
2020
async ({ id, userFullName, userEmail }, thunkAPI) => {
2121
try {
22-
const response = await axios.patch(`http://localhost:3030/user/profile/${id}`, {
22+
const response = await axios.patch(`/user/profile/${id}`, {
2323
fullName: userFullName,
2424
email: userEmail,
2525
});

0 commit comments

Comments
 (0)