import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
import { ScalarObject } from '@things-factory/shell'

import { Notification, NotificationStatus } from './notification'

@InputType()
export class NewNotification {
  @Field({ nullable: true })
  ownerId?: string

  @Field({ nullable: true })
  type?: string

  @Field({ nullable: true })
  subject?: string

  @Field({ nullable: true })
  title?: string

  @Field({ nullable: true })
  body?: string

  @Field({ nullable: true })
  url?: string

  @Field({ nullable: true })
  image?: string

  @Field(type => ScalarObject, { nullable: true })
  property?: any

  @Field({ nullable: true })
  timestamp?: Date
}

@InputType()
export class NotificationPatch {
  @Field(type => ID, { nullable: true })
  id?: string

  @Field(type => NotificationStatus, { nullable: true })
  state?: NotificationStatus

  @Field({ nullable: true })
  cuFlag?: string
}

@ObjectType()
export class NotificationList {
  @Field(type => [Notification])
  items: Notification[]

  @Field(type => Int)
  total: number
}
