forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add modal on get started page for onboarding experiment v2
- Loading branch information
1 parent
41750d6
commit 0da951b
Showing
3 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
apps/web/src/pages/quick-start/components/OnboadingExperimentModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { useState } from 'react'; | ||
import { Modal, useMantineTheme, Grid } from '@mantine/core'; | ||
|
||
import styled from '@emotion/styled'; | ||
import { colors, shadows, Title, Button } from '@novu/design-system'; | ||
import { useAuthContext, useSegment } from '@novu/shared-web'; | ||
import { useCreateOnboardingExperimentWorkflow } from '../../../api/hooks/notification-templates/useCreateOnboardingExperimentWorkflow'; | ||
|
||
export function OnboardingExperimentModal() { | ||
const [opened, setOpened] = useState(true); | ||
const theme = useMantineTheme(); | ||
const segment = useSegment(); | ||
const { currentOrganization } = useAuthContext(); | ||
const { | ||
createOnboardingExperimentWorkflow, | ||
isLoading: IsCreateOnboardingExpWorkflowLoading, | ||
isDisabled: isIsCreateOnboardingExpWorkflowDisabled, | ||
} = useCreateOnboardingExperimentWorkflow(); | ||
const handleOnClose = () => { | ||
setOpened(true); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
opened={opened} | ||
overlayColor={theme.colorScheme === 'dark' ? colors.BGDark : colors.BGLight} | ||
overlayOpacity={0.7} | ||
styles={{ | ||
modal: { | ||
backgroundColor: theme.colorScheme === 'dark' ? colors.B15 : colors.white, | ||
width: '700px', | ||
}, | ||
body: { | ||
paddingTop: '5px', | ||
paddingInline: '8px', | ||
}, | ||
}} | ||
title={<Title size={2}>What would you like to do first?</Title>} | ||
sx={{ backdropFilter: 'blur(10px)' }} | ||
shadow={theme.colorScheme === 'dark' ? shadows.dark : shadows.medium} | ||
radius="md" | ||
size="lg" | ||
onClose={handleOnClose} | ||
centered | ||
withCloseButton={false} | ||
> | ||
<Grid> | ||
<Grid.Col xs={12} md={6} mb={20}> | ||
<ChannelCard> | ||
<TitleRow> {'Send test notification'}</TitleRow> | ||
<Description>{'Learn how to setup a workflow and send your first email notification.'}</Description> | ||
<StyledButton | ||
loading={IsCreateOnboardingExpWorkflowLoading} | ||
disabled={isIsCreateOnboardingExpWorkflowDisabled} | ||
pulse={true} | ||
variant={'gradient'} | ||
onClick={async () => { | ||
segment.track('Buton Clicked - [Onboarding]', { | ||
action: 'Modal - Send test notification', | ||
experiment_id: '2024-w15-onb', | ||
_organization: currentOrganization?._id, | ||
}); | ||
localStorage.removeItem('onboarding_modal'); | ||
createOnboardingExperimentWorkflow(); | ||
}} | ||
> | ||
{'Send test notification now'} | ||
</StyledButton> | ||
</ChannelCard> | ||
</Grid.Col> | ||
<Grid.Col xs={12} md={6} mb={20}> | ||
<ChannelCard> | ||
<TitleRow> {'Look around'}</TitleRow> | ||
<Description>{'Start exploring the Novu app on your own terms'}</Description> | ||
<StyledButton | ||
variant={'outline'} | ||
onClick={async () => { | ||
segment.track('Buton Clicked - [Onboarding]', { | ||
action: 'Modal - Get started', | ||
experiment_id: '2024-w15-onb', | ||
_organization: currentOrganization?._id, | ||
}); | ||
localStorage.removeItem('onboarding_modal'); | ||
setOpened(false); | ||
}} | ||
> | ||
{'Get started'} | ||
</StyledButton> | ||
</ChannelCard> | ||
</Grid.Col> | ||
</Grid> | ||
</Modal> | ||
); | ||
} | ||
|
||
const ChannelCard = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
flex-direction: column; | ||
max-width: 230px; | ||
`; | ||
|
||
const TitleRow = styled.div` | ||
display: flex; | ||
align-items: center; | ||
font-size: 20px; | ||
line-height: 32px; | ||
margin-bottom: 8px; | ||
`; | ||
|
||
const Description = styled.div` | ||
flex: auto; | ||
font-size: 16px; | ||
line-height: 20px; | ||
margin-bottom: 20px; | ||
color: ${colors.B60}; | ||
height: 60px; | ||
`; | ||
|
||
const StyledButton = styled(Button)` | ||
width: fit-content; | ||
outline: none; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters