import type {
  AdminFindProjectById,
  AdminFindProjectByIdVariables,
} from 'types/graphql'

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

import CellEmpty from 'src/components/Cell/CellEmpty/CellEmpty'
import CellFailure from 'src/components/Cell/CellFailure/CellFailure'
import CellLoading from 'src/components/Cell/CellLoading/CellLoading'
import Project from 'src/components/Project/AdminProject/AdminProject'

export const QUERY: TypedDocumentNode<
  AdminFindProjectById,
  AdminFindProjectByIdVariables
> = gql`
  query AdminFindProjectById($id: Int!) {
    project: project(id: $id) {
      id
      title
      description
      date
      links
      images
      tags {
        id
        tag
        color
      }
    }
  }
`

export const Loading = () => <CellLoading />
export const Empty = () => <CellEmpty />
export const Failure = ({
  error,
}: CellFailureProps<AdminFindProjectByIdVariables>) => (
  <CellFailure error={error} />
)
export const Success = ({
  project,
}: CellSuccessProps<AdminFindProjectById, AdminFindProjectByIdVariables>) => (
  <Project project={project} />
)
