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 useAuthorization from '../users/context_hooks/AuthorizationHook';
// import useAuthorization from '../users/context_hooks/AuthorizationHook';
const Footer = () => {
const year = new Date().getFullYear();

View File

@ -1,26 +1,18 @@
import { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import UsersApiService from '../service/UsersApiService';
import { useState } from 'react';
const useUserObject = async (id) => {
// debugger;
let userObject = {
name: 'user',
const useUserObject = () => {
const emptyObject = {
name: '',
password: '',
role: 'user',
id: '',
};
const data = await UsersApiService.get(id);
if (data && data.name) {
//userObject.name = data.name;
}
const [userObject, setUserObject] = useState({ ...emptyObject });
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 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 = () => {
let { id } = useAuthorization();
// let id = localStorage.getItem('userId');
// let { id } = useAuthorization();
let id = localStorage.getItem('userId');
id = parseInt(id, 10);
if (!id) {
return (