1- import { NumberCaller } from "../../../NumberCaller"
2- import { ContactType } from "@shared/types"
3- import { isDev } from "@shared/utils/utils"
4- import { FavouriteStar } from "./FavouritesStar"
5- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
6- import { useAccount } from "@renderer/hooks/useAccount"
7- import { useNethlinkData } from "@renderer/store"
8- import { usePhoneIslandEventHandler } from "@renderer/hooks/usePhoneIslandEventHandler"
9- import { Avatar } from "../../../Nethesis"
10- import {
11- faPhone as CallIcon ,
12- } from '@fortawesome/free-solid-svg-icons'
13- import { t } from "i18next"
14- import { ReactNode } from "react"
15- import classNames from "classnames"
16- export const ContactNameAndActions = ( { contact, number, isHighlight, displayedNumber, avatarDim, username, isFavourite, isSearchData } : {
17- contact : ContactType ,
18- number : string ,
19- isHighlight : boolean ,
20- displayedNumber : string | ReactNode [ ] ,
21- avatarDim : "small" | "base" | "extra_small" | "large" | "extra_large" ,
22- username : string | undefined ,
1+ import { NumberCaller } from '../../../NumberCaller'
2+ import { ContactType } from '@shared/types'
3+ import { isDev } from '@shared/utils/utils'
4+ import { FavouriteStar } from './FavouritesStar'
5+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
6+ import { useAccount } from '@renderer/hooks/useAccount'
7+ import { useNethlinkData } from '@renderer/store'
8+ import { usePhoneIslandEventHandler } from '@renderer/hooks/usePhoneIslandEventHandler'
9+ import { Avatar } from '../../../Nethesis'
10+ import { faPhone as CallIcon } from '@fortawesome/free-solid-svg-icons'
11+ import { t } from 'i18next'
12+ import { ReactNode } from 'react'
13+ import classNames from 'classnames'
14+ export const ContactNameAndActions = ( {
15+ contact,
16+ number,
17+ isHighlight,
18+ displayedNumber,
19+ avatarDim,
20+ username,
21+ isFavourite,
22+ isSearchData
23+ } : {
24+ contact : ContactType
25+ number : string
26+ isHighlight : boolean
27+ displayedNumber : string | ReactNode [ ]
28+ avatarDim : 'small' | 'base' | 'extra_small' | 'large' | 'extra_large'
29+ username : string | undefined
2330 isFavourite : boolean
2431 isSearchData : boolean
2532} ) => {
@@ -28,46 +35,79 @@ export const ContactNameAndActions = ({ contact, number, isHighlight, displayedN
2835 const { callNumber } = usePhoneIslandEventHandler ( )
2936 const avatarSrc = username && operators ?. avatars ?. [ username ]
3037
31- const isOperator = username && ! ! ( operators ?. operators ?. [ username ] )
38+ const isOperator = username && ! ! operators ?. operators ?. [ username ]
3239
3340 return (
34- < div className = { classNames ( avatarDim === 'small' ? 'gap-3' : 'gap-6' , "flex flex-row items-center w-full max-w-full" ) }
41+ < div
42+ className = { classNames (
43+ avatarDim === 'small' ? 'gap-3' : 'gap-6' ,
44+ 'flex flex-row items-center w-full max-w-full'
45+ ) }
3546 >
3647 < Avatar
3748 size = { avatarDim }
3849 src = { avatarSrc }
3950 status = { isOperator ? operators ?. operators ?. [ username ] ?. mainPresence : undefined }
4051 bordered = { true }
41- placeholderType = { operators ?. extensions [ contact . speeddial_num || '' ] ? 'operator' : 'person' }
52+ placeholderType = {
53+ operators ?. extensions [ contact ?. speeddial_num || '' ]
54+ ? 'operator'
55+ : contact ?. kind === 'company'
56+ ? 'company'
57+ : 'person'
58+ }
4259 />
43- < div className = ' relative w-full h-[44px] ' >
60+ < div className = " relative w-full h-[44px] " >
4461 < div className = "absolute top-0 left-0 flex flex-col gap-1 w-full " >
4562 < div className = "flex flex-row gap-2 w-full overflow-hidden" >
46- < div className = 'dark:text-titleDark text-titleLight font-medium text-[14px] leading-5 truncate break-all whitespace-nowrap ' >
47- { isFavourite ? ( contact . company || `${ t ( 'Common.Unknown' ) } ` ) : ( contact . name || contact . company || `${ t ( 'Common.Unknown' ) } ` ) }
48- { isDev ( ) && < span
49- onClick = { ( ) => {
50- navigator . clipboard . writeText ( JSON . stringify ( { contact, number, isHighlight, displayedNumber, avatarDim, username, isFavourite, isSearchData } ) )
51- } }
52- className = 'absolute top-[-4px] left-[-26px] text-[8px] cursor-pointer' > [{ contact . id } ]</ span > }
63+ < div className = "dark:text-titleDark text-titleLight font-medium text-[14px] leading-5 truncate break-all whitespace-nowrap " >
64+ { isFavourite
65+ ? contact . company || `${ t ( 'Common.Unknown' ) } `
66+ : contact . name || contact . company || `${ t ( 'Common.Unknown' ) } ` }
67+ { isDev ( ) && (
68+ < span
69+ onClick = { ( ) => {
70+ navigator . clipboard . writeText (
71+ JSON . stringify ( {
72+ contact,
73+ number,
74+ isHighlight,
75+ displayedNumber,
76+ avatarDim,
77+ username,
78+ isFavourite,
79+ isSearchData
80+ } )
81+ )
82+ } }
83+ className = "absolute top-[-4px] left-[-26px] text-[8px] cursor-pointer"
84+ >
85+ [{ contact . id } ]
86+ </ span >
87+ ) }
5388 </ div >
5489 { isOperator && < FavouriteStar contact = { contact } isSearchData = { isSearchData } /> }
5590 </ div >
5691 < div className = "flex flex-row gap-2 items-center" >
57- { ! isHighlight &&
92+ { ! isHighlight && (
5893 < FontAwesomeIcon
5994 className = "dark:text-gray-400 text-gray-600 text-base"
6095 icon = { CallIcon }
6196 onClick = { ( ) => callNumber ( contact . speeddial_num ! ) }
6297 />
63- }
98+ ) }
6499 < NumberCaller
65100 number = { number }
66- disabled = { ! isCallsEnabled }
67- className = " dark:text-textBlueDark text-textBlueLight font-normal hover:underline"
101+ disabled = { displayedNumber ?. length === 0 || ! isCallsEnabled }
102+ className = { ` ${ displayedNumber ?. length === 0 ? '' : ' dark:text-textBlueDark text-textBlueLight' } font-normal hover:underline` }
68103 isNumberHiglighted = { isHighlight }
69104 >
70- { displayedNumber }
105+ { displayedNumber !== ' ' &&
106+ displayedNumber !== '' &&
107+ displayedNumber !== null &&
108+ ( ! Array . isArray ( displayedNumber ) || displayedNumber . length > 0 )
109+ ? displayedNumber
110+ : '-' }
71111 </ NumberCaller >
72112 </ div >
73113 </ div >
0 commit comments