remove last

This commit is contained in:
Victor Batischev 2024-02-28 19:59:56 +03:00
parent 57cc2bc1fa
commit 59d0f5eae6
11 changed files with 28 additions and 27 deletions

View File

@ -6,7 +6,7 @@ import {
modalToggle modalToggle
} from "@redux/projectsTrackerSlice"; } from "@redux/projectsTrackerSlice";
import { caseOfNum, urlForLocal } from "@utils/helper"; import { caseOfNum, removeLast, urlForLocal } from "@utils/helper";
import { apiRequest } from "@api/request"; import { apiRequest } from "@api/request";
@ -67,7 +67,7 @@ const ListEmployees = ({
} }
alt="avatar" alt="avatar"
/> />
<span>{person.user.fio.split(" ").slice(0, -1).join(" ")}</span> <span>{removeLast(person.user.fio)}</span>
<img <img
className="delete" className="delete"
src={close} src={close}

View File

@ -11,10 +11,10 @@ import { getProfileInfo } from "@redux/outstaffingSlice";
import { setProjectBoardFetch } from "@redux/projectsTrackerSlice"; import { setProjectBoardFetch } from "@redux/projectsTrackerSlice";
import { import {
backendImg,
caseOfNum, caseOfNum,
getCorrectRequestDate, getCorrectRequestDate,
getToken, getToken,
removeLast,
urlForLocal urlForLocal
} from "@utils/helper"; } from "@utils/helper";
@ -759,12 +759,12 @@ export const ModalTiсket = ({
<div className="workers_box task__info"> <div className="workers_box task__info">
<span className="exit" onClick={() => setActive(false)}></span> <span className="exit" onClick={() => setActive(false)}></span>
<h5>Создатель: </h5> <h5>Создатель: </h5>
<p className="workers__creator">{task.user?.fio}</p> <p className="workers__creator">{removeLast(task.user?.fio)}</p>
{executor ? ( {executor ? (
<> <>
<h5>Исполнитель: </h5> <h5>Исполнитель: </h5>
<div className="executor"> <div className="executor">
<p>{executor.fio}</p> <p>{removeLast(executor.fio)}</p>
<img <img
src={ src={
executor?.avatar executor?.avatar
@ -803,7 +803,7 @@ export const ModalTiсket = ({
key={person.user_id} key={person.user_id}
onClick={() => taskExecutor(person)} onClick={() => taskExecutor(person)}
> >
<span>{person.user.fio}</span> <span>{removeLast(person.user.fio)}</span>
<img <img
src={ src={
person.user?.avatar person.user?.avatar
@ -826,7 +826,7 @@ export const ModalTiсket = ({
{members.map((member) => { {members.map((member) => {
return ( return (
<div className="worker" key={member.user_id}> <div className="worker" key={member.user_id}>
<p>{member.fio.split(" ").slice(0, -1).join(" ")}</p> <p>{removeLast(member.fio)}</p>
<img <img
src={ src={
member?.avatar member?.avatar
@ -869,7 +869,7 @@ export const ModalTiсket = ({
key={person.user_id} key={person.user_id}
onClick={() => addMember(person)} onClick={() => addMember(person)}
> >
<span>{person.user.fio}</span> <span>{removeLast(person.user.fio)}</span>
<img <img
src={ src={
person.user?.avatar person.user?.avatar

View File

@ -23,7 +23,7 @@ import {
} from "@redux/projectsTrackerSlice"; } from "@redux/projectsTrackerSlice";
import { getCorrectDate } from "@utils/calendarHelper"; import { getCorrectDate } from "@utils/calendarHelper";
import { getCorrectRequestDate, urlForLocal } from "@utils/helper"; import { getCorrectRequestDate, removeLast, urlForLocal } from "@utils/helper";
import { apiRequest } from "@api/request"; import { apiRequest } from "@api/request";
@ -448,7 +448,7 @@ export const TrackerModal = ({
> >
<p> <p>
{selectedWorker {selectedWorker
? selectedWorker.employee.fio ? removeLast(selectedWorker.employee.fio)
: "Выберите пользователя"} : "Выберите пользователя"}
</p> </p>
<img className="arrow" src={arrowDown} alt="arrow" /> <img className="arrow" src={arrowDown} alt="arrow" />
@ -467,7 +467,7 @@ export const TrackerModal = ({
setSelectedWorker(worker); setSelectedWorker(worker);
}} }}
> >
<span>{worker.employee.fio}</span> <span>{removeLast(worker.employee.fio)}</span>
<img <img
src={urlForLocal(worker.employee.avatar)} src={urlForLocal(worker.employee.avatar)}
alt="avatar" alt="avatar"
@ -698,7 +698,7 @@ export const TrackerModal = ({
} }
alt="avatar" alt="avatar"
/> />
<span>{person.user.fio}</span> <span>{removeLast(person.user.fio)}</span>
</div> </div>
); );
}) })

View File

@ -262,7 +262,7 @@
position: absolute; position: absolute;
width: 100%; width: 100%;
padding: 9.5px 12px; padding: 9.5px 12px;
top: 48px; top: 45px;
left: 0; left: 0;
background: white; background: white;
border-radius: 5px; border-radius: 5px;

View File

@ -97,7 +97,7 @@ export const Navigation = () => {
<div className="profile-header__personal-info"> <div className="profile-header__personal-info">
<h3 className="profile-header__personal-info-name"> <h3 className="profile-header__personal-info-name">
{profileInfo?.fio ? profileInfo?.fio : profileInfo?.username} {profileInfo?.fio || profileInfo?.username}
</h3> </h3>
<NavLink end to={"/profile"}> <NavLink end to={"/profile"}>
<img <img

View File

@ -95,7 +95,7 @@ export const ProfileCalendar = () => {
alt="avatar" alt="avatar"
/> />
<p className="summary__name"> <p className="summary__name">
{profileInfo?.fio ? profileInfo?.fio : profileInfo?.username},{" "} {profileInfo?.fio || profileInfo?.username},{" "}
{profileInfo.specification} разработчик {profileInfo.specification} разработчик
</p> </p>
</div> </div>

View File

@ -146,7 +146,7 @@ export const ProfileHeader = () => {
<nav className="auth-body__navigation"> <nav className="auth-body__navigation">
<div className="profile-header__personal-info"> <div className="profile-header__personal-info">
<h3 className="profile-header__personal-info-name"> <h3 className="profile-header__personal-info-name">
{profileInfo?.fio ? profileInfo?.fio : profileInfo?.username} {profileInfo?.fio || profileInfo?.username}
</h3> </h3>
<NavLink end to={"/profile"}> <NavLink end to={"/profile"}>
<img <img

View File

@ -103,12 +103,12 @@ export const Profile = () => {
{user === "developer" ? ( {user === "developer" ? (
<span> <span>
<p>Добрый день,&nbsp;</p> <p>Добрый день,&nbsp;</p>
{profileInfo?.fio ? profileInfo?.fio : profileInfo?.username} {profileInfo?.fio || profileInfo?.username}
</span> </span>
) : ( ) : (
<span> <span>
<p>Добрый день,&nbsp;</p> <p>Добрый день,&nbsp;</p>
{profileInfo?.fio ? profileInfo?.fio : profileInfo?.username} {profileInfo?.fio || profileInfo?.username}
</span> </span>
)} )}
</h2> </h2>
@ -124,13 +124,11 @@ export const Profile = () => {
<p className="summary__name"> <p className="summary__name">
{user === "developer" ? ( {user === "developer" ? (
<span> <span>
{profileInfo?.fio ? profileInfo?.fio : profileInfo?.username},{" "} {profileInfo?.fio || profileInfo?.username},{" "}
{profileInfo?.specification} разработчик {profileInfo?.specification} разработчик
</span> </span>
) : ( ) : (
<span> <span>{profileInfo?.fio || profileInfo?.username}</span>
{profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}
</span>
)} )}
</p> </p>
</div> </div>

View File

@ -967,7 +967,7 @@ export const ProjectTracker = () => {
alt="avatar" alt="avatar"
/> />
<span> <span>
{task.executor?.fio || {removeLast(task.executor?.fio) ||
"Исполнитель не назначен"} "Исполнитель не назначен"}
</span> </span>
</div> </div>

View File

@ -107,7 +107,7 @@ export const Summary = () => {
alt="avatar" alt="avatar"
/> />
<p className="summary__name"> <p className="summary__name">
{profileInfo?.fio ? profileInfo?.fio : profileInfo?.username},{" "} {profileInfo?.fio || profileInfo?.username},{" "}
{profileInfo.specification} разработчик {profileInfo.specification} разработчик
</p> </p>
</div> </div>

View File

@ -92,7 +92,10 @@ export function copyProjectLink(projectId) {
); );
} }
export function removeLast(string) { export function removeLast(string = " ") {
let lastIndex = string.lastIndexOf(" "); let arr = string.trim().split(" ");
return string.substring(0, lastIndex); if (arr.length > 2) {
return arr.slice(0, -1).join(" ");
}
return string;
} }