Skip to content

Commit

Permalink
Add full typing OOTB for all cell components
Browse files Browse the repository at this point in the history
  • Loading branch information
Philzen authored Dec 8, 2024
1 parent 455bae8 commit 76a2c13
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { ${operationName}, ${operationName}Variables } from 'types/graphql'

import type {
CellSuccessProps,
CellFailureProps,
CellLoadingProps,
CellSuccessProps,
TypedDocumentNode,
} from '@redwoodjs/web'

Expand All @@ -17,18 +18,22 @@ export const QUERY: TypedDocumentNode<
}
`

export const Loading = () => <div>Loading...</div>
export const Loading: React.FC<
CellLoadingProps<<${operationName}Variables>
> = () => <div>Loading...</div>

export const Empty = () => <div>Empty</div>
export const Empty: React.FC<
CellSuccessProps<${operationName}Variables>
> = () => <div>Empty</div>

export const Failure = ({
error,
}: CellFailureProps<${operationName}Variables>) => (
export const Failure: React.FC<
CellFailureProps<${operationName}Variables>
> = ({ error }) => (
<div style={{ color: 'red' }}>Error: {error?.message}</div>
)

export const Success = ({
${camelName},
}: CellSuccessProps<${operationName}, ${operationName}Variables>) => {
export const Success: React.FC<
CellSuccessProps<${operationName}, ${operationName}Variables>
> = ({ ${camelName} }) => {
return <div>{JSON.stringify(${camelName})}</div>
}

0 comments on commit 76a2c13

Please sign in to comment.