-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ front: Implemented user display logic in grouped rows user molecule (
#50)
- Loading branch information
1 parent
1c5bc83
commit b55d3fb
Showing
2 changed files
with
61 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 34 additions & 7 deletions
41
tdrive/frontend/src/app/molecules/grouped-rows/user/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,43 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import React from 'react'; | ||
import { Base, Info } from '@atoms/text'; | ||
import Avatar from '@atoms/avatar'; | ||
import BaseBlock from '@molecules/grouped-rows/base'; | ||
import Languages from '@features/global/services/languages-service'; | ||
import type { UserType } from '@features/users/types/user'; | ||
import { getFullName } from '@features/users/utils/get-full-name'; | ||
|
||
// @ts-ignore | ||
interface UserBlockProps extends React.InputHTMLAttributes<HTMLInputElement> { | ||
avatar: JSX.Element; | ||
title: JSX.Element | string; | ||
subtitle: JSX.Element | string; | ||
suffix?: JSX.Element | string; | ||
interface UserBlockProps { | ||
className?: string; | ||
suffix?: JSX.Element | string | false; | ||
title_suffix?: JSX.Element | string | false; | ||
subtitle_suffix?: JSX.Element | string | false; | ||
user?: UserType; | ||
isSelf?: boolean; | ||
} | ||
|
||
export default function UserBlock(props: UserBlockProps) { | ||
return BaseBlock(props); | ||
return <BaseBlock | ||
className={props.className} | ||
suffix={props.suffix} | ||
title_suffix={props.title_suffix} | ||
subtitle_suffix={props.subtitle_suffix} | ||
|
||
avatar={ | ||
<Avatar | ||
avatar={props.user?.thumbnail || ''} | ||
title={props.user ? getFullName(props.user) : '-'} | ||
size="sm" | ||
/> | ||
} | ||
title={ | ||
<> | ||
<Base>{!!props.user && getFullName(props.user)}</Base> | ||
{props.isSelf && <Info>{' ' + Languages.t('components.internal-access_specific_rules_you')}</Info>} | ||
</> | ||
} | ||
subtitle={ | ||
<div className='text-sm text-slate-500'>{props.user?.email || ""}</div> | ||
} | ||
/> | ||
} |