Skip to content

Commit

Permalink
добавляет дату найма в компанию
Browse files Browse the repository at this point in the history
  • Loading branch information
semant1cs committed Dec 17, 2023
1 parent 209765d commit cf111c3
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 43 deletions.
11 changes: 5 additions & 6 deletions frontend/src/components/mapMenu/EmployeeMap/EmployeeMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ import levelStore from "../../../store/levelStore.ts";
import {IUserType} from "../../../types/UserType.ts";
import axios from "axios";
import Starfield from "react-starfield";
import {IEmployeeType} from "../../../types/EmployeeType.ts";


interface IEmployeeMap {
user?: IUserType,
formattedDate: string,
logOut: () => void
}

const EmployeeMap: React.FC<IEmployeeMap> = observer(({user, formattedDate, logOut}) => {
const EmployeeMap: React.FC<IEmployeeMap> = observer(({user, logOut}) => {
const [isLoading, setIsLoading] = useState<boolean>(true)
const [employee, setEmployee] = useState(null)
const [employee, setEmployee] = useState<IEmployeeType>()

useEffect(() => {
// console.log(user)
axios.get("http://localhost:8000/employees").then((r) => {
r.data.map((employee) => {
r.data.map((employee: IEmployeeType) => {
if (user?.id === employee.user.id) {
setEmployee(employee)
setIsLoading(false)
Expand Down Expand Up @@ -80,8 +80,7 @@ const EmployeeMap: React.FC<IEmployeeMap> = observer(({user, formattedDate, logO
/>
<UserProfile
logOut={logOut}
user={user}
formattedDate={formattedDate}
employee={employee}
/>
<CustomProgressBar
className="progress-bar-wrapper"
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/components/mapMenu/MapMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const MapMenu: React.FC = observer(() => {
const navigate = useNavigate()

const [user, setUser] = useState<IUserType>()
const [formattedDate, setFormattedDate] = useState<string>("")
const [isLoading, setIsLoading] = useState<boolean>(true)

useEffect(() => {
Expand All @@ -32,11 +31,6 @@ const MapMenu: React.FC = observer(() => {
}
})
superUserStore.setAllUsers(response.data)

if (user) {
const date = new Date(Date.parse(user!.registered_at))
setFormattedDate(`${date.getDay()}.${date.getMonth()}.${date.getUTCFullYear()}`)
}
setIsLoading(false)
})
}, [])
Expand Down Expand Up @@ -67,7 +61,6 @@ const MapMenu: React.FC = observer(() => {
: <EmployeeMap
logOut={handleOnLogOut}
user={user}
formattedDate={formattedDate}
/>
)
}
Expand Down
48 changes: 33 additions & 15 deletions frontend/src/components/mapMenu/UIMapMenu/UserProfile/UserInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
import React from 'react';
import React, {useEffect, useState} from 'react';
import CustomInput from "../../../../UIComponents/customInput/CustomInput.tsx";
import {IUserType} from "../../../../types/UserType.ts";
import {IEmployeeType} from "../../../../types/EmployeeType.ts";

interface IPropTypes {
user: IUserType | undefined,
formattedDate: string,
employee: IEmployeeType | undefined,
}

const UserInfo: React.FC<IPropTypes> = ({user, formattedDate}) => {
const UserInfo: React.FC<IPropTypes> = ({employee}) => {
return (
<div>
<img className="user-profile-photo"
src="https://clck.ru/36wj9g"
alt="Фото профиля"
<img
className="user-profile-photo"
src="https://clck.ru/36wj9g"
alt="Фото профиля"
/>
<div className="user-info-fields">
<CustomInput type="text" width="350px" disabled={true} value={user?.username}
height="55px" placeholder="ФИО"/>
<CustomInput type="email" width="350px" placeholder="email" disabled={true} value={user?.email}
height="55px"/>
<CustomInput type="text" width="350px" placeholder="Дата трудоустройства" disabled={true}
defaultValue={formattedDate}
height="55px"/>
<CustomInput
type="text"
width="350px"
disabled={true}
value={`${employee?.last_name} ${employee?.name} ${employee?.patronymic}`}
height="55px"
placeholder="ФИО"
/>

<CustomInput
type="email"
width="350px"
placeholder="email"
disabled={true}
value={employee?.user.email}
height="55px"
/>
<CustomInput
type="text"
width="350px"
placeholder="Дата трудоустройства"
disabled={true}
defaultValue={employee ? employee?.hired_at.split("-").reverse().join(".") : "01.01.1999"}
height="55px"
/>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import React, {useState} from 'react';
import ModalWindow from "../../../../UIComponents/modalWindow/ModalWindow.tsx";
import UserProfileModalBody from "./UserProfileModalBody.tsx";
import "./userProfileModalBody.scss"
import {IUserType} from "../../../../types/UserType.ts";
import {IEmployeeType} from "../../../../types/EmployeeType.ts";

interface IPropTypes {
user?: IUserType,
formattedDate: string,
employee?: IEmployeeType,
logOut: () => void
}

const UserProfile: React.FC<IPropTypes> = ({user, formattedDate, logOut}) => {
const UserProfile: React.FC<IPropTypes> = ({employee, logOut}) => {
const [isModalOpen, setIsModalOpen] = useState<boolean>(false)

return (
Expand All @@ -30,7 +29,7 @@ const UserProfile: React.FC<IPropTypes> = ({user, formattedDate, logOut}) => {
</g>
</svg>
</div>
{isModalOpen && <ModalWindow onClose={() => setIsModalOpen(!isModalOpen)} body={<UserProfileModalBody logOut={logOut} user={user} formattedDate={formattedDate}/>}/>}
{isModalOpen && <ModalWindow onClose={() => setIsModalOpen(!isModalOpen)} body={<UserProfileModalBody logOut={logOut} employee={employee}/>}/>}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
import React, {useCallback, useEffect} from 'react';
import {IUserType} from "../../../../types/UserType.ts";
import React, {useCallback} from 'react';

import {IAchievementType} from "../../../../types/AchievementType.ts";
import Achievements from "./Achievements/Achievements.tsx";
import UserInfo from "./UserInfo.tsx";
import CustomButton from "../../../../UIComponents/customButton/CustomButton.tsx";
import {IEmployeeType} from "../../../../types/EmployeeType.ts";


interface IUserProfileModalProps {
img?: string
user?: IUserType,
formattedDate: string,
employee?: IEmployeeType,
logOut?: () => void
}


const UserProfileModalBody: React.FC<IUserProfileModalProps> = ({user, formattedDate, logOut}) => {
const UserProfileModalBody: React.FC<IUserProfileModalProps> = ({employee, logOut}) => {
const achievements: IAchievementType[] = [
{id: "1", title: "Начало работы", description: "Описание 1"},
{id: "2", title: "Середина работы ", description: "Описание 2"},
{id: "3", title: "Конец работы ", description: "Описание 3"}
]

useEffect(() => {
console.log(user)
}, [user])

const handleOnLogOut = useCallback(() => {
logOut ? logOut() : null
}, [])
Expand All @@ -39,7 +34,7 @@ const UserProfileModalBody: React.FC<IUserProfileModalProps> = ({user, formatted
<CustomButton className="user-profile-logout__btn" text="Выйти" handleOnClick={handleOnLogOut}/>
: null
}
<UserInfo user={user} formattedDate={formattedDate}/>
<UserInfo employee={employee}/>
<Achievements achievements={achievements}/>
</div>
);
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/types/EmployeeType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {IUserType} from "./UserType.ts";

export interface IEmployeeType {
tutor_id: string,
name: string,
last_name: string,
hired_at: string,
patronymic: string
coins: number,
id: string,
user: IUserType
}

0 comments on commit cf111c3

Please sign in to comment.