:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { Meta, StoryObj } from '@storybook/react'
import { router } from 'kea-router'
import { useDelayedOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { passwordResetLogic } from 'scenes/authentication/password-reset/passwordResetLogic'
import { urls } from 'scenes/urls'
import { useStorybookMocks } from '~/mocks/browser'
import preflightJson from '~/mocks/fixtures/_preflight.json'
import { PasswordReset } from './PasswordReset'
// some metadata and optional parameters
const meta: Meta = {
title: 'Scenes-Other/Password Reset',
parameters: {
layout: 'fullscreen',
viewMode: 'story',
},
}
export default meta
type Story = StoryObj<{}>
// export more stories with different state
export const NoSMTP: Story = {
render: () => {
useStorybookMocks({
get: {
'/_preflight': {
...preflightJson,
cloud: false,
realm: 'hosted-clickhouse',
available_social_auth_providers: {
github: false,
gitlab: false,
'google-oauth2': false,
saml: false,
},
email_service_available: false,
},
},
})
return <PasswordReset />
},
}
export const Initial: Story = {
render: () => {
useStorybookMocks({
get: {
'/_preflight': {
...preflightJson,
cloud: false,
realm: 'hosted-clickhouse',
available_social_auth_providers: {
github: false,
gitlab: false,
'google-oauth2': false,
saml: false,
},
email_service_available: true,
},
},
post: {
'/api/reset': {},
},
})
return <PasswordReset />
},
}
export const Success: Story = {
render: () => {
useStorybookMocks({
get: {
'/_preflight': {
...preflightJson,
cloud: false,
realm: 'hosted-clickhouse',
available_social_auth_providers: {
github: false,
gitlab: false,
'google-oauth2': false,
saml: false,
},
email_service_available: true,
},
},
post: {
'/api/reset': {},
},
})
useDelayedOnMountEffect(() => {
passwordResetLogic.actions.setRequestPasswordResetValues({ email: '[email protected]' })
passwordResetLogic.actions.submitRequestPasswordResetSuccess({ email: '[email protected]' })
})
return <PasswordReset />
},
}
export const Throttled: Story = {
render: () => {
useStorybookMocks({
get: {
'/_preflight': {
...preflightJson,
cloud: false,
realm: 'hosted-clickhouse',
available_social_auth_providers: {
github: false,
gitlab: false,
'google-oauth2': false,
saml: false,
},
email_service_available: true,
},
},
post: {
'/api/reset': {},
},
})
useDelayedOnMountEffect(() => {
passwordResetLogic.actions.setRequestPasswordResetValues({ email: '[email protected]' })
passwordResetLogic.actions.setRequestPasswordResetManualErrors({ code: 'throttled' })
})
return <PasswordReset />
},
}
export const WithEmailFromQuery: Story = {
render: () => {
useStorybookMocks({
get: {
'/_preflight': {
...preflightJson,
cloud: false,
realm: 'hosted-clickhouse',
available_social_auth_providers: {
github: false,
gitlab: false,
'google-oauth2': false,
saml: false,
},
email_service_available: true,
},
},
post: {
'/api/reset': {},
},
})
useDelayedOnMountEffect(() => router.actions.push(urls.passwordReset(), { email: '[email protected]' }))
return <PasswordReset />
},
}