import {
    Address,
    Scope,
    Center,
    Civility,
    DateTime,
    User,
    WorkflowAvailable,
    Job,
    PrivateCommentEmbeddable,
} from "ChillMainAssets/types";
import { StoredObject } from "ChillDocStoreAssets/types";
import { Thirdparty } from "../../../ChillThirdPartyBundle/Resources/public/types";
import { Calendar } from "../../../ChillCalendarBundle/Resources/public/types";

export interface Person {
    id: number;
    type: "person";
    text: string;
    textAge: string;
    firstName: string;
    lastName: string;
    current_household_address: Address | null;
    birthdate: DateTime | null;
    deathdate: DateTime | null;
    age: number;
    phonenumber: string;
    mobilenumber: string;
    email: string;
    gender: "woman" | "man" | "other";
    centers: Center[];
    civility: Civility | null;
    current_household_id: number;
    current_residential_addresses: Address[];
}

export interface AccompanyingPeriod {
    id: number;
    addressLocation?: Address | null;
    administrativeLocation?: Location | null;
    calendars: Calendar[];
    closingDate?: Date | null;
    closingMotive?: ClosingMotive | null;
    comments: Comment[];
    confidential: boolean;
    createdAt?: Date | null;
    createdBy?: User | null;
    emergency: boolean;
    intensity?: "occasional" | "regular";
    job?: Job | null;
    locationHistories: AccompanyingPeriodLocationHistory[];
    openingDate?: Date | null;
    origin?: Origin | null;
    participations: AccompanyingPeriodParticipation[];
    personLocation?: Person | null;
    pinnedComment?: Comment | null;
    preventUserIsChangedNotification: boolean;
    remark: string;
    requestorAnonymous: boolean;
    requestorPerson?: Person | null;
    requestorThirdParty?: Thirdparty | null;
    resources: AccompanyingPeriodResource[];
    scopes: Scope[];
    socialIssues: SocialIssue[];
    step?:
        | "CLOSED"
        | "CONFIRMED"
        | "CONFIRMED_INACTIVE_SHORT"
        | "CONFIRMED_INACTIVE_LONG"
        | "DRAFT";
}

export interface AccompanyingPeriodWorkEvaluationDocument {
    id: number;
    type: "accompanying_period_work_evaluation_document";
    storedObject: StoredObject;
    title: string;
    createdAt: DateTime | null;
    createdBy: User | null;
    updatedAt: DateTime | null;
    updatedBy: User | null;
    workflows_availables: WorkflowAvailable[];
    workflows: object[];
}

export interface AccompanyingPeriodWork {
    id?: number;
    accompanyingPeriod?: AccompanyingPeriod;
    accompanyingPeriodWorkEvaluations: AccompanyingPeriodWorkEvaluation[];
    createdAt?: string;
    createdAutomatically: boolean;
    createdAutomaticallyReason: string;
    createdBy: User;
    endDate?: string;
    goals: AccompanyingPeriodWorkGoal[];
    handlingThierParty?: Thirdparty;
    note: string;
    persons: Person[];
    privateComment: PrivateCommentEmbeddable;
    referrersHistory: AccompanyingPeriodWorkReferrerHistory[];
    results: Result[];
    socialAction?: SocialAction;
    startDate?: string;
    thirdParties: Thirdparty[];
    updatedAt?: string;
    updatedBy: User;
    version: number;
}

interface SocialAction {
    id: number;
    parent?: SocialAction | null;
    children: SocialAction[];
    issue?: SocialIssue | null;
    ordering: number;
    title: {
        fr: string;
    };
    defaultNotificationDelay?: string | null;
    desactivationDate?: string | null;
    evaluations: Evaluation[];
    goals: Goal[];
    results: Result[];
}

export interface AccompanyingPeriodResource {
    id: number;
    accompanyingPeriod: AccompanyingPeriod;
    comment?: string | null;
    person?: Person | null;
    thirdParty?: Thirdparty | null;
}

export interface Origin {
    id: number;
    label: {
        fr: string;
    };
    noActiveAfter: DateTime;
}

export interface ClosingMotive {
    id: number;
    active: boolean;
    name: {
        fr: string;
    };
    ordering: number;
    isCanceledAccompanyingPeriod: boolean;
    parent?: ClosingMotive | null;
    children: ClosingMotive[];
}

export interface AccompanyingPeriodParticipation {
    id: number;
    startDate: DateTime;
    endDate?: DateTime | null;
    accompanyingPeriod: AccompanyingPeriod;
    person: Person;
}

export interface AccompanyingPeriodLocationHistory {
    id: number;
    startDate: DateTime;
    endDate?: DateTime | null;
    addressLocation?: Address | null;
    period: AccompanyingPeriod;
    personLocation?: Person | null;
}

export interface SocialIssue {
    id: number;
    parent?: SocialIssue | null;
    children: SocialIssue[];
    socialActions?: SocialAction[] | null;
    ordering: number;
    title: {
        fr: string;
    };
    desactivationDate?: string | null;
}

export interface Goal {
    id: number;
    results: Result[];
    socialActions?: SocialAction[] | null;
    title: {
        fr: string;
    };
}

export interface Result {
    id: number;
    accompanyingPeriodWorks: AccompanyingPeriodWork[];
    accompanyingPeriodWorkGoals: AccompanyingPeriodWorkGoal[];
    goals: Goal[];
    socialActions: SocialAction[];
    title: {
        fr: string;
    };
    desactivationDate?: string | null;
}

export interface AccompanyingPeriodWorkGoal {
    id: number;
    accompanyingPeriodWork: AccompanyingPeriodWork;
    goal: Goal;
    note: string;
    results: Result[];
}

export interface AccompanyingPeriodWorkEvaluation {
    accompanyingPeriodWork: AccompanyingPeriodWork | null;
    comment: string;
    createdAt: DateTime | null;
    createdBy: User | null;
    documents: AccompanyingPeriodWorkEvaluationDocument[];
    endDate: DateTime | null;
    evaluation: Evaluation | null;
    id: number | null;
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    key: any;
    maxDate: DateTime | null;
    startDate: DateTime | null;
    updatedAt: DateTime | null;
    updatedBy: User | null;
    warningInterval: string | null;
    timeSpent: number | null;
}

export interface Evaluation {
    id: number;
    url: string;
    socialActions: SocialAction[];
    title: {
        fr: string;
    };
    active: boolean;
    delay: string;
    notificationDelay: string;
}

export interface AccompanyingPeriodWorkReferrerHistory {
    id: number;
    accompanyingPeriodWork: AccompanyingPeriodWork;
    user: User;
    startDate: DateTime;
    endDate: DateTime | null;
    createdAt: DateTime;
    updatedAt: DateTime | null;
    createdBy: User;
    updatedBy: User | null;
}
