@servicetitan/onboarding-ui 13.2.0 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/company-profile/stores/company-profile-form.store.js.map +1 -1
- package/dist/contentful/marketing-carousel.store.js.map +1 -1
- package/dist/customer-types/stores/customer-type-form.store.js.map +1 -1
- package/dist/pusher/presence.store.js.map +1 -1
- package/dist/pusher/pusher.store.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/company-profile/stores/company-profile-form.store.ts"],"sourcesContent":["import {\n commitFormState,\n DropdownFieldState,\n InputFieldState,\n setFormStateValues,\n} from '@servicetitan/form';\nimport { injectable } from '@servicetitan/react-ioc';\nimport { FieldState, FormState } from 'formstate';\nimport { action, computed, makeObservable, observable } from 'mobx';\nimport { AddressModel } from '../../address-suggestion-popover';\nimport {\n Country,\n countryToEinBnMaskMap,\n countryToZipMaskMap,\n CountryType,\n getCountry,\n isCountry,\n zipCodeValidator,\n} from '../../utils/country-helpers';\nimport { PhoneValidator } from '../utils/validators';\n\nconst required = (value: string) => (!value || value.length === 0) && 'cannot be empty string';\n\nexport interface DropdownRegion {\n Code: string;\n Name: string;\n}\n\nexport interface CountryWithRegions {\n Country: string;\n Regions: DropdownRegion[];\n}\n\nexport interface ProfileModel {\n companyName?: string | undefined;\n adminPhone?: string | undefined;\n companyStreetAddress?: string | undefined;\n companyCountry?: string | undefined;\n companyStateCode?: string | undefined;\n companyCity?: string | undefined;\n companyZipCode?: string | undefined;\n einOrBn?: string | undefined;\n isCompanyAddressVerified?: boolean;\n companyLogo?: string | undefined;\n}\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\ntype AddressFormType = {\n companyStreetAddress: InputFieldState<string>;\n companyCountry: DropdownFieldState<CountryType | ''>;\n companyStateCode: DropdownFieldState<string>;\n companyCity: InputFieldState<string>;\n companyZipCode: InputFieldState<string>;\n isCompanyAddressVerified: FieldState<boolean>;\n};\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type ICompanyProfileFormType = {\n companyName: InputFieldState<string>;\n adminPhone: InputFieldState<string>;\n einOrBn: InputFieldState<string>;\n address: FormState<AddressFormType>;\n companyLogo: FieldState<string | File | undefined>;\n};\n\nexport interface ICompanyProfileFormStore {\n showFormError: boolean;\n isInitializing: boolean;\n form: FormState<ICompanyProfileFormType>;\n}\n\ninterface CompanyProfileFormOptions {\n phonePattern: RegExp;\n countries: string[];\n countryAndRegionData: CountryWithRegions[];\n phoneMask: string;\n regionToCodeMap: Map<string, string>;\n}\n\n@injectable()\nexport class CompanyProfileFormStore implements ICompanyProfileFormStore {\n @observable showFormError = false;\n @observable isInitializing = false;\n @observable countries: string[] = [];\n @observable countryAndRegionData: CountryWithRegions[] = [];\n @observable phoneMask = '';\n @observable regionToCodeMap: Map<string, string> = new Map();\n @observable withAddressValidation = false;\n\n form: FormState<ICompanyProfileFormType> = new FormState({\n companyName: new InputFieldState('').validators(required),\n adminPhone: new InputFieldState(''),\n einOrBn: new InputFieldState(''),\n address: new FormState({\n companyStreetAddress: new InputFieldState('').validators(required),\n companyCountry: new DropdownFieldState<CountryType | ''>('').validators(required),\n companyStateCode: new DropdownFieldState('').validators(required),\n companyCity: new InputFieldState('').validators(required),\n companyZipCode: new InputFieldState('').validators(required),\n isCompanyAddressVerified: new FieldState(false),\n }).validators($ => {\n if (!this.withAddressValidation) {\n return false;\n }\n\n return (\n !$.isCompanyAddressVerified.value && 'Please validate/confirm your Company Address.'\n );\n }),\n companyLogo: new FieldState<string | File | undefined>(undefined).validators(value => {\n if (value instanceof File) {\n const maxSize = 10 * 1024 * 1024;\n if (value.size > maxSize) {\n return 'File size must be less than 10 MB';\n }\n\n const allowedTypes = ['.jpg', '.jpeg', '.png', '.bmp', '.tif'];\n if (!value.name.includes('.')) {\n return `File must have a valid extension (e.g., ${allowedTypes.join(', ')}).`;\n }\n\n const fileExtension = '.' + value.name.split('.').pop()?.toLowerCase();\n if (!allowedTypes.includes(fileExtension)) {\n return `File must be one of the following formats: ${allowedTypes.map(extension => extension.slice(1)).join(', ')}`;\n }\n }\n return false;\n }),\n });\n\n constructor() {\n makeObservable(this);\n\n this.form.$.address.$.companyZipCode.validators(\n zipCodeValidator(() => this.form.$.address.$.companyCountry.$)\n );\n\n this.form.$.einOrBn.validators(($: string) => {\n const errorMessage = `Invalid ${\n isCountry(this.form.$.address.$.companyCountry.value, Country.Canada) ? 'BN' : 'EIN'\n }`;\n return $ && $.length !== 9 && errorMessage;\n });\n this.addressFields.forEach(({ onDidChange }) => {\n onDidChange(() => this.form.$.address.$.isCompanyAddressVerified.onChange(false));\n });\n }\n\n @action\n setNeedAddressValidation = (value: boolean) => {\n this.withAddressValidation = value;\n };\n\n @action\n setFormErrorCheck = (value: boolean) => {\n this.showFormError = value;\n };\n\n @computed\n get zipCodeMask() {\n return countryToZipMaskMap[this.form.$.address.$.companyCountry.$ || Country.USA];\n }\n\n @computed\n get einOrBnMask() {\n return countryToEinBnMaskMap[this.form.$.address.$.companyCountry.$ || Country.USA];\n }\n\n @computed\n get einOrBnInputProps() {\n return isCountry(this.form.$.address.$.companyCountry.value, Country.Canada)\n ? {\n label: 'BN Number',\n placeholder: 'XXXXXXXXX',\n }\n : {\n label: 'EIN Number',\n placeholder: 'XX-XXXXXXX',\n };\n }\n\n @action\n initForm = (formData: ProfileModel, options: CompanyProfileFormOptions) => {\n this.form.$.adminPhone.validators(PhoneValidator(options.phonePattern, false));\n this.countries = options.countries;\n this.countryAndRegionData = options.countryAndRegionData;\n this.phoneMask = options.phoneMask;\n this.regionToCodeMap = options.regionToCodeMap;\n let companyCountry = getCountry(formData.companyCountry) ?? ('' as const);\n if (companyCountry && this.countries && !this.countries?.includes(companyCountry)) {\n companyCountry = '';\n }\n const companyZipCode =\n (isCountry(companyCountry, Country.USA)\n ? formData.companyZipCode?.slice(0, 5)\n : formData.companyZipCode) ?? '';\n setFormStateValues(this.form, { ...formData });\n setFormStateValues(this.form.$.address, { ...formData, companyCountry, companyZipCode });\n commitFormState(this.form);\n };\n\n @action\n commitForm = () => commitFormState(this.form);\n\n @action\n applyAddressSuggestion = (suggestedAddress: AddressModel) => {\n this.form.$.address.$.isCompanyAddressVerified.onChange(true);\n setFormStateValues(\n this.form.$.address,\n {\n companyStreetAddress: suggestedAddress.street\n ? suggestedAddress.street +\n (suggestedAddress.unit ? ', ' + suggestedAddress.unit : '')\n : '',\n companyCity: suggestedAddress.city,\n companyZipCode: suggestedAddress.zip,\n companyStateCode: suggestedAddress.state,\n companyCountry: getCountry(suggestedAddress.country),\n },\n true\n );\n };\n\n @computed\n get suggestionAddressModel() {\n const form = this.form.$.address;\n return {\n street: form.$.companyStreetAddress.$,\n city: form.$.companyCity.$,\n zip: form.$.companyZipCode.$,\n state: form.$.companyStateCode.$,\n country: form.$.companyCountry.$,\n };\n }\n\n @computed\n private get addressFields() {\n const form = this.form.$.address;\n return [\n form.$.companyStreetAddress,\n form.$.companyCity,\n form.$.companyZipCode,\n form.$.companyStateCode,\n form.$.companyCountry,\n ];\n }\n}\n"],"names":["commitFormState","DropdownFieldState","InputFieldState","setFormStateValues","injectable","FieldState","FormState","action","computed","makeObservable","observable","Country","countryToEinBnMaskMap","countryToZipMaskMap","getCountry","isCountry","zipCodeValidator","PhoneValidator","required","value","length","CompanyProfileFormStore","zipCodeMask","form","$","address","companyCountry","USA","einOrBnMask","einOrBnInputProps","Canada","label","placeholder","suggestionAddressModel","street","companyStreetAddress","city","companyCity","zip","companyZipCode","state","companyStateCode","country","addressFields","constructor","showFormError","isInitializing","countries","countryAndRegionData","phoneMask","regionToCodeMap","Map","withAddressValidation","companyName","validators","adminPhone","einOrBn","isCompanyAddressVerified","companyLogo","undefined","File","maxSize","size","allowedTypes","name","includes","join","fileExtension","split","pop","toLowerCase","map","extension","slice","setNeedAddressValidation","setFormErrorCheck","initForm","formData","options","phonePattern","commitForm","applyAddressSuggestion","suggestedAddress","onChange","unit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pCG,kBAAkByC,iBAAiB1C,KAAK;gBACxCd,gBAAgBZ,WAAWoE,iBAAiBxC,OAAO;YACvD,GACA;QAER;QA1FIjC,eAAe,IAAI;QAEnB,IAAI,CAACc,IAAI,CAACC,CAAC,CAACC,OAAO,CAACD,CAAC,CAACe,cAAc,CAACe,UAAU,CAC3CtC,iBAAiB,IAAM,IAAI,CAACO,IAAI,CAACC,CAAC,CAACC,OAAO,CAACD,CAAC,CAACE,cAAc,CAACF,CAAC;QAGjE,IAAI,CAACD,IAAI,CAACC,CAAC,CAACgC,OAAO,CAACF,UAAU,CAAC,CAAC9B;YAC5B,MAAM6D,eAAe,CAAC,QAAQ,EAC1BtE,UAAU,IAAI,CAACQ,IAAI,CAACC,CAAC,CAACC,OAAO,CAACD,CAAC,CAACE,cAAc,CAACP,KAAK,EAAER,QAAQmB,MAAM,IAAI,OAAO,OACjF;YACF,OAAON,KAAKA,EAAEJ,MAAM,KAAK,KAAKiE;QAClC;QACA,IAAI,CAAC1C,aAAa,CAAC2C,OAAO,CAAC,CAAC,EAAEC,WAAW,EAAE;YACvCA,YAAY,IAAM,IAAI,CAAChE,IAAI,CAACC,CAAC,CAACC,OAAO,CAACD,CAAC,CAACiC,wBAAwB,CAAC0B,QAAQ,CAAC;QAC9E;IACJ;AAoGJ"}
|
|
1
|
+
{"version":3,"sources":["../../../src/company-profile/stores/company-profile-form.store.ts"],"sourcesContent":["import {\n commitFormState,\n DropdownFieldState,\n InputFieldState,\n setFormStateValues,\n} from '@servicetitan/form';\nimport { injectable } from '@servicetitan/react-ioc';\nimport { FieldState, FormState } from 'formstate';\nimport { action, computed, makeObservable, observable } from 'mobx';\nimport { AddressModel } from '../../address-suggestion-popover';\nimport {\n Country,\n countryToEinBnMaskMap,\n countryToZipMaskMap,\n CountryType,\n getCountry,\n isCountry,\n zipCodeValidator,\n} from '../../utils/country-helpers';\nimport { PhoneValidator } from '../utils/validators';\n\nconst required = (value: string) => (!value || value.length === 0) && 'cannot be empty string';\n\nexport interface DropdownRegion {\n Code: string;\n Name: string;\n}\n\nexport interface CountryWithRegions {\n Country: string;\n Regions: DropdownRegion[];\n}\n\nexport interface ProfileModel {\n companyName?: string | undefined;\n adminPhone?: string | undefined;\n companyStreetAddress?: string | undefined;\n companyCountry?: string | undefined;\n companyStateCode?: string | undefined;\n companyCity?: string | undefined;\n companyZipCode?: string | undefined;\n einOrBn?: string | undefined;\n isCompanyAddressVerified?: boolean;\n companyLogo?: string | undefined;\n}\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\ntype AddressFormType = {\n companyStreetAddress: InputFieldState<string>;\n companyCountry: DropdownFieldState<CountryType | ''>;\n companyStateCode: DropdownFieldState<string>;\n companyCity: InputFieldState<string>;\n companyZipCode: InputFieldState<string>;\n isCompanyAddressVerified: FieldState<boolean>;\n};\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type ICompanyProfileFormType = {\n companyName: InputFieldState<string>;\n adminPhone: InputFieldState<string>;\n einOrBn: InputFieldState<string>;\n address: FormState<AddressFormType>;\n companyLogo: FieldState<string | File | undefined>;\n};\n\nexport interface ICompanyProfileFormStore {\n showFormError: boolean;\n isInitializing: boolean;\n form: FormState<ICompanyProfileFormType>;\n}\n\ninterface CompanyProfileFormOptions {\n phonePattern: RegExp;\n countries: string[];\n countryAndRegionData: CountryWithRegions[];\n phoneMask: string;\n regionToCodeMap: Map<string, string>;\n}\n\n@injectable()\nexport class CompanyProfileFormStore implements ICompanyProfileFormStore {\n @observable showFormError = false;\n @observable isInitializing = false;\n @observable countries: string[] = [];\n @observable countryAndRegionData: CountryWithRegions[] = [];\n @observable phoneMask = '';\n @observable regionToCodeMap: Map<string, string> = new Map();\n @observable withAddressValidation = false;\n\n form: FormState<ICompanyProfileFormType> = new FormState({\n companyName: new InputFieldState('').validators(required),\n adminPhone: new InputFieldState(''),\n einOrBn: new InputFieldState(''),\n address: new FormState({\n companyStreetAddress: new InputFieldState('').validators(required),\n companyCountry: new DropdownFieldState<CountryType | ''>('').validators(required),\n companyStateCode: new DropdownFieldState('').validators(required),\n companyCity: new InputFieldState('').validators(required),\n companyZipCode: new InputFieldState('').validators(required),\n isCompanyAddressVerified: new FieldState(false),\n }).validators($ => {\n if (!this.withAddressValidation) {\n return false;\n }\n\n return (\n !$.isCompanyAddressVerified.value && 'Please validate/confirm your Company Address.'\n );\n }),\n companyLogo: new FieldState<string | File | undefined>(undefined).validators(value => {\n if (value instanceof File) {\n const maxSize = 10 * 1024 * 1024;\n if (value.size > maxSize) {\n return 'File size must be less than 10 MB';\n }\n\n const allowedTypes = ['.jpg', '.jpeg', '.png', '.bmp', '.tif'];\n if (!value.name.includes('.')) {\n return `File must have a valid extension (e.g., ${allowedTypes.join(', ')}).`;\n }\n\n const fileExtension = '.' + value.name.split('.').pop()?.toLowerCase();\n if (!allowedTypes.includes(fileExtension)) {\n return `File must be one of the following formats: ${allowedTypes.map(extension => extension.slice(1)).join(', ')}`;\n }\n }\n return false;\n }),\n });\n\n constructor() {\n makeObservable(this);\n\n this.form.$.address.$.companyZipCode.validators(\n zipCodeValidator(() => this.form.$.address.$.companyCountry.$)\n );\n\n this.form.$.einOrBn.validators(($: string) => {\n const errorMessage = `Invalid ${\n isCountry(this.form.$.address.$.companyCountry.value, Country.Canada) ? 'BN' : 'EIN'\n }`;\n return $ && $.length !== 9 && errorMessage;\n });\n this.addressFields.forEach(({ onDidChange }) => {\n onDidChange(() => this.form.$.address.$.isCompanyAddressVerified.onChange(false));\n });\n }\n\n @action\n setNeedAddressValidation = (value: boolean) => {\n this.withAddressValidation = value;\n };\n\n @action\n setFormErrorCheck = (value: boolean) => {\n this.showFormError = value;\n };\n\n @computed\n get zipCodeMask() {\n return countryToZipMaskMap[this.form.$.address.$.companyCountry.$ || Country.USA];\n }\n\n @computed\n get einOrBnMask() {\n return countryToEinBnMaskMap[this.form.$.address.$.companyCountry.$ || Country.USA];\n }\n\n @computed\n get einOrBnInputProps() {\n return isCountry(this.form.$.address.$.companyCountry.value, Country.Canada)\n ? {\n label: 'BN Number',\n placeholder: 'XXXXXXXXX',\n }\n : {\n label: 'EIN Number',\n placeholder: 'XX-XXXXXXX',\n };\n }\n\n @action\n initForm = (formData: ProfileModel, options: CompanyProfileFormOptions) => {\n this.form.$.adminPhone.validators(PhoneValidator(options.phonePattern, false));\n this.countries = options.countries;\n this.countryAndRegionData = options.countryAndRegionData;\n this.phoneMask = options.phoneMask;\n this.regionToCodeMap = options.regionToCodeMap;\n let companyCountry = getCountry(formData.companyCountry) ?? ('' as const);\n if (companyCountry && this.countries && !this.countries?.includes(companyCountry)) {\n companyCountry = '';\n }\n const companyZipCode =\n (isCountry(companyCountry, Country.USA)\n ? formData.companyZipCode?.slice(0, 5)\n : formData.companyZipCode) ?? '';\n setFormStateValues(this.form, { ...formData });\n setFormStateValues(this.form.$.address, { ...formData, companyCountry, companyZipCode });\n commitFormState(this.form);\n };\n\n @action\n commitForm = () => commitFormState(this.form);\n\n @action\n applyAddressSuggestion = (suggestedAddress: AddressModel) => {\n this.form.$.address.$.isCompanyAddressVerified.onChange(true);\n setFormStateValues(\n this.form.$.address,\n {\n companyStreetAddress: suggestedAddress.street\n ? suggestedAddress.street +\n (suggestedAddress.unit ? ', ' + suggestedAddress.unit : '')\n : '',\n companyCity: suggestedAddress.city,\n companyZipCode: suggestedAddress.zip,\n companyStateCode: suggestedAddress.state,\n companyCountry: getCountry(suggestedAddress.country),\n },\n true\n );\n };\n\n @computed\n get suggestionAddressModel() {\n const form = this.form.$.address;\n return {\n street: form.$.companyStreetAddress.$,\n city: form.$.companyCity.$,\n zip: form.$.companyZipCode.$,\n state: form.$.companyStateCode.$,\n country: form.$.companyCountry.$,\n };\n }\n\n @computed\n private get addressFields() {\n const form = this.form.$.address;\n return [\n form.$.companyStreetAddress,\n form.$.companyCity,\n form.$.companyZipCode,\n form.$.companyStateCode,\n form.$.companyCountry,\n ];\n }\n}\n"],"names":["commitFormState","DropdownFieldState","InputFieldState","setFormStateValues","injectable","FieldState","FormState","action","computed","makeObservable","observable","Country","countryToEinBnMaskMap","countryToZipMaskMap","getCountry","isCountry","zipCodeValidator","PhoneValidator","required","value","length","CompanyProfileFormStore","zipCodeMask","form","$","address","companyCountry","USA","einOrBnMask","einOrBnInputProps","Canada","label","placeholder","suggestionAddressModel","street","companyStreetAddress","city","companyCity","zip","companyZipCode","state","companyStateCode","country","addressFields","showFormError","isInitializing","countries","countryAndRegionData","phoneMask","regionToCodeMap","Map","withAddressValidation","companyName","validators","adminPhone","einOrBn","isCompanyAddressVerified","companyLogo","undefined","File","maxSize","size","allowedTypes","name","includes","join","fileExtension","split","pop","toLowerCase","map","extension","slice","setNeedAddressValidation","setFormErrorCheck","initForm","formData","options","phonePattern","commitForm","applyAddressSuggestion","suggestedAddress","onChange","unit","errorMessage","forEach","onDidChange"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SACIA,eAAe,EACfC,kBAAkB,EAClBC,eAAe,EACfC,kBAAkB,QACf,qBAAqB;AAC5B,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,UAAU,EAAEC,SAAS,QAAQ,YAAY;AAClD,SAASC,MAAM,EAAEC,QAAQ,EAAEC,cAAc,EAAEC,UAAU,QAAQ,OAAO;AAEpE,SACIC,OAAO,EACPC,qBAAqB,EACrBC,mBAAmB,EAEnBC,UAAU,EACVC,SAAS,EACTC,gBAAgB,QACb,8BAA8B;AACrC,SAASC,cAAc,QAAQ,sBAAsB;AAErD,MAAMC,WAAW,CAACC,QAAkB,AAAC,CAAA,CAACA,SAASA,MAAMC,MAAM,KAAK,CAAA,KAAM;AA2DtE,OAAO,MAAMC;IA8ET,IACIC,cAAc;QACd,OAAOT,mBAAmB,CAAC,IAAI,CAACU,IAAI,CAACC,CAAC,CAACC,OAAO,CAACD,CAAC,CAACE,cAAc,CAACF,CAAC,IAAIb,QAAQgB,GAAG,CAAC;IACrF;IAEA,IACIC,cAAc;QACd,OAAOhB,qBAAqB,CAAC,IAAI,CAACW,IAAI,CAACC,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wB,CAAC0B,QAAQ,CAAC;QAC9E;IACJ;AAoGJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/contentful/marketing-carousel.store.ts"],"sourcesContent":["import { inject, injectable } from '@servicetitan/react-ioc';\nimport { action, computed, makeObservable, observable, runInAction } from 'mobx';\nimport queryString from 'query-string';\nimport { IContentfulApi, CONTENTFUL_API_TOKEN } from '@servicetitan/contentful-proxy';\nimport { OxPhotoGalleryFields } from './interfaces';\n\nconst carouselBackgroundLightPath =\n 'https://static.servicetitan.com/acm/auth/sign-in-carousel-background.png';\n\nexport enum MarketingCarouselColorTheme {\n Light = 'Light',\n Dark = 'Dark',\n}\n\nexport interface MarketingCarouselFallbackData {\n carouselSettings: {\n colorTheme: MarketingCarouselColorTheme;\n backgroundImageUrl: string;\n };\n carouselData: MarketingCarouselItem[];\n}\n\ninterface MarketingCarouselStoreOptions {\n codeId: string;\n isPreview?: boolean;\n utmSource?: string;\n fallbackData?: MarketingCarouselFallbackData;\n}\n\ninterface MarketingCarouselItem {\n headline: string;\n ctaLink: string;\n ctaLabel: string;\n imageUrl: string;\n description: string;\n}\n\n@injectable()\nexport class MarketingCarouselStore {\n @observable isInitializing = false;\n @observable private photoGalleryData?: OxPhotoGalleryFields;\n @observable private utmSource?: string;\n @observable private fallbackData?: MarketingCarouselFallbackData;\n\n constructor(@inject(CONTENTFUL_API_TOKEN) private contentfulApi: IContentfulApi) {\n makeObservable(this);\n }\n\n @action\n initialize = async ({\n codeId,\n utmSource,\n fallbackData,\n isPreview = false,\n }: MarketingCarouselStoreOptions) => {\n this.isInitializing = true;\n this.utmSource = utmSource;\n this.fallbackData = fallbackData;\n try {\n const data = await this.contentfulApi.getContentfulData<OxPhotoGalleryFields>({\n entryType: 'oxPhotoGallery',\n codeId,\n isPreview: isPreview ?? false,\n });\n if (!data?.items.length) {\n return;\n }\n runInAction(() => {\n this.photoGalleryData = data;\n });\n } finally {\n runInAction(() => {\n this.isInitializing = false;\n });\n }\n };\n\n // colorTheme and backgroundImageUrl are not not part of initial release of contentful\n @computed\n get carouselSettings() {\n return this.photoGalleryData\n ? {\n backgroundImageUrl: carouselBackgroundLightPath,\n colorTheme: MarketingCarouselColorTheme.Light,\n }\n : this.fallbackData?.carouselSettings;\n }\n\n @computed\n get carouselData(): MarketingCarouselItem[] | undefined {\n try {\n if (!this.photoGalleryData?.items) {\n return this.fallbackData?.carouselData;\n }\n return (\n this.photoGalleryData.items\n .filter(({ showDate, hideDate }) => this.isDateRangeActive(showDate, hideDate))\n .map(({ ctaLink, ctaTrackingCode, media, ...fields }) => ({\n ...fields,\n ctaLink: this.getCtaLink(ctaLink, ctaTrackingCode),\n imageUrl: media.file.url.replace('//', 'https://'),\n })) ?? this.fallbackData?.carouselData\n );\n } catch {\n return this.fallbackData?.carouselData;\n }\n }\n\n private getCtaLink = (ctaLink: string, ctaTrackingCode?: string) => {\n if (!ctaTrackingCode) {\n return ctaLink;\n }\n const qs = queryString.parse(ctaTrackingCode);\n if (this.utmSource) {\n qs.utm_source = this.utmSource;\n }\n return `${ctaLink}?${queryString.stringify(qs)}`;\n };\n\n private isDateRangeActive = (start?: string, end?: string) => {\n if (!start && !end) {\n return true;\n }\n const localCurrentTime = new Date().getTime();\n const inStartRange = !start || localCurrentTime >= new Date(start).getTime();\n const inEndRange = !end || localCurrentTime < new Date(end).getTime();\n return inStartRange && inEndRange;\n };\n}\n"],"names":["inject","injectable","action","computed","makeObservable","observable","runInAction","queryString","IContentfulApi","CONTENTFUL_API_TOKEN","OxPhotoGalleryFields","carouselBackgroundLightPath","MarketingCarouselColorTheme","MarketingCarouselStore","carouselSettings","photoGalleryData","backgroundImageUrl","colorTheme","fallbackData","carouselData","items","filter","showDate","hideDate","isDateRangeActive","map","ctaLink","ctaTrackingCode","media","fields","getCtaLink","imageUrl","file","url","replace","
|
|
1
|
+
{"version":3,"sources":["../../src/contentful/marketing-carousel.store.ts"],"sourcesContent":["import { inject, injectable } from '@servicetitan/react-ioc';\nimport { action, computed, makeObservable, observable, runInAction } from 'mobx';\nimport queryString from 'query-string';\nimport { IContentfulApi, CONTENTFUL_API_TOKEN } from '@servicetitan/contentful-proxy';\nimport { OxPhotoGalleryFields } from './interfaces';\n\nconst carouselBackgroundLightPath =\n 'https://static.servicetitan.com/acm/auth/sign-in-carousel-background.png';\n\nexport enum MarketingCarouselColorTheme {\n Light = 'Light',\n Dark = 'Dark',\n}\n\nexport interface MarketingCarouselFallbackData {\n carouselSettings: {\n colorTheme: MarketingCarouselColorTheme;\n backgroundImageUrl: string;\n };\n carouselData: MarketingCarouselItem[];\n}\n\ninterface MarketingCarouselStoreOptions {\n codeId: string;\n isPreview?: boolean;\n utmSource?: string;\n fallbackData?: MarketingCarouselFallbackData;\n}\n\ninterface MarketingCarouselItem {\n headline: string;\n ctaLink: string;\n ctaLabel: string;\n imageUrl: string;\n description: string;\n}\n\n@injectable()\nexport class MarketingCarouselStore {\n @observable isInitializing = false;\n @observable private photoGalleryData?: OxPhotoGalleryFields;\n @observable private utmSource?: string;\n @observable private fallbackData?: MarketingCarouselFallbackData;\n\n constructor(@inject(CONTENTFUL_API_TOKEN) private contentfulApi: IContentfulApi) {\n makeObservable(this);\n }\n\n @action\n initialize = async ({\n codeId,\n utmSource,\n fallbackData,\n isPreview = false,\n }: MarketingCarouselStoreOptions) => {\n this.isInitializing = true;\n this.utmSource = utmSource;\n this.fallbackData = fallbackData;\n try {\n const data = await this.contentfulApi.getContentfulData<OxPhotoGalleryFields>({\n entryType: 'oxPhotoGallery',\n codeId,\n isPreview: isPreview ?? false,\n });\n if (!data?.items.length) {\n return;\n }\n runInAction(() => {\n this.photoGalleryData = data;\n });\n } finally {\n runInAction(() => {\n this.isInitializing = false;\n });\n }\n };\n\n // colorTheme and backgroundImageUrl are not not part of initial release of contentful\n @computed\n get carouselSettings() {\n return this.photoGalleryData\n ? {\n backgroundImageUrl: carouselBackgroundLightPath,\n colorTheme: MarketingCarouselColorTheme.Light,\n }\n : this.fallbackData?.carouselSettings;\n }\n\n @computed\n get carouselData(): MarketingCarouselItem[] | undefined {\n try {\n if (!this.photoGalleryData?.items) {\n return this.fallbackData?.carouselData;\n }\n return (\n this.photoGalleryData.items\n .filter(({ showDate, hideDate }) => this.isDateRangeActive(showDate, hideDate))\n .map(({ ctaLink, ctaTrackingCode, media, ...fields }) => ({\n ...fields,\n ctaLink: this.getCtaLink(ctaLink, ctaTrackingCode),\n imageUrl: media.file.url.replace('//', 'https://'),\n })) ?? this.fallbackData?.carouselData\n );\n } catch {\n return this.fallbackData?.carouselData;\n }\n }\n\n private getCtaLink = (ctaLink: string, ctaTrackingCode?: string) => {\n if (!ctaTrackingCode) {\n return ctaLink;\n }\n const qs = queryString.parse(ctaTrackingCode);\n if (this.utmSource) {\n qs.utm_source = this.utmSource;\n }\n return `${ctaLink}?${queryString.stringify(qs)}`;\n };\n\n private isDateRangeActive = (start?: string, end?: string) => {\n if (!start && !end) {\n return true;\n }\n const localCurrentTime = new Date().getTime();\n const inStartRange = !start || localCurrentTime >= new Date(start).getTime();\n const inEndRange = !end || localCurrentTime < new Date(end).getTime();\n return inStartRange && inEndRange;\n };\n}\n"],"names":["inject","injectable","action","computed","makeObservable","observable","runInAction","queryString","IContentfulApi","CONTENTFUL_API_TOKEN","OxPhotoGalleryFields","carouselBackgroundLightPath","MarketingCarouselColorTheme","MarketingCarouselStore","carouselSettings","photoGalleryData","backgroundImageUrl","colorTheme","fallbackData","carouselData","items","filter","showDate","hideDate","isDateRangeActive","map","ctaLink","ctaTrackingCode","media","fields","getCtaLink","imageUrl","file","url","replace","contentfulApi","isInitializing","utmSource","initialize","codeId","isPreview","data","getContentfulData","entryType","length","qs","parse","utm_source","stringify","start","end","localCurrentTime","Date","getTime","inStartRange","inEndRange"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,MAAM,EAAEC,UAAU,QAAQ,0BAA0B;AAC7D,SAASC,MAAM,EAAEC,QAAQ,EAAEC,cAAc,EAAEC,UAA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AASE,oBAAoB,IAAIC,KAAKH,OAAOI,OAAO;YAC1E,MAAME,aAAa,CAACL,OAAOC,mBAAmB,IAAIC,KAAKF,KAAKG,OAAO;YACnE,OAAOC,gBAAgBC;QAC3B;QAlFInD,eAAe,IAAI;IACvB;AAkFJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/customer-types/stores/customer-type-form.store.ts"],"sourcesContent":["import {\n CheckboxFieldState,\n commitFormState,\n getEnumValues,\n isFormStateChanged,\n} from '@servicetitan/form';\nimport { injectable } from '@servicetitan/react-ioc';\nimport { FormState } from 'formstate';\nimport { action, computed, makeObservable, observable, runInAction } from 'mobx';\nimport { CustomerTypes } from '../utils/customer-types';\n\nexport interface CustomerTypeForm {\n [index: string]: CheckboxFieldState;\n}\n\nexport interface ICustomerTypeFormStore {\n isInitializing: boolean;\n form: FormState<CustomerTypeForm>;\n isFormChanged: boolean;\n initForm: (data?: CustomerTypes[]) => void;\n commitForm: () => void;\n}\n\n@injectable()\nexport class CustomerTypeFormStore implements ICustomerTypeFormStore {\n @observable isInitializing = true;\n @observable form: FormState<CustomerTypeForm> = new FormState({});\n\n constructor() {\n makeObservable(this);\n }\n\n @action\n initForm = (types?: CustomerTypes[]) => {\n this.isInitializing = true;\n runInAction(() => {\n this.form = new FormState<CustomerTypeForm>(\n getEnumValues(CustomerTypes).reduce(\n (acc, customerTypeEnum) => ({\n ...acc,\n [customerTypeEnum]: new CheckboxFieldState(\n !!types?.includes(customerTypeEnum)\n ),\n }),\n {}\n )\n ).validators(\n $ =>\n Object.keys($).every(type => !$[type].$) &&\n 'Please confirm your customer type(s).'\n );\n });\n this.commitForm();\n this.isInitializing = false;\n };\n\n @action\n commitForm = () => {\n commitFormState(this.form);\n };\n\n @computed\n get isFormChanged() {\n return isFormStateChanged(this.form).get();\n }\n}\n"],"names":["CheckboxFieldState","commitFormState","getEnumValues","isFormStateChanged","injectable","FormState","action","computed","makeObservable","observable","runInAction","CustomerTypes","CustomerTypeFormStore","isFormChanged","form","get","
|
|
1
|
+
{"version":3,"sources":["../../../src/customer-types/stores/customer-type-form.store.ts"],"sourcesContent":["import {\n CheckboxFieldState,\n commitFormState,\n getEnumValues,\n isFormStateChanged,\n} from '@servicetitan/form';\nimport { injectable } from '@servicetitan/react-ioc';\nimport { FormState } from 'formstate';\nimport { action, computed, makeObservable, observable, runInAction } from 'mobx';\nimport { CustomerTypes } from '../utils/customer-types';\n\nexport interface CustomerTypeForm {\n [index: string]: CheckboxFieldState;\n}\n\nexport interface ICustomerTypeFormStore {\n isInitializing: boolean;\n form: FormState<CustomerTypeForm>;\n isFormChanged: boolean;\n initForm: (data?: CustomerTypes[]) => void;\n commitForm: () => void;\n}\n\n@injectable()\nexport class CustomerTypeFormStore implements ICustomerTypeFormStore {\n @observable isInitializing = true;\n @observable form: FormState<CustomerTypeForm> = new FormState({});\n\n constructor() {\n makeObservable(this);\n }\n\n @action\n initForm = (types?: CustomerTypes[]) => {\n this.isInitializing = true;\n runInAction(() => {\n this.form = new FormState<CustomerTypeForm>(\n getEnumValues(CustomerTypes).reduce(\n (acc, customerTypeEnum) => ({\n ...acc,\n [customerTypeEnum]: new CheckboxFieldState(\n !!types?.includes(customerTypeEnum)\n ),\n }),\n {}\n )\n ).validators(\n $ =>\n Object.keys($).every(type => !$[type].$) &&\n 'Please confirm your customer type(s).'\n );\n });\n this.commitForm();\n this.isInitializing = false;\n };\n\n @action\n commitForm = () => {\n commitFormState(this.form);\n };\n\n @computed\n get isFormChanged() {\n return isFormStateChanged(this.form).get();\n }\n}\n"],"names":["CheckboxFieldState","commitFormState","getEnumValues","isFormStateChanged","injectable","FormState","action","computed","makeObservable","observable","runInAction","CustomerTypes","CustomerTypeFormStore","isFormChanged","form","get","isInitializing","initForm","types","reduce","acc","customerTypeEnum","includes","validators","$","Object","keys","every","type","commitForm"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SACIA,kBAAkB,EAClBC,eAAe,EACfC,aAAa,EACbC,kBAAkB,QACf,qBAAqB;AAC5B,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,MAAM,EAAEC,QAAQ,EAAEC,cAAc,EAAEC,UAAU,EAAEC,WAAW,QAAQ,OAAO;AACjF,SAASC,aAAa,QAAQ,0BAA0B;AAexD,OAAO,MAAMC;IAqCT,IACIC,gBAAgB;QAChB,OAAOV,mBAAmB,IAAI,CAACW,IAAI,EAAEC,GAAG;IAC5C;IApCA,aAAc;QAHd,uBAAYC,kBAAiB;QAC7B,uBAAYF,QAAoC,IAAIT,UAAU,CAAC;QAM/D,uBACAY,YAAW,CAACC;YACR,IAAI,CAACF,cAAc,GAAG;YACtBN,YAAY;gBACR,IAAI,CAACI,IAAI,GAAG,IAAIT,UACZH,cAAcS,eAAeQ,MAAM,CAC/B,CAACC,KAAKC,mBAAsB,CAAA;wBACxB,GAAGD,GAAG;wBACN,CAACC,iBAAiB,EAAE,IAAIrB,mBACpB,CAAC,EAACkB,kBAAAA,4BAAAA,MAAOI,QAAQ,CAACD;oBAE1B,CAAA,GACA,CAAC,IAEPE,UAAU,CACRC,CAAAA,IACIC,OAAOC,IAAI,CAACF,GAAGG,KAAK,CAACC,CAAAA,OAAQ,CAACJ,CAAC,CAACI,KAAK,CAACJ,CAAC,KACvC;YAEZ;YACA,IAAI,CAACK,UAAU;YACf,IAAI,CAACb,cAAc,GAAG;QAC1B;QAEA,uBACAa,cAAa;YACT5B,gBAAgB,IAAI,CAACa,IAAI;QAC7B;QA9BIN,eAAe,IAAI;IACvB;AAmCJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pusher/presence.store.ts"],"sourcesContent":["import { inject, injectable } from '@servicetitan/react-ioc';\nimport { action, computed, makeObservable, observable } from 'mobx';\nimport { PresenceChannel } from 'pusher-js';\nimport { sortBy } from '../utils';\nimport { PusherStore } from './pusher.store';\n\ninterface MemberInfo {\n EnteredDate: number;\n Name: string;\n IsFromAdmin: boolean;\n}\ninterface Member {\n id: string;\n info: MemberInfo;\n}\n\n@injectable()\nexport class PresenceStore {\n @observable private instance?: PresenceChannel;\n\n constructor(@inject(PusherStore) private pusherStore: PusherStore) {\n makeObservable(this);\n }\n\n @action\n initialize = async (channelName: string) => {\n const presenceChannelName = this.pusherStore.combinePresenceChannelName(channelName);\n this.instance = this.pusherStore.pusher.subscribe(presenceChannelName) as PresenceChannel;\n return new Promise<void>((resolve, reject) => {\n this.channel.bind('pusher:subscription_succeeded', resolve);\n this.channel.bind('pusher:subscription_error', reject);\n });\n };\n\n @action\n dispose = () => {\n this.pusherStore.pusher.unsubscribe(this.channel.name);\n this.instance = undefined;\n };\n\n @computed\n get first() {\n return this.users[0];\n }\n\n @computed\n get amIFirst() {\n return this.first?.id === this.me?.id;\n }\n\n @computed\n private get channel() {\n if (!this.instance) {\n throw new Error('Presence channel is not initialized');\n }\n return this.instance;\n }\n\n @computed\n get allMembers() {\n const result: Member[] = [];\n for (const id in this.channel.members.members) {\n result.push(this.channel.members.get(id));\n }\n return result;\n }\n\n @computed\n get users() {\n return this.allMembers\n .filter(({ info: { IsFromAdmin } }) => !IsFromAdmin)\n .sort(sortBy(member => member.info.EnteredDate));\n }\n\n @computed\n private get me() {\n return this.channel.members.me as Member;\n }\n\n @computed\n get lastUser() {\n return this.users[this.users.length - 1]?.info?.Name ?? '-';\n }\n}\n"],"names":["inject","injectable","action","computed","makeObservable","observable","PresenceChannel","sortBy","PusherStore","PresenceStore","first","users","amIFirst","id","me","channel","instance","Error","allMembers","result","members","push","get","filter","info","IsFromAdmin","sort","member","EnteredDate","lastUser","length","Name","
|
|
1
|
+
{"version":3,"sources":["../../src/pusher/presence.store.ts"],"sourcesContent":["import { inject, injectable } from '@servicetitan/react-ioc';\nimport { action, computed, makeObservable, observable } from 'mobx';\nimport { PresenceChannel } from 'pusher-js';\nimport { sortBy } from '../utils';\nimport { PusherStore } from './pusher.store';\n\ninterface MemberInfo {\n EnteredDate: number;\n Name: string;\n IsFromAdmin: boolean;\n}\ninterface Member {\n id: string;\n info: MemberInfo;\n}\n\n@injectable()\nexport class PresenceStore {\n @observable private instance?: PresenceChannel;\n\n constructor(@inject(PusherStore) private pusherStore: PusherStore) {\n makeObservable(this);\n }\n\n @action\n initialize = async (channelName: string) => {\n const presenceChannelName = this.pusherStore.combinePresenceChannelName(channelName);\n this.instance = this.pusherStore.pusher.subscribe(presenceChannelName) as PresenceChannel;\n return new Promise<void>((resolve, reject) => {\n this.channel.bind('pusher:subscription_succeeded', resolve);\n this.channel.bind('pusher:subscription_error', reject);\n });\n };\n\n @action\n dispose = () => {\n this.pusherStore.pusher.unsubscribe(this.channel.name);\n this.instance = undefined;\n };\n\n @computed\n get first() {\n return this.users[0];\n }\n\n @computed\n get amIFirst() {\n return this.first?.id === this.me?.id;\n }\n\n @computed\n private get channel() {\n if (!this.instance) {\n throw new Error('Presence channel is not initialized');\n }\n return this.instance;\n }\n\n @computed\n get allMembers() {\n const result: Member[] = [];\n for (const id in this.channel.members.members) {\n result.push(this.channel.members.get(id));\n }\n return result;\n }\n\n @computed\n get users() {\n return this.allMembers\n .filter(({ info: { IsFromAdmin } }) => !IsFromAdmin)\n .sort(sortBy(member => member.info.EnteredDate));\n }\n\n @computed\n private get me() {\n return this.channel.members.me as Member;\n }\n\n @computed\n get lastUser() {\n return this.users[this.users.length - 1]?.info?.Name ?? '-';\n }\n}\n"],"names":["inject","injectable","action","computed","makeObservable","observable","PresenceChannel","sortBy","PusherStore","PresenceStore","first","users","amIFirst","id","me","channel","instance","Error","allMembers","result","members","push","get","filter","info","IsFromAdmin","sort","member","EnteredDate","lastUser","length","Name","pusherStore","initialize","dispose","channelName","presenceChannelName","combinePresenceChannelName","pusher","subscribe","Promise","resolve","reject","bind","unsubscribe","name","undefined"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,MAAM,EAAEC,UAAU,QAAQ,0BAA0B;AAC7D,SAASC,MAAM,EAAEC,QAA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AAiD;IAC5D;IA9DA,YAAY,AAA6BC,WAAwB,CAAE;;QAFnE,uBAAoBhB,YAApB,KAAA;QAMA,uBACAiB,cADA,KAAA;QAUA,uBACAC,WADA,KAAA;aAdyCF,cAAAA;aAKzCC,aAAa,OAAOE;YAChB,MAAMC,sBAAsB,IAAI,CAACJ,WAAW,CAACK,0BAA0B,CAACF;YACxE,IAAI,CAACnB,QAAQ,GAAG,IAAI,CAACgB,WAAW,CAACM,MAAM,CAACC,SAAS,CAACH;YAClD,OAAO,IAAII,QAAc,CAACC,SAASC;gBAC/B,IAAI,CAAC3B,OAAO,CAAC4B,IAAI,CAAC,iCAAiCF;gBACnD,IAAI,CAAC1B,OAAO,CAAC4B,IAAI,CAAC,6BAA6BD;YACnD;QACJ;aAGAR,UAAU;YACN,IAAI,CAACF,WAAW,CAACM,MAAM,CAACM,WAAW,CAAC,IAAI,CAAC7B,OAAO,CAAC8B,IAAI;YACrD,IAAI,CAAC7B,QAAQ,GAAG8B;QACpB;QAjBI1C,eAAe,IAAI;IACvB;AA6DJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pusher/pusher.store.ts"],"sourcesContent":["import { injectable } from '@servicetitan/react-ioc';\nimport { action, computed, makeObservable, observable } from 'mobx';\nimport Pusher, { Channel } from 'pusher-js';\n\nexport interface PusherConfig {\n authEndpoint: string;\n tenantId: string;\n pusherNamespace: string;\n globalPusherChannelName?: string;\n appKey?: string;\n}\nconst APP_KEY = '59831c16dcf080351f5b';\n\n@injectable()\nexport class PusherStore {\n @observable private instance?: Pusher;\n @observable private config?: PusherConfig;\n\n constructor() {\n makeObservable(this);\n }\n\n @action\n initialize = (config: PusherConfig) => {\n this.instance = new Pusher(config.appKey ?? APP_KEY, {\n authEndpoint: config.authEndpoint,\n cluster: 'mt1',\n });\n this.config = config;\n this.pusher.subscribe(this.combineChannelName('global'));\n };\n\n @action\n findChannel = (channelName: string): Channel | undefined => {\n return this.pusher.channels.find(this.combineChannelName(channelName));\n };\n\n @action\n combineChannelName = (channelName: string) =>\n `private-${this.combineChannelSuffix(channelName)}`;\n\n @action\n combinePresenceChannelName = (channelName: string) =>\n `presence-${this.combineChannelSuffix(channelName)}`;\n\n @action\n dispose = () => {\n this.instance?.disconnect();\n this.instance = undefined;\n };\n\n private combineChannelSuffix = (channelName: string) =>\n `${this.config?.pusherNamespace}-${channelName}-${this.config?.tenantId}`;\n\n @computed\n get pusher() {\n if (!this.instance) {\n throw new Error('Pusher instance is not initialized');\n }\n return this.instance;\n }\n}\n"],"names":["injectable","action","computed","makeObservable","observable","Pusher","APP_KEY","PusherStore","pusher","instance","Error","
|
|
1
|
+
{"version":3,"sources":["../../src/pusher/pusher.store.ts"],"sourcesContent":["import { injectable } from '@servicetitan/react-ioc';\nimport { action, computed, makeObservable, observable } from 'mobx';\nimport Pusher, { Channel } from 'pusher-js';\n\nexport interface PusherConfig {\n authEndpoint: string;\n tenantId: string;\n pusherNamespace: string;\n globalPusherChannelName?: string;\n appKey?: string;\n}\nconst APP_KEY = '59831c16dcf080351f5b';\n\n@injectable()\nexport class PusherStore {\n @observable private instance?: Pusher;\n @observable private config?: PusherConfig;\n\n constructor() {\n makeObservable(this);\n }\n\n @action\n initialize = (config: PusherConfig) => {\n this.instance = new Pusher(config.appKey ?? APP_KEY, {\n authEndpoint: config.authEndpoint,\n cluster: 'mt1',\n });\n this.config = config;\n this.pusher.subscribe(this.combineChannelName('global'));\n };\n\n @action\n findChannel = (channelName: string): Channel | undefined => {\n return this.pusher.channels.find(this.combineChannelName(channelName));\n };\n\n @action\n combineChannelName = (channelName: string) =>\n `private-${this.combineChannelSuffix(channelName)}`;\n\n @action\n combinePresenceChannelName = (channelName: string) =>\n `presence-${this.combineChannelSuffix(channelName)}`;\n\n @action\n dispose = () => {\n this.instance?.disconnect();\n this.instance = undefined;\n };\n\n private combineChannelSuffix = (channelName: string) =>\n `${this.config?.pusherNamespace}-${channelName}-${this.config?.tenantId}`;\n\n @computed\n get pusher() {\n if (!this.instance) {\n throw new Error('Pusher instance is not initialized');\n }\n return this.instance;\n }\n}\n"],"names":["injectable","action","computed","makeObservable","observable","Pusher","APP_KEY","PusherStore","pusher","instance","Error","config","initialize","appKey","authEndpoint","cluster","subscribe","combineChannelName","findChannel","channelName","channels","find","combineChannelSuffix","combinePresenceChannelName","dispose","disconnect","undefined","pusherNamespace","tenantId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,UAAU,QAAQ,0BAA0B;AACrD,SAASC,MAAM,EAAEC,QAAQ,EAAEC,cAAc,EAAEC,UAAU,QAAQ,OAAO;AACpE,OAAOC,YAAyB,YAAY;AAS5C,MAAMC,UAAU;AAGhB,OAAO,MAAMC;IAwCT,IACIC,SAAS;QACT,IAAI,CAAC,IAAI,CAACC,QAAQ,EAAE;YAChB,MAAM,IAAIC,MAAM;QACpB;QACA,OAAO,IAAI,CAACD,QAAQ;IACxB;IA1CA,aAAc;QAHd,uBAAoBA,YAApB,KAAA;QACA,uBAAoBE,UAApB,KAAA;QAMA,uBACAC,cAAa,CAACD;gBACiBA;YAA3B,IAAI,CAACF,QAAQ,GAAG,IAAIJ,OAAOM,CAAAA,iBAAAA,OAAOE,MAAM,cAAbF,4BAAAA,iBAAiBL,SAAS;gBACjDQ,cAAcH,OAAOG,YAAY;gBACjCC,SAAS;YACb;YACA,IAAI,CAACJ,MAAM,GAAGA;YACd,IAAI,CAACH,MAAM,CAACQ,SAAS,CAAC,IAAI,CAACC,kBAAkB,CAAC;QAClD;QAEA,uBACAC,eAAc,CAACC;YACX,OAAO,IAAI,CAACX,MAAM,CAACY,QAAQ,CAACC,IAAI,CAAC,IAAI,CAACJ,kBAAkB,CAACE;QAC7D;QAEA,uBACAF,sBAAqB,CAACE,cAClB,CAAC,QAAQ,EAAE,IAAI,CAACG,oBAAoB,CAACH,cAAc;QAEvD,uBACAI,8BAA6B,CAACJ,cAC1B,CAAC,SAAS,EAAE,IAAI,CAACG,oBAAoB,CAACH,cAAc;QAExD,uBACAK,WAAU;gBACN;aAAA,iBAAA,IAAI,CAACf,QAAQ,cAAb,qCAAA,eAAegB,UAAU;YACzB,IAAI,CAAChB,QAAQ,GAAGiB;QACpB;QAEA,uBAAQJ,wBAAuB,CAACH;gBACzB,cAA+C;mBAAlD,IAAG,eAAA,IAAI,CAACR,MAAM,cAAX,mCAAA,aAAagB,eAAe,CAAC,CAAC,EAAER,YAAY,CAAC,GAAE,gBAAA,IAAI,CAACR,MAAM,cAAX,oCAAA,cAAaiB,QAAQ,EAAE;;QAjCzEzB,eAAe,IAAI;IACvB;AAyCJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/onboarding-ui",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.3.0",
|
|
4
4
|
"description": "Shared components between servicetitan monolith and Onboarding",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"resumablejs": "~1.0.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@servicetitan/confirm": "^32.
|
|
34
|
-
"@servicetitan/culture": "^32.
|
|
35
|
-
"@servicetitan/data-query": "^32.
|
|
33
|
+
"@servicetitan/confirm": "^32.4.0",
|
|
34
|
+
"@servicetitan/culture": "^32.4.0",
|
|
35
|
+
"@servicetitan/data-query": "^32.4.0",
|
|
36
36
|
"@servicetitan/design-system": "~14.5.1",
|
|
37
|
-
"@servicetitan/form": "^32.
|
|
38
|
-
"@servicetitan/react-ioc": "^31.
|
|
37
|
+
"@servicetitan/form": "^32.4.0",
|
|
38
|
+
"@servicetitan/react-ioc": "^31.6.0",
|
|
39
39
|
"@types/contentful-resolve-response": "^0.1.31",
|
|
40
40
|
"@types/react": "~18.2.55",
|
|
41
41
|
"@types/react-input-mask": "~2.0.5",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@contentful/rich-text-react-renderer": "^15.6.2",
|
|
51
51
|
"@contentful/rich-text-types": "^15.7.0",
|
|
52
52
|
"@servicetitan/contentful-proxy": "^1.1.11",
|
|
53
|
-
"@servicetitan/react-hooks": "^5.0
|
|
53
|
+
"@servicetitan/react-hooks": "^5.1.0",
|
|
54
54
|
"@types/google.maps": "^3.45.6",
|
|
55
55
|
"classnames": "^2.3.1",
|
|
56
56
|
"contentful-resolve-response": "^1.3.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"less": true,
|
|
70
70
|
"webpack": false
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "3dab3310534a39aaacb0069e1d377579fe0a7fab"
|
|
73
73
|
}
|