Skip to content

Commit

Permalink
Final updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mliu committed Sep 14, 2024
1 parent f514c1a commit 6c1fe6b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/huma-shared/src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export const checkIsDev = () =>
window.location.hostname.startsWith('v2') ||
window.location.hostname.startsWith('pr-') ||
window.location.hostname.startsWith('deploy-preview') ||
window.location.hostname.startsWith('localhost') ||
process.env.NODE_ENV === 'development'
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ export function Notifications({
}
}, [campaign, dispatch, handleAction])

return <NotifiSubscriptionModal handleSuccess={handleUserAction} />
return (
<NotifiSubscriptionModal
successText={campaign ? 'VIEW POINTS' : undefined}
handleSuccess={handleUserAction}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { LoadingModal } from '../LoadingModal'
import { WrapperModal } from '../WrapperModal'

type Props = {
successText?: string
handleSuccess: () => void
}

Expand All @@ -34,6 +35,7 @@ const validateDefaultTargetGroup = async (
}

export function NotifiSubscriptionModal({
successText,
handleSuccess,
}: Props): React.ReactElement {
const theme = useTheme()
Expand Down Expand Up @@ -93,6 +95,16 @@ export function NotifiSubscriptionModal({

await subscribeAlertsDefault(fusionEventTopics, targetGroupId)
await updateFtuStage(FtuStage.Done)

const targetGroup = (
await frontendClient?.fetchFusionData()
)?.targetGroup?.find((group) => group?.name === 'Default')
const emailTarget = targetGroup?.emailTargets?.[0]
if (emailTarget && !emailTarget.isConfirmed) {
await frontendClient.sendEmailTargetVerification({
targetId: emailTarget.id,
})
}
}

setShowSuccessScreen(true)
Expand All @@ -111,6 +123,7 @@ export function NotifiSubscriptionModal({
updateFtuStage,
isLoadingFtuStage,
ftuStage,
frontendClient,
])

useEffect(() => {
Expand Down Expand Up @@ -190,7 +203,7 @@ export function NotifiSubscriptionModal({
<CheckIcon />
</Box>
<BottomButton variant='contained' onClick={handleCloseModal}>
DONE
{successText ?? 'DONE'}
</BottomButton>
</WrapperModal>
)
Expand Down
2 changes: 1 addition & 1 deletion packages/huma-widget/src/hooks/useNotifi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const useIsFirstTimeNotifiUser = (

useEffect(() => {
const checkIsFirstTimeNotifiUser = async () => {
if (isInitialized && notifiChainSupported && !isLoadingFtu) {
if (isInitialized && notifiChainSupported) {
// If the user is not authenticated or expired, they are possibly a first time user.
if (!isAuthenticated || isExpired) {
setIsFirstTimeNotifiUser(true)
Expand Down

0 comments on commit 6c1fe6b

Please sign in to comment.