Skip to content
Snippets Groups Projects
challenge.model.ts 1.33 KiB
import { UserChallengeState, UserChallengeSuccess } from 'enums'
import { DateTime } from 'luxon'
import {
  Dataload,
  Relation,
  UserAction,
  UserActionEntity,
  UserDuel,
  UserDuelEntity,
  UserExploration,
  UserQuiz,
} from 'models'

export interface ChallengeState {
  userChallengeList: UserChallenge[]
  currentChallenge: UserChallenge | null
  currentDataload: Dataload[]
}
export interface ChallengeEntity {
  id: string
  title: string
  description: string
  target: number
  relationships: {
    quiz: {
      data: Relation
    }
    duel: {
      data: Relation
    }
    exploration: { data: Relation[] }
  }
}

export interface ChallengeProgress {
  quizProgress: number
  explorationProgress: number
  actionProgress: number
}

export interface UserChallengeEntity {
  id: string
  title: string
  title_line_return?: string
  description: string
  state: UserChallengeState
  target: number
  progress: ChallengeProgress
  duel: UserDuelEntity
  success: UserChallengeSuccess
  startDate: string | null
  endingDate: string | null
  quiz: UserQuiz
  exploration: UserExploration
  action: UserActionEntity
}

export interface UserChallenge
  extends Omit<
    UserChallengeEntity,
    'startDate' | 'endingDate' | 'duel' | 'action'
  > {
  startDate: DateTime | null
  endingDate: DateTime | null
  duel: UserDuel
  action: UserAction
}