Files
mattermost-mobile/app/components/channel_actions/set_header_box/set_header.tsx
Elias Nahum a0f25f0e3b [Gekidou] Channel Info screen (#6330)
* Channel Info screen

* Delete the channel & related data when archiving while viewing archived channels is off

* feedback review

* UX feedback

* Add missing isOptionItem prop
2022-06-02 16:09:12 -04:00

53 lines
1.6 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useCallback} from 'react';
import {useIntl} from 'react-intl';
import {StyleProp, ViewStyle} from 'react-native';
import OptionBox from '@components/option_box';
import {Screens} from '@constants';
import {dismissBottomSheet, goToScreen, showModal} from '@screens/navigation';
type Props = {
channelId: string;
containerStyle?: StyleProp<ViewStyle>;
isHeaderSet: boolean;
inModal?: boolean;
testID?: string;
}
const SetHeaderBox = ({channelId, containerStyle, isHeaderSet, inModal, testID}: Props) => {
const intl = useIntl();
const onSetHeader = useCallback(async () => {
const title = intl.formatMessage({id: 'screens.channel_edit_header', defaultMessage: 'Edit Channel Header'});
if (inModal) {
goToScreen(Screens.CREATE_OR_EDIT_CHANNEL, title, {channelId, headerOnly: true});
return;
}
await dismissBottomSheet();
showModal(Screens.CREATE_OR_EDIT_CHANNEL, title, {channelId, headerOnly: true});
}, [intl, channelId]);
let text;
if (isHeaderSet) {
text = intl.formatMessage({id: 'channel_info.edit_header', defaultMessage: 'Edit Header'});
} else {
text = intl.formatMessage({id: 'channel_info.set_header', defaultMessage: 'Set Header'});
}
return (
<OptionBox
containerStyle={containerStyle}
iconName='pencil-outline'
onPress={onSetHeader}
testID={testID}
text={text}
/>
);
};
export default SetHeaderBox;