lab8 it is annoying

This commit is contained in:
Zakharov_Rostislav 2023-12-22 12:21:31 +04:00
parent 61abe13183
commit 0302c95582
3 changed files with 13 additions and 21 deletions

View File

@ -1,5 +1,5 @@
import './Footer.css'; import './Footer.css';
import useAuthorization from '../users/context_hooks/AuthorizationHook'; // import useAuthorization from '../users/context_hooks/AuthorizationHook';
const Footer = () => { const Footer = () => {
const year = new Date().getFullYear(); const year = new Date().getFullYear();

View File

@ -1,26 +1,18 @@
import { useEffect, useState } from 'react'; import { useState } from 'react';
import PropTypes from 'prop-types';
import UsersApiService from '../service/UsersApiService';
const useUserObject = async (id) => { const useUserObject = () => {
// debugger; const emptyObject = {
let userObject = { name: '',
name: 'user',
password: '', password: '',
role: 'user', role: 'user',
id: '', id: '',
}; };
const data = await UsersApiService.get(id); const [userObject, setUserObject] = useState({ ...emptyObject });
if (data && data.name) {
//userObject.name = data.name;
}
return { return {
userObject, user: userObject,
setUser: setUserObject,
}; };
}; };
useUserObject.propTypes = {
id: PropTypes.number,
};
export default useUserObject; export default useUserObject;

View File

@ -1,10 +1,10 @@
import AuthorizationForm from '../components/users/authorization/form/AuthorizationForm.jsx'; import AuthorizationForm from '../components/users/authorization/form/AuthorizationForm.jsx';
import UserPageInfo from '../components/users/userPage/UserPageInfo.jsx'; import UserPageInfo from '../components/users/userPage/UserPageInfo.jsx';
import useAuthorization from '../components/users/context_hooks/AuthorizationHook.js'; // import useAuthorization from '../components/users/context_hooks/AuthorizationHook';
const UserPage = () => { const UserPage = () => {
let { id } = useAuthorization(); // let { id } = useAuthorization();
// let id = localStorage.getItem('userId'); let id = localStorage.getItem('userId');
id = parseInt(id, 10); id = parseInt(id, 10);
if (!id) { if (!id) {
return ( return (