{"version":3,"file":"shortlist-otnooKCU.js","sources":["../../../app/assets/javascripts/app/listings/shortlist.ts"],"sourcesContent":["\nimport q_ajax_3 from \"app/utils/q_ajax/q_ajax_3\"\nimport {showSignUpModal} from \"app/authentication/action\"\nimport Auth_callback_queue from \"app/authentication/callback_queue\"\n\n\nimport I18n from \"plugins/i18n-js\"\n\n\ninterface InputOptions {\n show_auth_modal_on_fail?: boolean,\n}\ninterface Options {\n show_auth_modal_on_fail: boolean,\n}\nconst DEFAULT_OPTIONS: Options = {\n show_auth_modal_on_fail: true,\n}\n\n/*\n# Shortlist the listing if authenticated\n# If failed (not authenticated), queue it\n#\n# @param show_auth_modal_on_fail\n# if false, won't show modal after fail (not auth)\n*/\nconst shortlist = (listing_id: string, options?: InputOptions) => {\n const opts: Options = Object.assign({}, DEFAULT_OPTIONS, options)\n\n q_ajax_3(\n {\n url: `/${I18n.locale}/listings/${listing_id}/shortlist`,\n type: \"POST\",\n },\n {\n error_tracking_options: {\n endpoint_identifier: \"app/assets/javascripts/app/listings/shortlist#shortlist\",\n },\n },\n )\n .catch(({response}) => {\n if (response.status === 401){\n Auth_callback_queue.add(() => {\n shortlist(listing_id)\n }, `app/listings/${listing_id}/shortlist`)\n\n if (opts.show_auth_modal_on_fail) {\n showSignUpModal()\n }\n }\n })\n}\n\nexport default shortlist\n"],"names":["DEFAULT_OPTIONS","shortlist","listing_id","options","opts","q_ajax_3","I18n","response","Auth_callback_queue","showSignUpModal"],"mappings":"yLAeA,MAAMA,EAA2B,CAC/B,wBAAyB,EAC3B,EASMC,EAAY,CAACC,EAAoBC,IAA2B,CAChE,MAAMC,EAAgB,OAAO,OAAO,CAAA,EAAIJ,EAAiBG,CAAO,EAEhEE,EACE,CACE,IAAO,IAAI,OAAAC,EAAK,OAAM,cAAa,OAAAJ,EAAU,cAC7C,KAAO,MACT,EACA,CACE,uBAAwB,CACtB,oBAAqB,yDAAA,CACvB,CACF,EAED,MAAM,CAAC,CAAC,SAAAK,KAAc,CACjBA,EAAS,SAAW,MACtBC,EAAoB,IAAI,IAAM,CAC5BP,EAAUC,CAAU,CACtB,EAAG,gBAAgB,OAAAA,EAAU,aAAY,EAErCE,EAAK,yBACSK,EAAA,EAEpB,CACD,CACH"}