-
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.
Add pretty messages with call to action for Not Found and Error states: ![image](https://github.com/user-attachments/assets/9df8e556-88ed-4400-80f6-b62f46d3807e)
- Loading branch information
Showing
9 changed files
with
193 additions
and
22 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
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
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,21 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import DeadEnd from './DeadEnd' | ||
|
||
const meta: Meta<typeof DeadEnd> = { | ||
component: DeadEnd, | ||
tags: ['autodocs'], | ||
} | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof DeadEnd> | ||
|
||
/** DeadEnd tells users when their request can't be completed and they have to turn back. */ | ||
export const Primary: Story = { | ||
args: { | ||
title: 'Page not found', | ||
desc: "Sorry, we couldn't find the page you were looking for.", | ||
c2a: { text: 'Go home', to: '#' }, | ||
}, | ||
} |
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,45 @@ | ||
import { Link } from '@redwoodjs/router' | ||
|
||
import PageHead from '../PageHead/PageHead' | ||
import Typ from '../Typ/Typ' | ||
|
||
export type Props = { | ||
title: string | ||
desc: string | string[] | ||
c2a: { text: string } & ({ href: string } | { to: string }) | ||
} | ||
|
||
const DeadEnd = (props: Props) => { | ||
const { title, c2a } = props | ||
const desc = Array.isArray(props.desc) ? props.desc : [props.desc] | ||
|
||
const action = (() => { | ||
if ('href' in c2a) { | ||
return ( | ||
<a className="button is-primary mt-3" href={c2a.href}> | ||
{c2a.text} | ||
</a> | ||
) | ||
} else { | ||
return ( | ||
<Link className="button is-primary mt-3" to={c2a.to}> | ||
{c2a.text} | ||
</Link> | ||
) | ||
} | ||
})() | ||
|
||
return ( | ||
<div className="has-text-centered mx-auto" style={{ maxWidth: '600px' }}> | ||
<PageHead title={title} desc={desc.join(' ')} /> | ||
{desc.map((p, i) => ( | ||
<Typ x="p" key={i}> | ||
{p} | ||
</Typ> | ||
))} | ||
{action} | ||
</div> | ||
) | ||
} | ||
|
||
export default DeadEnd |
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import type { | ||
IgnoredEmailQuery, | ||
IgnoredEmailQueryVariables, | ||
ResubscribeMutation, | ||
ResubscribeMutationVariables, | ||
UnsubscribeMutation, | ||
|
@@ -10,6 +10,7 @@ import { type CellFailureProps, useMutation } from '@redwoodjs/web' | |
|
||
import { queryValue } from 'src/logic/path' | ||
|
||
import DeadEnd from '../DeadEnd/DeadEnd' | ||
import Typ from '../Typ/Typ' | ||
|
||
export const QUERY = gql` | ||
|
@@ -140,9 +141,21 @@ const ResubscribeForm = ({ | |
|
||
export const Loading = () => <div>Loading...</div> | ||
|
||
export const Failure = ({ error }: CellFailureProps<IgnoredEmailQuery>) => ( | ||
<ShowError error={error} /> | ||
) | ||
export const Failure = ({ | ||
error, | ||
}: CellFailureProps<IgnoredEmailQueryVariables>) => { | ||
console.error({ error }) | ||
return ( | ||
<DeadEnd | ||
title="Something went wrong" | ||
desc={[ | ||
"Sorry, we weren't able to process your request due to a technical issue.", | ||
'Please contact us at [email protected] for assistance.', | ||
]} | ||
c2a={{ text: 'Go home', to: '/' }} | ||
/> | ||
) | ||
} | ||
|
||
export const Empty = () => ( | ||
<UnsubscribeForm email={queryValue('email')} token={queryValue('token')} /> | ||
|
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
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