{"version":3,"file":"salesVisitDialogUtils-b510699d.js","sources":["../../src/components/pages/orders/salesvisits/salesVisitDialogUtils.ts"],"sourcesContent":["import Guid from \"@/app/types/common/guid\";\nimport { EnumSalesVisitAssociatedEntityType } from \"@/app/services/generated/enums/enumSalesVisitAssociatedEntityType.generated\";\nimport { showModalDialog } from \"@/components/platform/common/showModalDialog\";\nimport {\n PlannedSalesVisit,\n salesVisitService,\n} from \"@/app/services/generated/salesvisitService\";\nimport CreateOrEditSalesVisitDialog from \"@/components/pages/orders/salesvisits/components/CreateOrEditSalesVisitDialog.vue\";\nimport api from \"@/app/api\";\nimport { tenantService } from \"@/app/services/extensions/tenantServiceExtended\";\nimport userStore from \"@/store/modules/userStore\";\n\nexport async function showCreateSalesVisitDialog(opts: {\n entityType: \"outlet\" | \"lead\" | \"group\";\n entityId?: Guid;\n}) {\n const salesVisit = new PlannedSalesVisit();\n salesVisit.id = Guid.create();\n salesVisit.date = tenantService.today;\n\n if (userStore.state.user) {\n salesVisit.userId = userStore.state.user.id;\n }\n\n if (opts.entityId) {\n salesVisit.associatedEntityId = opts.entityId;\n }\n\n if (opts.entityType === \"outlet\") {\n salesVisit.associatedEntityType = EnumSalesVisitAssociatedEntityType.outlet;\n }\n\n if (opts.entityType === \"lead\") {\n salesVisit.associatedEntityType = EnumSalesVisitAssociatedEntityType.lead;\n }\n\n if (opts.entityType === \"group\") {\n salesVisit.associatedEntityType = EnumSalesVisitAssociatedEntityType.group;\n }\n\n const { value, wasSuccessful } = await showModalDialog<\n PlannedSalesVisit,\n typeof CreateOrEditSalesVisitDialog\n >(CreateOrEditSalesVisitDialog, {\n props: {\n salesVisit,\n },\n });\n\n if (value && wasSuccessful) {\n await salesVisitService.savePlannedSalesVisit(api.tenantId, value);\n }\n\n return { value, wasSuccessful };\n}\n"],"names":[],"mappings":"ocAYA,eAAsB,2BAA2B,KAG9C,CACK,MAAA,WAAa,IAAI,kBACZ,WAAA,GAAK,KAAK,SACrB,WAAW,KAAO,cAAc,MAE5B,UAAU,MAAM,OACP,WAAA,OAAS,UAAU,MAAM,KAAK,IAGvC,KAAK,WACP,WAAW,mBAAqB,KAAK,UAGnC,KAAK,aAAe,WACtB,WAAW,qBAAuB,mCAAmC,QAGnE,KAAK,aAAe,SACtB,WAAW,qBAAuB,mCAAmC,MAGnE,KAAK,aAAe,UACtB,WAAW,qBAAuB,mCAAmC,OAGvE,KAAM,CAAE,MAAO,aAAkB,EAAA,MAAM,gBAGrC,6BAA8B,CAC9B,MAAO,CACL,UACF,CAAA,CACD,EAED,OAAI,OAAS,eACX,MAAM,kBAAkB,sBAAsB,IAAI,SAAU,KAAK,EAG5D,CAAE,MAAO,cAClB,CA1CsB"}