{"version":3,"sources":["webpack:///./node_modules/@abaco/crop-plan-module/src/modules/crop-plan-module/api/VegCycleApi.ts"],"names":["VarietyApi","http","this","plot_id","paging","block_id","get","params","offset","count","res","propsToDatePaged","data","records","length","pk_cuaa","campaign","crop_code","filter","search","replace","toLowerCase","sort","item_id","push","hasClones","toUpperCase","id","cycle_number","editedVegCycle","put","propsToDate","plotSeedOut","post","delete","pkCuaa","result","seedId"],"mappings":"+PAKqBA,E,WAIjB,WAAYC,GAAgB,uBACxBC,KAAKD,KAAOA,E,4GAGhB,WAAmBE,EAAiBC,EAAsBC,GAA1D,2FAEQA,EAFR,gCAGoBH,KAAKD,KAAKK,IAAV,sDAA6DH,EAA7D,mBAA+EE,EAA/E,sBAA6G,CACrHE,OAAQ,CACJC,OAAQJ,EAAOI,OACfC,MAAOL,EAAOK,SAN9B,OAGQC,EAHR,6CAUoBR,KAAKD,KAAKK,IAAV,sDAA6DH,EAA7D,sBAA0F,CAClGI,OAAQ,CACJC,OAAQJ,EAAOI,OACfC,MAAOL,EAAOK,SAb9B,OAUQC,EAVR,qBAiBIC,eAAiBD,EAAIE,KAAM,CAAC,aAAc,aAjB9C,kBAkBWF,EAAIE,MAlBf,iD,oJAsBA,WAAsBT,EAAiBE,GAAvC,uGACsBH,KAAKD,KAAKK,IAAV,sDAA6DH,EAA7D,mBAA+EE,EAA/E,sBAA6G,CAC3HE,OAAQ,CACJC,OAAQ,EACRC,MAAO,KAJnB,cACUC,EADV,OAOIC,eAAiBD,EAAIE,KAAM,CAAC,aAAc,aAP9C,kBAQWF,EAAIE,KAAKC,QAAQC,OAAS,EAAIJ,EAAIE,KAAKC,QAAQ,GAAK,MAR/D,gD,8IAWA,WAAkBE,EAAiBC,EAAkBC,EAAmBC,EAAuBd,GAA/F,uGACsBF,KAAKD,KAAKK,IAAV,oDAA2DS,EAA3D,YAAsEC,EAAtE,kBAAwFC,EAAxF,qBAAsH,CACpIV,OAAQ,CACJY,OAAM,OAAED,QAAF,IAAEA,OAA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E,MARf,iD,6JAYA,WAA+BM,GAA/B,uGACsBhB,KAAKD,KAAKK,IAAV,iEAAgF,CAC9FC,OAAQ,CACJW,OAAQA,EAAS,mBAAH,OAAsBA,EAAOQ,eAAkB,KAC7DJ,KAAM,cACNd,OAAQ,EACRC,MAAO,OANnB,cACUC,EADV,yBAUWA,EAAIE,KAAKC,SAVpB,gD,8IAaO,WAAoBsB,GAApB,uGACejC,KAAKD,KAAKK,IAAV,+GAAsH6B,IADrI,cACGzB,EADH,yBAEIA,EAAIE,KAAKwB,QAFb,gD,iJAKA,WAAuBD,EAAgBE,GAAvC,uGACenC,KAAKD,KAAKK,IAAV,6DAAoE6B,EAApE,kBAAoFE,IADnG,cACG3B,EADH,yBAEIA,EAAIE,MAFR,gD","file":"js/chunk-2d0cc7bb.e3861d99.js","sourcesContent":["import { PlotSeed, Seed, PlotSeedOut, PlotDictionarySeed, WarehouseSeed } from '../models/Seed';\nimport { PagingParams, PagedResults } from '@abaco/web-common/src/Paging';\nimport { HTTPClient, propsToDate, propsToDatePaged } from '@abaco/web-common/src/HTTP';\nimport { ColtivationSystem } from '../models/Plot';\n\nexport default class VarietyApi {\n\n private http: HTTPClient;\n\n constructor(http: HTTPClient) {\n this.http = http;\n }\n\n async getVegCycles(plot_id: number, paging: PagingParams, block_id?: number): Promise> {\n let res;\n if (block_id) {\n res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/blocks/${block_id}/vegetative_cycles`, {\n params: {\n offset: paging.offset,\n count: paging.count\n }\n });\n } else {\n res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/vegetative_cycles`, {\n params: {\n offset: paging.offset,\n count: paging.count\n }\n });\n }\n propsToDatePaged(res.data, ['start_date', 'end_date'])\n return res.data;\n }\n\n //used for block with planting so only one and only veg cycle\n async getBlockVariety(plot_id: number, block_id: number): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/blocks/${block_id}/vegetative_cycles`, {\n params: {\n offset: 0,\n count: 1\n }\n });\n propsToDatePaged(res.data, ['start_date', 'end_date'])\n return res.data.records.length > 0 ? res.data.records[0] : null;\n }\n\n async getAllSeeds(pk_cuaa: number, campaign: number, crop_code: string, filter: string | null, paging: PagingParams): Promise> {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/land_uses/${pk_cuaa}/${campaign}/crops/${crop_code}/dictionary_seeds`, {\n params: {\n search: filter?.replace(\"[\", \"\").replace(\"]\", \"\").toLowerCase(),\n sort: \"+seed_name\",\n offset: paging.offset,\n count: paging.count\n }\n })\n\n return res.data;\n }\n\n async getAllClonesOfSeed(pk_cuaa: number, campaign: number, crop_code: string, item_id: number, search: string | null, paging: PagingParams): Promise> {\n const filter = [];\n filter.push(`clone_of eq ${item_id}`);\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/land_uses/${pk_cuaa}/${campaign}/crops/${crop_code}/dictionary_seeds`, {\n params: {\n search: search?.replace(\"[\", \"\").replace(\"]\", \"\").toLowerCase(),\n sort: \"+seed_name\",\n offset: paging.offset,\n count: paging.count,\n filter: filter\n }\n })\n\n return res.data;\n }\n\n async getSeeds(plot_id: number, hasClones: boolean, search: string | null, paging: PagingParams): Promise> {\n const filter = [];\n if (!hasClones) {\n filter.push(`clone_of eq`);\n }\n if (search) {\n filter.push(`^full_text_search like ${search.replace(\"[\", \"\").replace(\"]\", \"\").toUpperCase()}`);\n }\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/dictionary_seeds`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n sort: \"+seed_name\",\n filter: filter\n }\n })\n\n return res.data;\n }\n\n async getSeed(plot_id: number, id: number): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/dictionary_seeds`, {\n params: {\n offset: 0,\n count: 1,\n filter: \"seed_id eq \" + id\n }\n })\n return res.data.records[0];\n }\n\n\n async getClonesOfSeed(plot_id: number, item_id: number, search: string | null, paging: PagingParams): Promise> {\n const filter = [];\n filter.push(`clone_of eq ${item_id}`);\n if (search) {\n filter.push(`^full_text_search like ${search.replace(\"[\", \"\").replace(\"]\", \"\").toUpperCase()}`);\n }\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/dictionary_seeds`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n sort: \"+seed_name\",\n filter: filter\n }\n })\n\n return res.data;\n }\n\n async editVegCycle(plot_id: number, cycle_number: number, editedVegCycle: PlotSeedOut, block_id?: number): Promise {\n let res;\n if (block_id) {\n res = await this.http.put(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/blocks/${block_id}/vegetative_cycles/${cycle_number}`, editedVegCycle)\n } else {\n res = await this.http.put(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/vegetative_cycles/${cycle_number}`, editedVegCycle)\n }\n propsToDate(res.data, ['start_date', 'end_date'])\n return res.data;\n }\n\n async insertVegCycle(plot_id: number, plotSeedOut: PlotSeedOut, block_id?: number): Promise {\n let res;\n if (block_id) {\n res = await this.http.post(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/blocks/${block_id}/vegetative_cycles`, plotSeedOut)\n } else {\n res = await this.http.post(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/vegetative_cycles`, plotSeedOut)\n }\n propsToDate(res.data, ['start_date', 'end_date'])\n return res.data;\n }\n\n async deleteVariety(plot_id: number, cycle_number: number, block_id?: number): Promise {\n let res;\n if (block_id) {\n res = await this.http.delete(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/blocks/${block_id}/vegetative_cycles/${cycle_number}`)\n } else {\n res = await this.http.delete(`/sitiagri-rest-api/api_basic/v1/plots/plots/${plot_id}/vegetative_cycles/${cycle_number}`)\n }\n propsToDate(res.data, ['start_date', 'end_date'])\n return res.data\n }\n\n\n async getAllColtivationSystems(filter: string | null): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dictionary_forcing_types`, {\n params: {\n filter: filter ? `ds_forcing like ${filter.toUpperCase()}` : null,\n sort: \"+ds_forcing\",\n offset: 0,\n count: 300\n }\n })\n\n return res.data.records;\n }\n\n public async checkSeedAuth(pkCuaa: number): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/user_registry/module_competencies/BEST_PRACTICE/SEED_EDIT?subject_id=${pkCuaa}`);\n return res.data.result;\n }\n\n public async getWarehouseSeed(pkCuaa: number, seedId: number): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/seeds/${seedId}`);\n return res.data;\n }\n\n}\n"],"sourceRoot":""}