Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | import { css, useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { IconSquareNumber1Filled, IconSquareNumber2Filled, IconSquareNumber3Filled } from '@tabler/icons-react'; import { memo, type ReactNode } from 'react'; import { FormattedMessage } from 'react-intl'; import { Group, Typography, UnstyledButton } from '@allshares/studio-design-system'; import { ChallengeNotifyButtonWithModal } from '@amalia/payout-definition/challenges/components'; import { useLaunchChallengeNotificationStatus } from '@amalia/payout-definition/challenges/state'; import { ChallengeLaunchNotificationStatus } from '@amalia/payout-definition/plans/types'; import { useDesignerLibrary } from '../../hooks/use-designer-library'; import { usePlanHubRuleDesignerChallengeStepTab } from '../../hooks/use-plan-hub-rule-designer-step-tab'; import { usePlanHubRuleDesignerContext } from '../../PlanHubRuleDesigner.context'; import { useIsCurrentPlanArchived } from '../../shared/use-is-current-plan-archived'; import { type PlanHubRuleDesignerChallengeStepTabs } from '../plan-hub-rule-designer-step-tabs.types'; const StyledContainer = styled(Group)` width: 100%; justify-content: space-between; padding: 0 24px; `; const StyledTabs = styled(Group)` align-items: center; height: 70px; // To apply the blue border to the border-bottom of the group margin-bottom: -6px; `; const StyledTabButton = styled(UnstyledButton, { shouldForwardProp: (prop) => prop !== 'isSelected', })<{ isSelected: boolean }>` display: flex; align-items: center; padding: 6px 16px 16px 16px; border-bottom: 4px solid ${({ isSelected, theme }) => (isSelected ? theme.ds.colors.primary[400] : 'none')}; `; const StyledTabTitle = styled(Typography, { shouldForwardProp: (prop) => prop !== 'isSelected', })<{ isSelected: boolean }>` margin-left: 8px; color: ${({ isSelected, theme }) => theme.ds.colors.gray[isSelected ? 900 : 700]}; [data-color-scheme='dark'] & { color: ${({ isSelected, theme }) => theme.ds.colors.gray[isSelected ? 100 : 400]}; } `; export const PlanHubRuleDesignerChallengeTabs = memo(function PlanHubRuleDesignerChallengeTabs() { const theme = useTheme(); const { ruleId } = usePlanHubRuleDesignerContext(); const { accessors } = useDesignerLibrary(); const ruleDefinition = accessors.getRuleById(ruleId); const isPlanArchived = useIsCurrentPlanArchived(); const [selectedRuleDesignerTab, setSelectedRuleDesignerTab] = usePlanHubRuleDesignerChallengeStepTab(); const { data: launchNotificationsStatus, isSuccess } = useLaunchChallengeNotificationStatus(ruleId); return ( <StyledContainer align="center"> <StyledTabs> {Array.from<{ tabValue: PlanHubRuleDesignerChallengeStepTabs; TabIcon: typeof IconSquareNumber1Filled | typeof IconSquareNumber2Filled | typeof IconSquareNumber3Filled; tabLabel: ReactNode; }>([ { tabValue: '1-define-duration', TabIcon: IconSquareNumber1Filled, tabLabel: <FormattedMessage defaultMessage="Define duration" />, }, { tabValue: '2-select-evaluation-criterion', TabIcon: IconSquareNumber2Filled, tabLabel: <FormattedMessage defaultMessage="Select evaluation criterion" />, }, { tabValue: '3-set-prize-table', TabIcon: IconSquareNumber3Filled, tabLabel: <FormattedMessage defaultMessage="Set prize table" />, }, ]).map(({ tabValue, TabIcon, tabLabel }, tabIndex) => { const isSelectedTab = selectedRuleDesignerTab === tabValue; const titlePrefix = `${tabIndex + 1}. `; return ( <StyledTabButton key={tabValue} isSelected={isSelectedTab} onClick={() => setSelectedRuleDesignerTab(tabValue)} > {!!isSelectedTab && ( <TabIcon fill={theme.ds.colors.primary[400]} size={24} /> )} <StyledTabTitle isSelected={isSelectedTab} variant={isSelectedTab ? 'heading2Bold' : 'bodyLargeRegular'} > {!isSelectedTab && titlePrefix} {tabLabel} </StyledTabTitle> </StyledTabButton> ); })} </StyledTabs> {!!isSuccess && (launchNotificationsStatus === ChallengeLaunchNotificationStatus.SENT ? ( <Typography variant="bodyBaseRegular" css={css` font-style: italic; `} > <FormattedMessage defaultMessage="Participants notified about challenge launch" /> </Typography> ) : isPlanArchived ? null : ( <ChallengeNotifyButtonWithModal ruleConfiguration={ruleDefinition?.configuration} ruleId={ruleId} size="large" /> ))} </StyledContainer> ); }); |