Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 7 additions & 5 deletions app/components/UI/Perps/Views/PerpsHomeView/PerpsHomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,13 @@ const PerpsHomeView = ({
setTitleSectionHeight(event.nativeEvent.layout.height)
}
>
{isServiceInterruptionBannerEnabled && (
<Box twClassName="px-4 mb-4">
<PerpsServiceInterruptionBanner
testID={PerpsHomeViewSelectorsIDs.SERVICE_INTERRUPTION_BANNER}
/>
</Box>
)}
Comment thread
brianacnguyen marked this conversation as resolved.
<TitleHub
testID={PerpsHomeViewSelectorsIDs.HOME_HEADING}
title={hideHeader ? undefined : perpsScreenTitle}
Expand Down Expand Up @@ -1122,11 +1129,6 @@ const PerpsHomeView = ({
</Box>

<Box paddingBottom={3}>
{/* Service Interruption Banner */}
<PerpsServiceInterruptionBanner
testID={PerpsHomeViewSelectorsIDs.SERVICE_INTERRUPTION_BANNER}
/>

{/* Balance Actions Component */}
<PerpsMarketBalanceActions
showActionButtons={HOME_SCREEN_CONFIG.ShowHeaderActionButtons}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,17 @@ describe('PerpsServiceInterruptionBanner', () => {
expect(getByText('Contact support')).toBeOnTheScreen();
});

it('navigates to support when support link pressed', () => {
it('navigates to support when contact support action button pressed', () => {
useSelector.mockImplementation((selector: unknown) => {
if (selector === selectPerpsServiceInterruptionBannerEnabledFlag) {
return true;
}
return undefined;
});

const { getByTestId } = render(<PerpsServiceInterruptionBanner />);
const { getByText } = render(<PerpsServiceInterruptionBanner />);

fireEvent.press(
getByTestId('perps-service-interruption-banner-support-link'),
);
fireEvent.press(getByText('Contact support'));

expect(mockNavigate).toHaveBeenCalledTimes(1);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,16 @@
import React, { useCallback } from 'react';
import { StyleSheet } from 'react-native';
import { useSelector } from 'react-redux';
import { useNavigation } from '@react-navigation/native';
import {
Box,
Text,
Icon,
IconName,
IconSize,
TextVariant,
TextColor,
BoxFlexDirection,
BoxAlignItems,
BoxBackgroundColor,
IconColor,
BannerAlert,
BannerAlertSeverity,
} from '@metamask/design-system-react-native';
import { strings } from '../../../../../../locales/i18n';
import Routes from '../../../../../constants/navigation/Routes';
import { selectPerpsServiceInterruptionBannerEnabledFlag } from '../../selectors/featureFlags';
import { SUPPORT_CONFIG } from '../../constants/perpsConfig';
import type { PerpsServiceInterruptionBannerProps } from './PerpsServiceInterruptionBanner.types';

const styles = StyleSheet.create({
container: {
marginTop: 8,
marginBottom: 8,
},
banner: {
borderRadius: 12,
paddingHorizontal: 12,
paddingVertical: 12,
gap: 8,
},
titleRow: {
gap: 8,
},
iconContainer: {
width: 34,
height: 34,
borderRadius: 8,
alignItems: 'center',
justifyContent: 'center',
},
underline: {
textDecorationLine: 'underline',
},
});

const PerpsServiceInterruptionBanner: React.FC<
PerpsServiceInterruptionBannerProps
> = ({ testID = 'perps-service-interruption-banner' }) => {
Expand All @@ -70,51 +34,14 @@ const PerpsServiceInterruptionBanner: React.FC<
}

return (
<Box style={styles.container} testID={testID}>
<Box
style={styles.banner}
backgroundColor={BoxBackgroundColor.BackgroundMuted}
>
{/* Title row: icon + heading */}
<Box
flexDirection={BoxFlexDirection.Row}
alignItems={BoxAlignItems.Center}
style={styles.titleRow}
>
<Box
style={styles.iconContainer}
backgroundColor={BoxBackgroundColor.WarningMuted}
>
<Icon
name={IconName.FlashSlash}
size={IconSize.Md}
color={IconColor.WarningDefault}
/>
</Box>
<Text
variant={TextVariant.HeadingSm}
color={TextColor.WarningDefault}
>
{strings('perps.service_interruption.title')}
</Text>
</Box>

{/* Description aligned to left */}
<Text variant={TextVariant.BodySm} color={TextColor.TextAlternative}>
{strings('perps.service_interruption.description')}{' '}
<Text
variant={TextVariant.BodySm}
color={TextColor.TextAlternative}
style={styles.underline}
onPress={handleSupportPress}
accessibilityRole="link"
testID={`${testID}-support-link`}
>
{strings('perps.service_interruption.contact_support')}
</Text>
</Text>
</Box>
</Box>
<BannerAlert
severity={BannerAlertSeverity.Warning}
title={strings('perps.service_interruption.title')}
description={strings('perps.service_interruption.description')}
actionButtonLabel={strings('perps.service_interruption.contact_support')}
actionButtonOnPress={handleSupportPress}
testID={testID}
/>
);
};

Expand Down
Loading