@@ -5,17 +5,19 @@ import React, { useContext, useState } from 'react';
55import useSendbirdStateContext from '../../../../hooks/useSendbirdStateContext' ;
66import { useChannelSettingsContext } from '../../context/ChannelSettingsProvider' ;
77
8+ import { ChannelSettingsHeader , type ChannelSettingsHeaderProps } from './ChannelSettingsHeader' ;
9+
810import PlaceHolder , { PlaceHolderTypes } from '../../../../ui/PlaceHolder' ;
911import Label , { LabelTypography , LabelColors } from '../../../../ui/Label' ;
1012import { LocalizationContext } from '../../../../lib/LocalizationContext' ;
1113import Icon , { IconTypes , IconColors } from '../../../../ui/Icon' ;
12- import IconButton from '../../../../ui/IconButton' ;
1314import ChannelProfile from '../ChannelProfile' ;
1415import ModerationPanel from '../ModerationPanel' ;
1516import LeaveChannelModal from '../LeaveChannel' ;
1617import UserPanel from '../UserPanel' ;
1718
1819export interface ChannelSettingsUIProps {
20+ renderHeader ?: ( props : ChannelSettingsHeaderProps ) => React . ReactElement ;
1921 renderChannelProfile ?: ( ) => React . ReactElement ;
2022 renderModerationPanel ?: ( ) => React . ReactElement ;
2123 renderLeaveChannel ?: ( ) => React . ReactElement ;
@@ -24,61 +26,38 @@ export interface ChannelSettingsUIProps {
2426}
2527
2628const ChannelSettingsUI : React . FC < ChannelSettingsUIProps > = ( {
29+ renderHeader = ( props ) => < ChannelSettingsHeader { ...props } /> ,
2730 renderLeaveChannel,
2831 renderChannelProfile,
2932 renderModerationPanel,
3033 renderPlaceholderError,
3134 renderPlaceholderLoading,
3235} : ChannelSettingsUIProps ) => {
33- const { stringSet } = useContext ( LocalizationContext ) ;
34-
3536 const state = useSendbirdStateContext ( ) ;
37+ const isOnline = state ?. config ?. isOnline ;
38+ const { stringSet } = useContext ( LocalizationContext ) ;
3639 const { channel, invalidChannel, onCloseClick, loading } = useChannelSettingsContext ( ) ;
37-
3840 const [ showLeaveChannelModal , setShowLeaveChannelModal ] = useState ( false ) ;
3941
40- const isOnline = state ?. config ?. isOnline ;
41- const logger = state ?. config ?. logger ;
42-
43- const renderHeaderArea = ( ) => {
44- return (
45- < div className = "sendbird-channel-settings__header" >
46- < Label type = { LabelTypography . H_2 } color = { LabelColors . ONBACKGROUND_1 } >
47- { stringSet . CHANNEL_SETTING__HEADER__TITLE }
48- </ Label >
49- < div className = "sendbird-channel-settings__header-icon" >
50- < IconButton
51- width = "32px"
52- height = "32px"
53- onClick = { ( ) => {
54- logger . info ( 'ChannelSettings: Click close' ) ;
55- onCloseClick ?.( ) ;
56- } }
57- >
58- < Icon className = "sendbird-channel-settings__close-icon" type = { IconTypes . CLOSE } height = "22px" width = "22px" />
59- </ IconButton >
60- </ div >
61- </ div >
62- ) ;
63- } ;
64-
6542 if ( loading ) {
6643 if ( renderPlaceholderLoading ) return renderPlaceholderLoading ( ) ;
6744 return < PlaceHolder type = { PlaceHolderTypes . LOADING } /> ;
6845 }
6946
47+ const headerProps : ChannelSettingsHeaderProps = { onCloseClick } ;
48+
7049 if ( invalidChannel || ! channel ) {
7150 return (
7251 < div >
73- { renderHeaderArea ( ) }
52+ { renderHeader ( headerProps ) }
7453 < div > { renderPlaceholderError ? renderPlaceholderError ( ) : < PlaceHolder type = { PlaceHolderTypes . WRONG } /> } </ div >
7554 </ div >
7655 ) ;
7756 }
7857
7958 return (
8059 < >
81- { renderHeaderArea ( ) }
60+ { renderHeader ( headerProps ) }
8261 < div className = "sendbird-channel-settings__scroll-area" >
8362 { renderChannelProfile ?.( ) || < ChannelProfile /> }
8463 { renderModerationPanel ?.( ) || ( channel ?. myRole === 'operator' ? < ModerationPanel /> : < UserPanel /> ) }
0 commit comments