Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands",
"@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light",
"@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid",
"@nethesis/phone-island": "^0.8.43",
"@nethesis/phone-island": "^0.8.45",
"@tailwindcss/forms": "^0.5.7",
"@types/lodash": "^4.14.202",
"@types/node": "^18.19.9",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import { NumberCaller } from "../../../NumberCaller"
import { ContactType } from "@shared/types"
import { isDev } from "@shared/utils/utils"
import { FavouriteStar } from "./FavouritesStar"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { useAccount } from "@renderer/hooks/useAccount"
import { useNethlinkData } from "@renderer/store"
import { usePhoneIslandEventHandler } from "@renderer/hooks/usePhoneIslandEventHandler"
import { Avatar } from "../../../Nethesis"
import {
faPhone as CallIcon,
} from '@fortawesome/free-solid-svg-icons'
import { t } from "i18next"
import { ReactNode } from "react"
import classNames from "classnames"
export const ContactNameAndActions = ({ contact, number, isHighlight, displayedNumber, avatarDim, username, isFavourite, isSearchData }: {
contact: ContactType,
number: string,
isHighlight: boolean,
displayedNumber: string | ReactNode[],
avatarDim: "small" | "base" | "extra_small" | "large" | "extra_large",
username: string | undefined,
import { NumberCaller } from '../../../NumberCaller'
import { ContactType } from '@shared/types'
import { isDev } from '@shared/utils/utils'
import { FavouriteStar } from './FavouritesStar'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { useAccount } from '@renderer/hooks/useAccount'
import { useNethlinkData } from '@renderer/store'
import { usePhoneIslandEventHandler } from '@renderer/hooks/usePhoneIslandEventHandler'
import { Avatar } from '../../../Nethesis'
import { faPhone as CallIcon } from '@fortawesome/free-solid-svg-icons'
import { t } from 'i18next'
import { ReactNode } from 'react'
import classNames from 'classnames'
export const ContactNameAndActions = ({
contact,
number,
isHighlight,
displayedNumber,
avatarDim,
username,
isFavourite,
isSearchData
}: {
contact: ContactType
number: string
isHighlight: boolean
displayedNumber: string | ReactNode[]
avatarDim: 'small' | 'base' | 'extra_small' | 'large' | 'extra_large'
username: string | undefined
isFavourite: boolean
isSearchData: boolean
}) => {
Expand All @@ -28,46 +35,79 @@ export const ContactNameAndActions = ({ contact, number, isHighlight, displayedN
const { callNumber } = usePhoneIslandEventHandler()
const avatarSrc = username && operators?.avatars?.[username]

const isOperator = username && !!(operators?.operators?.[username])
const isOperator = username && !!operators?.operators?.[username]

return (
<div className={classNames(avatarDim === 'small' ? 'gap-3' : 'gap-6', "flex flex-row items-center w-full max-w-full")}
<div
className={classNames(
avatarDim === 'small' ? 'gap-3' : 'gap-6',
'flex flex-row items-center w-full max-w-full'
)}
>
<Avatar
size={avatarDim}
src={avatarSrc}
status={isOperator ? operators?.operators?.[username]?.mainPresence : undefined}
bordered={true}
placeholderType={operators?.extensions[contact.speeddial_num || ''] ? 'operator' : 'person'}
placeholderType={
operators?.extensions[contact?.speeddial_num || '']
? 'operator'
: contact?.kind === 'company'
? 'company'
: 'person'
}
/>
<div className='relative w-full h-[44px] '>
<div className="relative w-full h-[44px] ">
<div className="absolute top-0 left-0 flex flex-col gap-1 w-full ">
<div className="flex flex-row gap-2 w-full overflow-hidden">
<div className='dark:text-titleDark text-titleLight font-medium text-[14px] leading-5 truncate break-all whitespace-nowrap '>
{isFavourite ? (contact.company || `${t('Common.Unknown')}`) : (contact.name || contact.company || `${t('Common.Unknown')}`)}
{isDev() && <span
onClick={() => {
navigator.clipboard.writeText(JSON.stringify({ contact, number, isHighlight, displayedNumber, avatarDim, username, isFavourite, isSearchData }))
}}
className='absolute top-[-4px] left-[-26px] text-[8px] cursor-pointer'>[{contact.id}]</span>}
<div className="dark:text-titleDark text-titleLight font-medium text-[14px] leading-5 truncate break-all whitespace-nowrap ">
{isFavourite
? contact.company || `${t('Common.Unknown')}`
: contact.name || contact.company || `${t('Common.Unknown')}`}
{isDev() && (
<span
onClick={() => {
navigator.clipboard.writeText(
JSON.stringify({
contact,
number,
isHighlight,
displayedNumber,
avatarDim,
username,
isFavourite,
isSearchData
})
)
}}
className="absolute top-[-4px] left-[-26px] text-[8px] cursor-pointer"
>
[{contact.id}]
</span>
)}
</div>
{isOperator && <FavouriteStar contact={contact} isSearchData={isSearchData} />}
</div>
<div className="flex flex-row gap-2 items-center">
{!isHighlight &&
{!isHighlight && (
<FontAwesomeIcon
className="dark:text-gray-400 text-gray-600 text-base"
icon={CallIcon}
onClick={() => callNumber(contact.speeddial_num!)}
/>
}
)}
<NumberCaller
number={number}
disabled={!isCallsEnabled}
className="dark:text-textBlueDark text-textBlueLight font-normal hover:underline"
disabled={displayedNumber?.length === 0 || !isCallsEnabled}
className={`${displayedNumber?.length === 0 ? '' : 'dark:text-textBlueDark text-textBlueLight'}font-normal hover:underline`}
isNumberHiglighted={isHighlight}
>
{displayedNumber}
{displayedNumber !== ' ' &&
displayedNumber !== '' &&
displayedNumber !== null &&
(!Array.isArray(displayedNumber) || displayedNumber.length > 0)
? displayedNumber
: '-'}
</NumberCaller>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export function SearchNumber({ user, className }: SearchNumberProps) {
while (index !== -1) {
parts.push(number.substring(lastIndex, index))
parts.push(
<span key={`highlight_${index}`} className="dark:text-textBlueDark text-textBlueLight font-medium text-[1rem]">
<span
key={`highlight_${index}`}
className="dark:text-textBlueDark text-textBlueLight font-medium text-[1rem]"
>
{number.substring(index, index + searchText.length)}
</span>
)
Expand Down Expand Up @@ -76,7 +79,7 @@ export function SearchNumber({ user, className }: SearchNumberProps) {
<div className="group">
<div className="flex justify-between w-full min-h-14 py-2 px-5 dark:text-titleDark text-titleDark dark:hover:bg-hoverDark hover:bg-hoverLight">
<ContactNameAndActions
avatarDim='small'
avatarDim="small"
contact={user}
number={phoneNumber}
displayedNumber={highlightedNumber}
Expand All @@ -85,18 +88,20 @@ export function SearchNumber({ user, className }: SearchNumberProps) {
isFavourite={false}
isSearchData={true}
/>
<Button
className="group-hover:bg-transparent"
variant="ghost"
disabled={!isCallsEnabled}
onClick={() => {
callNumber(phoneNumber!)
}}
>
<p className="dark:text-textBlueDark text-textBlueLight font-medium text-[14px] leading-5">
{t('Operators.Call')}
</p>
</Button>
{phoneNumber && phoneNumber !== '' && (
<Button
className="group-hover:bg-transparent"
variant="ghost"
disabled={!isCallsEnabled}
onClick={() => {
callNumber(phoneNumber!)
}}
>
<p className="dark:text-textBlueDark text-textBlueLight font-medium text-[14px] leading-5">
{t('Operators.Call')}
</p>
</Button>
)}
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const usePhonebookSearchModule = (): {
return mapContact(contact)
})
const filteredNumbers = receivedPhoneNumbers.rows.filter(
(phoneNumber) => !(!phoneNumber.name || phoneNumber.name === '')
(phoneNumber) => !(!phoneNumber?.displayName || phoneNumber?.displayName === '')
)
return filteredNumbers
}
Expand Down
1 change: 1 addition & 0 deletions src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export type ContactType = {
privacy?: string
favorite?: boolean
selectedPrefNum?: string
kind?: string
}

export type ParkingType = {
Expand Down
1 change: 1 addition & 0 deletions src/shared/useNethVoiceAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export const useNethVoiceAPI = (loggedAccount: Account | undefined = undefined)
//DEFAULT VALUES
favorite: false,
selectedPrefNum: 'extension',
kind: 'person'
}
await _POST(`/webrest/phonebook/create`, newContact)
return newContact
Expand Down