{"version":3,"file":"index-CR-Ct9z2.js","sources":["../../../app/assets/javascripts/concepts/listings/problems/reports/new_report/box/index.ts","../../../app/assets/javascripts/concepts/listings/problems/reports/new_report/button/index.ts"],"sourcesContent":["\n// region JS Imports\n\n// region External Modules\nimport $ from \"jquery\"\nimport u from \"umbrellajs\"\nimport serialize from \"form-serialize\"\n\nimport I18n from \"plugins/i18n-js\"\n// endregion External Modules\n\n// Private Modules\nimport Modal from \"app/modal/show-modal\"\nimport Notifier from \"app/notifier/index\"\nimport Auth_action from \"app/authentication/action\"\nimport Auth_remote_state from \"app/authentication/remote_state\"\nimport shortlist from \"app/listings/shortlist\"\n\nimport {\n q_ajax_3,\n} from \"app/utils/q_ajax/q_ajax_3\"\n// Private Modules\n\n// region Public Components\n// endregion Public Components\n\n// region Private Components\n// endregion Private Components\n\n// endregion JS Imports\n\n\nconst CELL_CLASS_NAME = \"cell--listings--problems--reports--new-report--box\"\nconst CELL_INITIALIZED_CLASS_NAME = `${CELL_CLASS_NAME}--js-spacious-initialized`\n\n\n\nconst onSuccess = (data: string) => {\n // # HACK: get embed data attribute for listing_id in returned HTML\n const listing_id = $(data).find(\"[data-listing-id]\").data(\"listing-id\")\n const email = $(data).find(\"[data-email]\").data(\"email\")\n Modal.hideTopModal()\n Modal.showModalWithContent(data)\n Auth_remote_state.refreshAndUpdateComponentPromise()\n .then((signed_in) => {\n // # If signed in, already done in backend\n if (signed_in) { return }\n // # bugged?\n if (listing_id == null) { return }\n // # Try to shortlist the listing with AJAX,\n // # which actually queue the action and show sign up modal\n Auth_action.showSignInModal().done()\n // # Queue the sign up\n shortlist(listing_id, {\n show_auth_modal_on_fail: false,\n })\n })\n}\n\nconst onError = (response: Response) => {\n if (response.status === 422){\n Notifier.showError(I18n.t(\"js.app.notifier.defaults.form_invalid\"))\n Modal.hideTopModal()\n response.text().then((text) => Modal.showModalWithContent(text))\n }\n else{\n Notifier.showError(I18n.t(\"js.app.notifier.defaults.form_submit_failed\"))\n }\n}\n\n\nconst init = () => {\n u(`.${CELL_CLASS_NAME}`).each((el) => {\n const $el = $(el)\n\n if (el.classList.contains(CELL_INITIALIZED_CLASS_NAME)) { return }\n el.classList.add(CELL_INITIALIZED_CLASS_NAME)\n\n const $form = $el.find(\"form\")\n const $problem_type_selector =\n $form.find(\".cell--listings--problems--reports--new_report--box__listing-report-form--problem-type\")\n\n $problem_type_selector.on(\"change\", () => {\n if ($form.find(\".cell--listings--problems--reports--new_report--box__listing-report-form--problem-type:checked\").val() === \"others\"){\n $el.addClass(\"show--message--box\")\n }\n else{\n $el.removeClass(\"show--message--box\")\n }\n })\n\n $form.on(\"submit\", (e) => {\n e.preventDefault()\n const selected_checkboxes = $form.find(\".cell--listings--problems--reports--new_report--box__listing-report-form--problem-type:checked\")\n if (selected_checkboxes.length === 0){\n Notifier.showError(I18n.t(\"js.app.notifier.listings.problems.reports.no_problem_type_selected\"))\n return\n }\n\n q_ajax_3({\n url: $form.attr(\"action\"),\n method: \"POST\",\n data: serialize(($form[0] as HTMLFormElement), {hash: true}),\n })\n .then(({data}) => onSuccess(data))\n .catch(({response}) => onError(response))\n })\n\n })\n}\n\nexport default {init}\n","\n// region JS Imports\n\n// region External Modules\nimport u from \"umbrellajs\"\n// endregion External Modules\n\n// Private Modules\nimport q_ajax_3 from \"app/utils/q_ajax/q_ajax_3\"\nimport Modal from \"app/modal/show-modal\"\nimport Auth_action from \"app/authentication/action\"\n// Private Modules\n\n// region Public Components\n// endregion Public Components\n\n// region Private Components\nimport Problem_Box from \"../box/index\"\n// endregion Private Components\n\n// endregion JS Imports\n\n\nconst CELL_CLASS_NAME = \"cell--listings--problems--reports--new-report--button\"\nconst CELL_INITIALIZED_CLASS_NAME = `${CELL_CLASS_NAME}--js-spacious-initialized`\n\nconst init = () => {\n u(`.${CELL_CLASS_NAME}`).each((el) => {\n const $el = u(el)\n\n if (el.classList.contains(CELL_INITIALIZED_CLASS_NAME)) { return }\n el.classList.add(CELL_INITIALIZED_CLASS_NAME)\n\n const $remote_link_elements = $el.find(\".cell--listings--problems--reports--new-report--button__anchor\")\n\n $remote_link_elements.on(\"click\", (e) => {\n const $link = u(e.currentTarget as HTMLElement)\n const url = $link.attr(\"href\")\n\n q_ajax_3(\n {\n url: url,\n type: \"GET\",\n dataType: \"html\",\n },\n {\n error_tracking_options: {\n endpoint_identifier: \"app/assets/javascripts/concepts/listings/problems/reports/new_report/button/index#init\",\n },\n },\n )\n .then(({data}: {data: string}) => {\n Modal.showModalWithContent(data)\n Problem_Box.init()\n })\n .catch(({response}) => {\n if (response.status === 401) {\n Auth_action.showSignInModal().done()\n }\n })\n\n e.preventDefault()\n })\n\n })\n}\n\nexport default {init}\n"],"names":["CELL_CLASS_NAME","CELL_INITIALIZED_CLASS_NAME","onSuccess","data","listing_id","$","Modal","Auth_remote_state","signed_in","Auth_action","shortlist","onError","response","Notifier","I18n","text","init","u","el","$el","$form","e","q_ajax_3","serialize","Problem_Box","url","Report_btn"],"mappings":"kaAgCA,MAAMA,EAAkB,qDAClBC,EAA8B,GAAGD,OAAAA,EAAe,6BAIhDE,EAAaC,GAAiB,CAE5B,MAAAC,EAAaC,EAAEF,CAAI,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EACxDE,EAAEF,CAAI,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EACvDG,EAAM,aAAa,EACnBA,EAAM,qBAAqBH,CAAI,EAC/BI,EAAkB,iCAAiC,EAClD,KAAMC,GAAc,CAEfA,GAEAJ,GAAc,OAGNK,EAAA,kBAAkB,KAAK,EAEnCC,EAAUN,EAAY,CACpB,wBAAyB,EAAA,CAC1B,EAAA,CACF,CACH,EAEMO,EAAWC,GAAuB,CAClCA,EAAS,SAAW,KACtBC,EAAS,UAAUC,EAAK,EAAE,uCAAuC,CAAC,EAClER,EAAM,aAAa,EACVM,EAAA,OAAO,KAAMG,GAAST,EAAM,qBAAqBS,CAAI,CAAC,GAG/DF,EAAS,UAAUC,EAAK,EAAE,6CAA6C,CAAC,CAE5E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