import GraphQLService from './GraphQLService';

export interface FloorPlanArchitectureStyleData{
  id?:number,
  floorplan_id: string,
  archstyle_id: string
}

export interface FloorPlanArchitectureStyleCreateOPData {
  FloorPlanArchitectureStyleCreate?:FloorPlanArchitectureStyleData
}

interface SnapshotData {
  message : string
  result : string
  imp : string
  mismatch : string
  notFound : string
  conflict : string
  success : string
  error : string
  alert : string
  warning : string
  notice : string
  info : string
}
export interface FloorPlanArchitectureStyleDelOPData {
  FloorPlanArchitectureStyleDelete?:{
    snapshot: SnapshotData
    affected : number
  }
}

export interface FloorPlanArchitectureData{
  id? : number
  floorplan_id : string
  roomtype_id : string
  fr_floor_plan ?: {
    id : number
    number : number
    sqft : number
    title : string
  }
  fr_roomtype?: {
    id : number
    title : string
  }
}
export interface FloorArchitecureUpdateOPData {
  FloorPlanArchitectureStyleUpdate?:{
    snapshot: SnapshotData
    affected : number
    affectedRows ?: FloorPlanArchitectureData
  }
}

class FloorPlanArchitectureService extends GraphQLService {
    constructor() {
      super();
    }

    createFloorPlanArchitectureStyle(FloorPlanArchitectureStyleINData: FloorPlanArchitectureStyleData):Promise<FloorPlanArchitectureStyleCreateOPData |null | undefined>{
      const Query =`mutation FloorPlanArchitectureStyleCreate($input: [FloorPlanArchitectureStyleCreateInput!]!) {
                    FloorPlanArchitectureStyleCreate(input: $input) {
                      id
                      floorplan_id
                      archstyle_id
                     }
                  }`
      const variables = {
        input:[{
          "floorplan_id": FloorPlanArchitectureStyleINData.floorplan_id,
          "archstyle_id": FloorPlanArchitectureStyleINData.archstyle_id
        }]
      };
  
      return this.mutate<FloorPlanArchitectureStyleCreateOPData>(Query, variables);             
    }

    deleteFloorPlanArchitectureStyle(Id: number):Promise<FloorPlanArchitectureStyleDelOPData |null | undefined>{
      const Query =`mutation FloorPlanArchitectureStyleDelete($input: FloorPlanArchitectureStyleDeleteInput!) {
                    FloorPlanArchitectureStyleDelete(input: $input) {
                      snapshot {
                        message
                        result
                        imp
                        mismatch
                        notFound
                        conflict
                        success
                        error
                        alert
                        warning
                        notice
                        info
                      }
                      affected
                    }
                  }`;
            const variables = {
              input:{
                "where": [
                  {
                    "floorplan_id": {
                      "equal": `${Id}`
                    }
                  }
                ]
              }
            };
  
      return this.mutate<FloorPlanArchitectureStyleDelOPData>(Query, variables); 
    }

    updateFloorPlanArchitectureStyle(FloorPlanRoomTypeINData: FloorPlanArchitectureData):Promise<FloorArchitecureUpdateOPData |null | undefined>{
      const Query =`mutation FloorPlanArchitectureStyleUpdate($input: FloorPlanArchitectureStyleUpdateInput!) {
                      FloorPlanArchitectureStyleUpdate(input: $input) {
                        snapshot {
                        message
                        result
                        imp
                        mismatch
                        notFound
                        conflict
                        success
                        error
                        alert
                        warning
                        notice
                        info
                      }
                        affected
                        affectedRows {
                          id
                          floorplan_id
                          archstyle_id
                          fr_architecture_style {
                            id
                            title
                            desc
                          }
                          fr_floor_plan {
                            id
                            title
                            short_desc
                          }
                        }
                      }
                    }`;
            const variables = {
              "input": {
                "sets": {
                  "floorplan_id": null,
                  "archstyle_id": null
                },
                "where": [
                  {
                    "id": {
                      "equal": null
                    }
                  }
                ]
              }
            };
  
      return this.mutate<FloorArchitecureUpdateOPData>(Query, variables); 
    }
}

const FloorPlanArchitectureServiceInstance = new FloorPlanArchitectureService();
export default FloorPlanArchitectureServiceInstance;