diff --git a/src/components/index.ts b/src/components/index.ts index 6365340..917373f 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,7 +1,7 @@ export * from './buttons'; export * from './channel-icon-menu'; export * from './error-renderer'; -export * from './ui/header' +export * from './ui/header'; export * from './layout'; export * from './loaders'; export * from './modal'; diff --git a/src/components/menu/index.tsx b/src/components/menu/index.tsx index 672125d..1c246dc 100644 --- a/src/components/menu/index.tsx +++ b/src/components/menu/index.tsx @@ -33,13 +33,10 @@ const Menu = (props: IMenu) => { const active = currentLocation === path; return ( - - + + + +

{menuItem}

); @@ -48,4 +45,4 @@ const Menu = (props: IMenu) => { ); }; -export default Menu; \ No newline at end of file +export default Menu; diff --git a/src/components/menu/style.ts b/src/components/menu/style.ts index 21429b8..9d19bf3 100644 --- a/src/components/menu/style.ts +++ b/src/components/menu/style.ts @@ -5,10 +5,7 @@ import * as styled from 'styled-components'; import {Link} from 'components/ui'; import {theme, paddings} from 'components/shared/theme'; -const { - colors, - primaryThemeColor -} = theme; +const {colors, primaryThemeColor} = theme; export const MenuLayout = styled.default.div` display: flex; @@ -37,4 +34,4 @@ export const MenuItem = styled.default(Link)` font-size: 22px; margin: 0 ${paddings.medium} 0 0; } -`; \ No newline at end of file +`; diff --git a/src/components/side-menu/index.tsx b/src/components/side-menu/index.tsx index 903aca2..29795bf 100644 --- a/src/components/side-menu/index.tsx +++ b/src/components/side-menu/index.tsx @@ -12,15 +12,10 @@ import Menu from 'components/menu'; import NewTabLink from 'components/new-tab-link'; import Toggle from 'components/toggle'; -import { - Overlay, - MenuView, - SnapToBottom, - FooterContainer -} from './style'; +import {Overlay, MenuView, SnapToBottom, FooterContainer} from './style'; import config from 'config'; -export const SideMenu = ({showMenu}: {showMenu: () => void }): JSX.Element => { +export const SideMenu = ({showMenu}: {showMenu: () => void}): JSX.Element => { const dispatch = useAppDispatch(); const timeFormat = useAppSelector((state: RootState) => state.preferredTimeFormat.timeFormat); const handleToggleChange = () => { @@ -38,19 +33,11 @@ export const SideMenu = ({showMenu}: {showMenu: () => void }): JSX.Element => { - - + + ); -}; \ No newline at end of file +}; diff --git a/src/components/side-menu/style.ts b/src/components/side-menu/style.ts index a73cc8b..882f364 100644 --- a/src/components/side-menu/style.ts +++ b/src/components/side-menu/style.ts @@ -5,7 +5,11 @@ import * as styled from 'styled-components'; import {theme, paddings} from 'components/shared/theme'; import {ToggleContainer} from 'components/toggle/style'; -const {colors, footerHeight, typography: {fontSizeS}} = theme; +const { + colors, + footerHeight, + typography: {fontSizeS} +} = theme; export const Overlay = styled.default.div` position: fixed; @@ -54,4 +58,4 @@ export const FooterContainer = styled.default.div` ${ToggleContainer} { justify-content: flex-start; } -`; \ No newline at end of file +`; diff --git a/src/components/table-screen-header/table-screen-header.tsx b/src/components/table-screen-header/table-screen-header.tsx index f202c3d..3783777 100644 --- a/src/components/table-screen-header/table-screen-header.tsx +++ b/src/components/table-screen-header/table-screen-header.tsx @@ -11,7 +11,7 @@ export interface ITableScreenHeader { title: string; subtitle?: string; screenHeader: ScreenHeaderProps; - renderControl: (screenHeader: ScreenHeaderProps, key: TableHeaderKey) => JSX.Element | null; + renderControl?: (key: TableHeaderKey) => JSX.Element | null; } export const TableScreenHeader = ({title, subtitle = '', screenHeader, renderControl}: ITableScreenHeader): JSX.Element => { @@ -23,7 +23,7 @@ export const TableScreenHeader = ({title, subtitle = '', screenHeader, renderCon {Object.keys(screenHeader).map(key => { - const headerControl = screenHeader[key].render ? screenHeader[key].render(key) : renderControl(screenHeader, key as TableHeaderKey); + const headerControl = screenHeader[key].render ? screenHeader[key].render(key) : renderControl?.(key as TableHeaderKey); return headerControl ? {headerControl} : null; })} diff --git a/src/components/table-with-pagination/table-with-pagination.tsx b/src/components/table-with-pagination/table-with-pagination.tsx index d90417e..e81f5a6 100644 --- a/src/components/table-with-pagination/table-with-pagination.tsx +++ b/src/components/table-with-pagination/table-with-pagination.tsx @@ -1,7 +1,7 @@ /** * Copyright 2024 Phenix Real Time Solutions, Inc. Confidential and Proprietary. All Rights Reserved. */ -import {useEffect, useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {DataRowType, Table, TableHeaderKey, ITable, ITableWithPaginationHeader, ITableSort} from 'components/table'; import {isEqual} from 'utility/validators'; @@ -17,7 +17,7 @@ import {useSort, useSearch} from 'utility/custom-hooks'; interface ITableWithPagination extends ITable { screenHeader: ITableWithPaginationHeader; paginationItemText?: string; - getCurrentDisplayList?: (data: Record[]) => void; + getCurrentDisplayList?: (data: Record[]) => void; } const TableWithPagination = ({ @@ -34,7 +34,7 @@ const TableWithPagination = ({ changeSortProps, searchValue: propsSearchValue = '', changeSearch -}: ITableWithPagination): JSX.Element => { +}: ITableWithPagination): React.JSX.Element => { const [currentPageNumber, setCurrentPageNumber] = useState(1); const [currentData, setCurrentData] = useState([]); const [filteredData, setFilteredData] = useState(data || []); @@ -78,9 +78,9 @@ const TableWithPagination = ({ useEffect(() => { let pxRatioBeforeZoom = window.devicePixelRatio; let windowHeightBeforeResize = window.innerHeight; - const trackResize = e => { - const pxRatioAfterZoom = e.devicePixelRatio; - const windowHeightAfterResize = e.target.innerHeight; + const trackResize = () => { + const pxRatioAfterZoom = window.devicePixelRatio; + const windowHeightAfterResize = window.innerHeight; if (pxRatioAfterZoom !== pxRatioBeforeZoom || windowHeightAfterResize !== windowHeightBeforeResize) { pxRatioBeforeZoom = pxRatioAfterZoom; @@ -153,27 +153,53 @@ const TableWithPagination = ({ } }; - const renderControl = (screenHeader: ITableWithPaginationHeader, key: TableHeaderKey) => { - switch (key) { - case TableHeaderKey.Search: - return ; - case TableHeaderKey.AddRow: - return ; - case TableHeaderKey.SelectType: - return + }; + } + + return result; + }, [screenHeader, search, searchValue]); return (
- +
- +
diff --git a/src/components/table/props.ts b/src/components/table/props.ts index 9a551ff..4bfe1d3 100644 --- a/src/components/table/props.ts +++ b/src/components/table/props.ts @@ -42,6 +42,7 @@ export interface ITableColumn { isHidden?: boolean; width?: number; path?: string; + applicationId?: string; } export type ColumnsType = Record; diff --git a/src/components/table/table-row.tsx b/src/components/table/table-row.tsx index eeddfdd..6880e36 100644 --- a/src/components/table/table-row.tsx +++ b/src/components/table/table-row.tsx @@ -18,7 +18,7 @@ export const TableRow = ({columns, row}: ITableRow): React.JSX.Element | null => return (
{Object.keys(columns).map((key, idx) => { - const {isHidden, renderCell, dropdownCell, textCell, type, path = '', tdStyle, width} = columns[key]; + const {isHidden, renderCell, dropdownCell, textCell, type, path = '', tdStyle, width, applicationId} = columns[key]; if (isHidden) { return null; @@ -60,12 +60,13 @@ export const TableRow = ({columns, row}: ITableRow): React.JSX.Element | null => ); } else if (type === CellType.Link) { - let link = path || ''; + // For channel names, use channelId for the URL but display the name + const channelId = globalThis.encodeURIComponent(row.channelId || value); + let link = path ? `${path}/${channelId}` : `/channels/${channelId}`; if (row.extraPath) { link += `${path ? '/' : ''}${row.extraPath}`; } - return (
diff --git a/src/components/toggle/index.tsx b/src/components/toggle/index.tsx index 91a593a..2069f9c 100644 --- a/src/components/toggle/index.tsx +++ b/src/components/toggle/index.tsx @@ -1,14 +1,7 @@ /** * Copyright 2024 Phenix Real Time Solutions, Inc. Confidential and Proprietary. All Rights Reserved. */ -import { - ToggleContainer, - ToggleHiddenInput, - ToggleSwitchContainer, - ToggleSwitch, - ToggleTitleOn, - ToggleTitleOff -} from './style'; +import {ToggleContainer, ToggleHiddenInput, ToggleSwitchContainer, ToggleSwitch, ToggleTitleOn, ToggleTitleOff} from './style'; interface IToggle { handleChange: () => void; @@ -17,18 +10,13 @@ interface IToggle { position?: 'on' | 'off'; } const Toggle = (props: IToggle): JSX.Element => { - const { - onTitle, - offTitle, - handleChange, - position - } = props; + const {onTitle, offTitle, handleChange, position} = props; return ( {offTitle && {offTitle}} - + {onTitle && {onTitle}} @@ -36,4 +24,4 @@ const Toggle = (props: IToggle): JSX.Element => { ); }; -export default Toggle; \ No newline at end of file +export default Toggle; diff --git a/src/components/toggle/style.ts b/src/components/toggle/style.ts index 4c2cb18..c82e15b 100644 --- a/src/components/toggle/style.ts +++ b/src/components/toggle/style.ts @@ -5,7 +5,10 @@ import * as styled from 'styled-components'; import {theme} from 'components/shared/theme'; -const {colors, typography: {fontSizeS}} = theme; +const { + colors, + typography: {fontSizeS} +} = theme; export const ToggleContainer = styled.default.div` display: flex; @@ -66,4 +69,4 @@ export const ToggleHiddenInput = styled.default.input` } } } -`; \ No newline at end of file +`; diff --git a/src/components/ui/header/index.tsx b/src/components/ui/header/index.tsx index e8093b5..0bf1de1 100644 --- a/src/components/ui/header/index.tsx +++ b/src/components/ui/header/index.tsx @@ -1,12 +1,7 @@ /** * Copyright 2024 Phenix Real Time Solutions, Inc. Confidential and Proprietary. All Rights Reserved. */ -import { - useState, - useEffect, - useRef, - JSX -} from 'react'; +import {useState, useEffect, useRef, JSX} from 'react'; import {useNavigate, useLocation} from 'react-router-dom'; import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; import {faSignOutAlt} from '@fortawesome/free-solid-svg-icons'; @@ -19,14 +14,7 @@ import text from './text'; import {SideMenu} from 'components/side-menu'; import urlRoutes from 'routers/url-routes'; -import { - TopNavigation, - User, - ApplicationId, - UserInitials, - MenuIcon, - NavigationLeftSide -} from './style'; +import {TopNavigation, User, ApplicationId, UserInitials, MenuIcon, NavigationLeftSide} from './style'; import logo from 'assets/images/phenix-logo-101x41.png'; import menuIcon from 'assets/images/icon/menu.svg'; @@ -53,14 +41,14 @@ const Header = (): JSX.Element => { } }; - const checkAndRedirect = async(): Promise => { - const applicationId = await UserStoreService.get('applicationId') as string; + const checkAndRedirect = async (): Promise => { + const applicationId = (await UserStoreService.get('applicationId')) as string; if (!applicationId) { return navigate(`/login/${search}`); } - const lastVisitedRoutes = await UserStoreService.get>('lastVisitedRouteByApplicationId') as Record; + const lastVisitedRoutes = (await UserStoreService.get>('lastVisitedRouteByApplicationId')) as Record; const lastVisitedRoute = lastVisitedRoutes[applicationId]; const channelsPath = `/${urlRoutes.channels.path}/`; @@ -73,24 +61,10 @@ const Header = (): JSX.Element => { } }; - // const setLastVisitedRoute = async(): Promise => { - // const applicationId = await userStore.get('applicationId'); - // const lastVisitedRoutes = await userStore.get('lastVisitedRouteByApplicationId') || {}; - - // await userStore.set('lastVisitedRouteByApplicationId', { - // ...lastVisitedRoutes, - // [applicationId]: pathname - // }); - // }; - useEffect(() => { checkAndRedirect(); }, [isLoggedIn]); - // useEffect(() => { - // setLastVisitedRoute(); - // }, [pathname]); - useEffect(() => { document.addEventListener('click', handleClickOutside, true); @@ -99,27 +73,19 @@ const Header = (): JSX.Element => { }; }); - const handleLogout = async(): Promise => { + const handleLogout = async (): Promise => { dispatch(signoutThunk()); }; const handleCaretClick = () => setViewUserDetails(!viewUserDetails); - console.log('isLoggedIn', isLoggedIn); - return ( - {(isLoggedIn && applicationId) && - setShowMenu(!showMenu)} - src={menuIcon} - alt="menuIcon" - /> - } + {isLoggedIn && applicationId && setShowMenu(!showMenu)} src={menuIcon} alt="menuIcon" />} {phenixText} - {(isLoggedIn && applicationId) && + {isLoggedIn && applicationId && ( <> {userInitials} @@ -128,13 +94,11 @@ const Header = (): JSX.Element => {
- {showMenu && - setShowMenu(!showMenu)} /> - } + {showMenu && setShowMenu(!showMenu)} />} - } + )} ); }; -export default Header; \ No newline at end of file +export default Header; diff --git a/src/components/ui/header/style.tsx b/src/components/ui/header/style.tsx index c525a04..f86e7e2 100644 --- a/src/components/ui/header/style.tsx +++ b/src/components/ui/header/style.tsx @@ -19,10 +19,12 @@ export const TopNavigation = styled.default.div<{isLoggedIn: boolean}>` left: 0; right: 0; z-index: 1000; - ${({isLoggedIn}) => isLoggedIn && styled.css` - background-color: ${colors.headerColor}; - padding: ${paddings.small} ${paddings.xlarge}; - `} + ${({isLoggedIn}) => + isLoggedIn && + styled.css` + background-color: ${colors.headerColor}; + padding: ${paddings.small} ${paddings.xlarge}; + `} `; export const NavigationLeftSide = styled.default.div` @@ -73,4 +75,4 @@ export const UserInitials = styled.default.div` ${mediaPhone} { display: none; } -`; \ No newline at end of file +`; diff --git a/src/components/ui/header/text.ts b/src/components/ui/header/text.ts index 18ce8dc..21cae21 100644 --- a/src/components/ui/header/text.ts +++ b/src/components/ui/header/text.ts @@ -4,4 +4,4 @@ export default { applicationIdText: 'Application Id', phenixText: 'Phenix' -}; \ No newline at end of file +};