Skip to content

Commit

Permalink
fix(condo): INFRA-837 hide link from resident ticket[id] page if ther…
Browse files Browse the repository at this point in the history
…e is no resident (#5734)

* fix(condo): INFRA-837 hide link from resident ticket[id] page if there is no resident

* refactor(condo): INFRA-837 rid off lodash get usage
  • Loading branch information
sitozzz authored Jan 31, 2025
1 parent f951f65 commit 00007e1
Showing 1 changed file with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Ticket, User } from '@app/condo/schema'
import { get } from 'lodash'
import { User } from '@app/condo/schema'
import Link from 'next/link'
import React, { useMemo } from 'react'

Expand Down Expand Up @@ -32,26 +31,36 @@ interface ITicketUserInfoFieldProps {
}

export const TicketUserInfoField: React.FC<ITicketUserInfoFieldProps> = (props) => {
const id = useMemo(() => get(props, ['user', 'id']), [props])
const name = useMemo(() => get(props, ['user', 'name']), [props])
const nameLink = useMemo(() => get(props, ['nameLink'], '#'), [props])
const phone = useMemo(() => get(props, ['user', 'phone']), [props])
const email = useMemo(() => get(props, ['user', 'email']), [props])
const id = useMemo(() => props?.user?.id, [props])
const name = useMemo(() => props?.user?.name, [props])
const nameLink = useMemo(() => props?.nameLink, [props])
const phone = useMemo(() => props?.user?.phone, [props])
const email = useMemo(() => props?.user?.email, [props])
const userInfo = useMemo(() => [], [])

if (name) {
userInfo.push(
<UserNameField user={{ name, id }}>
{({ name: userName, postfix }) => (
<Link href={nameLink}>
<a>
{({ name: userName, postfix }) => {
if (nameLink) {
return (
<Link href={nameLink}>
<a>
{userName}
{postfix && (
<Typography.Text type='secondary'>&nbsp;{postfix}</Typography.Text>
)}
</a>
</Link>
)
}
return (
<Typography.Text>
{userName}
{postfix && (
<Typography.Text type='secondary'>&nbsp;{postfix}</Typography.Text>
)}
</a>
</Link>
)}
{postfix && (<Typography.Text type='secondary'>&nbsp;{postfix}</Typography.Text>)}
</Typography.Text>
)
}}
</UserNameField>
)
}
Expand Down

0 comments on commit 00007e1

Please sign in to comment.