{"version":3,"file":"usePromotedLookupMethods.mjs","names":["useState","useEffect","apiMutate","useLookupsStore","UdpEnums","ConfigService","usePromotedLookupMethods","apiCatalogId","t0","$","_c","productId","undefined","config","UNITY_PRODUCT_ID","data","setData","loading","setLoading","error","setError","setLookupApiMethodId","_temp","t1","Symbol","for","e","setErrorState","t2","response","setSuccessState","t3","t4","p","integrationV1ApiUrl","Udp_Lookup","then","response_0","baseGetDataUdpLookupMethod","unityBaseGetDataMethod","baseGetUdpLookupMethod","unityBaseGetMethod","apiMethodId","catch","t5","state"],"sources":["../../src/hooks/usePromotedLookupMethods.js"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { apiMutate } from '../utilities/useAxiosMutate';\nimport { useLookupsStore } from '../stores/lookupsStore';\nimport { UdpEnums } from '../enums/unitySystemEnums';\nimport { ConfigService } from '../configService';\n\nexport const usePromotedLookupMethods = (\n  apiCatalogId,\n  productId = ConfigService.config.UNITY_PRODUCT_ID\n) => {\n  const [data, setData] = useState(undefined);\n  const [loading, setLoading] = useState(true);\n  const [error, setError] = useState(undefined);\n  const setLookupApiMethodId = useLookupsStore(\n    (state) => state.setLookupApiMethodId\n  );\n\n  const setErrorState = (e) => {\n    setLoading(false);\n    setError(e);\n  };\n\n  const setSuccessState = (response) => {\n    setError(undefined);\n    setLoading(false);\n    setData(response);\n  };\n\n  useEffect(() => {\n    if (!apiCatalogId) return;\n\n    const p = apiMutate(\n      ConfigService.integrationV1ApiUrl,\n      `apicatalog/${apiCatalogId}/promotedMethodEntities/${UdpEnums.Udp_Lookup}/product/${productId}?compareSanitizedName=true`,\n      {}\n    );\n    p.then((response) => {\n      setSuccessState(response.data);\n      const baseGetDataUdpLookupMethod =\n        response.data['unityBaseGetDataMethod'];\n      const baseGetUdpLookupMethod = response.data['unityBaseGetMethod'];\n      const apiMethodId =\n        baseGetDataUdpLookupMethod?.apiMethodId ||\n        baseGetUdpLookupMethod?.apiMethodId;\n      if (apiMethodId) {\n        setLookupApiMethodId(apiMethodId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