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_ajax_3","http_status_code","AJAX_ERROR_HANDLER_ACTIONS","data","reason_or_error","response","create","user_authentication_handle","building_id","__vitePreload","Routes","I18n","destroy","RejectionReasons","SOURCE_FILE_PATH","DEFAULT_SELECTOR","ShortlistButton","EventEmitter","inputs","u_container_el","u","$shortlist_button","$unshortlist_button","e","local_contact_info_data","getContactInfoData","isPresentString","Auth_callback_queue","getLastContactInfoSyncPromise","Auth_action","$modal","authentication_box","email_address","setContactInfoData","create_building_user_shortlisting_inputs","isSignedIn","create_user","result_type","CreateUserResultTypes","trackSignUp","refreshAndUpdateComponentPromise","captureMessage","create_building_user_shortlisting","CreateBuildingUserShortlistingResultTypes","whatever","captureException","destroy_building_user_shortlisting","DestroyBuildingUserShortlistingResultTypes","Factory","selector","CELL_CLASS_NAME","CELL_INITIALIZED_CLASS_NAME","initAllMatchingElements","get_current_authenticated_user_buildings_shortlisted","GetCurrentAuthenticatedUserBuildingsShortlistedTypes","buildings","el","b"],"ignoreList":[],"sources":["../../../app/assets/javascripts/app/resources/current_authenticated_user/buildings_shortlisted/get_many/index.ts","../../../app/assets/javascripts/app/resources/building_user_shortlistings/create/index.ts","../../../app/assets/javascripts/app/resources/building_user_shortlistings/destroy/index.ts","../../../app/assets/javascripts/apps/spacious_website/components/buildings/shortlist_button/icon_only/factory.ts","../../../app/assets/javascripts/apps/spacious_website/components/buildings/shortlist_button/icon_only/index.ts"],"sourcesContent":["\n// region JS Imports\n\n// region External Modules\nimport Promise from \"bluebird\"\n// endregion External Modules\n\n// region Private Modules\nimport {\n q_ajax_3,\n ERROR_HANDLER_ACTIONS as AJAX_ERROR_HANDLER_ACTIONS,\n} from \"app/utils/q_ajax/q_ajax_3\"\n// endregion 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\n/* eslint-disable no-unused-vars */\nenum ResultTypeEnums {\n SUCCESS = \"SUCCESS\",\n NOT_SIGNED_IN = \"NOT_SIGNED_IN\",\n INVALID = \"INVALID\",\n SERVER_ERROR = \"SERVER_ERROR\",\n TOO_MANY_REQUEST = \"TOO_MANY_REQUEST\",\n}\n/* eslint-enable no-unused-vars */\n\ninterface BuildingDataEntry {\n id: string,\n}\n\ninterface PromiseResolvePayload {\n result_type: ResultTypeEnums,\n data?: BuildingDataEntry[],\n}\n\nconst get_many = (): Promise => {\n return Promise.resolve()\n .then(() => {\n return q_ajax_3(\n {\n url: \"/api/web_app/current_authenticated_user/buildings_shortlisted\",\n method: \"GET\",\n dataType: \"json\",\n },\n {\n custom_error_handler: ({http_status_code}) => {\n if (http_status_code === 401) {\n return AJAX_ERROR_HANDLER_ACTIONS.STOP_RETRY\n }\n\n return AJAX_ERROR_HANDLER_ACTIONS.CONTINUE_RETRY\n },\n error_tracking_options: {\n endpoint_identifier: \"/api/web_app/current_authenticated_user/buildings_shortlisted\",\n },\n },\n )\n })\n .then(({data}: {\n data: {\n data: {\n buildings: BuildingDataEntry[]\n }\n }\n }): PromiseResolvePayload => {\n return (\n {\n result_type: ResultTypeEnums.SUCCESS,\n data: data.data.buildings,\n }\n )\n })\n .catch((reason_or_error): PromiseResolvePayload => {\n if (reason_or_error instanceof Error) {\n throw reason_or_error\n }\n\n const { response } = reason_or_error\n switch (response.status) {\n case 500:\n case 502:\n case 503:\n case 504:\n return ({result_type: ResultTypeEnums.SERVER_ERROR})\n case 401:\n return ({result_type: ResultTypeEnums.NOT_SIGNED_IN})\n case 429:\n return ({result_type: ResultTypeEnums.TOO_MANY_REQUEST})\n default:\n return ({result_type: ResultTypeEnums.INVALID})\n }\n })\n}\n\nexport {\n get_many,\n ResultTypeEnums,\n}\n","\nimport Promise from \"bluebird\"\nimport {\n q_ajax_3,\n ERROR_HANDLER_ACTIONS as AJAX_ERROR_HANDLER_ACTIONS,\n} from \"app/utils/q_ajax/q_ajax_3\"\n\n\nimport I18n from \"plugins/i18n-js\"\n\n\ninterface Input {\n user_authentication_handle: string,\n\n building_id: string | number,\n}\n\n/* eslint-disable no-unused-vars */\nenum ResultTypeEnums {\n SUCCESS = \"SUCCESS\",\n UNAUTHENTICATED = \"UNAUTHENTICATED\",\n INVALID = \"INVALID\",\n SERVER_ERROR = \"SERVER_ERROR\",\n}\n/* eslint-enable no-unused-vars */\n\ninterface PromiseResolvePayload {\n result_type: ResultTypeEnums,\n data?: {},\n}\n\nconst create = ({user_authentication_handle, building_id}: Input): Promise => {\n return Promise.resolve(\n import(\n \"plugins/js-routes\"\n )\n )\n .then((Routes) => {\n return q_ajax_3(\n {\n url: Routes.create_api_web_app_building_user_shortlistings_path(),\n type: \"POST\",\n\n // Expect JSON in response\n dataType: \"JSON\",\n\n // Sending JSON to server\n contentType: \"application/json; charset=utf-8\",\n data: JSON.stringify({\n user_authentication_handle: user_authentication_handle,\n building_id: building_id,\n\n locale: I18n.locale,\n }),\n },\n {\n custom_error_handler: ({http_status_code}) => {\n if (http_status_code === 401) {\n return AJAX_ERROR_HANDLER_ACTIONS.STOP_RETRY\n }\n if (http_status_code === 422) {\n return AJAX_ERROR_HANDLER_ACTIONS.STOP_RETRY\n }\n\n return AJAX_ERROR_HANDLER_ACTIONS.CONTINUE_RETRY\n },\n },\n )\n })\n .then(() => {\n return (\n {\n result_type: ResultTypeEnums.SUCCESS,\n data: {},\n }\n )\n })\n .catch((reason_or_error) => {\n if (reason_or_error instanceof Error) {\n throw reason_or_error\n }\n\n const { response } = reason_or_error\n switch (response.status) {\n case 500:\n case 502:\n case 503:\n case 504:\n return ({\n result_type: ResultTypeEnums.SERVER_ERROR,\n })\n case 401:\n return ({\n result_type: ResultTypeEnums.UNAUTHENTICATED,\n })\n case 422:\n return ({\n result_type: ResultTypeEnums.INVALID,\n })\n default:\n return ({\n result_type: ResultTypeEnums.INVALID,\n })\n }\n })\n}\n\nexport {\n create,\n ResultTypeEnums,\n}\n","\nimport Promise from \"bluebird\"\nimport {\n q_ajax_3,\n ERROR_HANDLER_ACTIONS as AJAX_ERROR_HANDLER_ACTIONS,\n} from \"app/utils/q_ajax/q_ajax_3\"\n\n\nimport I18n from \"plugins/i18n-js\"\n\ninterface Input {\n user_authentication_handle: string,\n\n building_id: string | number,\n}\n\n/* eslint-disable no-unused-vars */\nenum ResultTypeEnums {\n SUCCESS = \"SUCCESS\",\n UNAUTHENTICATED = \"UNAUTHENTICATED\",\n INVALID = \"INVALID\",\n SERVER_ERROR = \"SERVER_ERROR\",\n}\n/* eslint-enable no-unused-vars */\n\ninterface PromiseResolvePayload {\n result_type: ResultTypeEnums,\n data?: {},\n}\n\nconst destroy = ({user_authentication_handle, building_id}: Input): Promise => {\n return Promise.resolve(\n import(\n \"plugins/js-routes\"\n )\n )\n .then((Routes) => {\n return q_ajax_3(\n {\n url: Routes.destroy_api_web_app_building_user_shortlistings_path(),\n type: \"DELETE\",\n\n // Expect JSON in response\n dataType: \"JSON\",\n\n // Sending JSON to server\n contentType: \"application/json; charset=utf-8\",\n data: JSON.stringify({\n user_authentication_handle: user_authentication_handle,\n building_id: building_id,\n\n locale: I18n.locale,\n }),\n },\n {\n custom_error_handler: ({http_status_code}) => {\n if (http_status_code === 401) {\n return AJAX_ERROR_HANDLER_ACTIONS.STOP_RETRY\n }\n if (http_status_code === 422) {\n return AJAX_ERROR_HANDLER_ACTIONS.STOP_RETRY\n }\n\n return AJAX_ERROR_HANDLER_ACTIONS.CONTINUE_RETRY\n },\n },\n )\n })\n .then(() => {\n return (\n {\n result_type: ResultTypeEnums.SUCCESS,\n data: {},\n }\n )\n })\n .catch((reason_or_error) => {\n if (reason_or_error instanceof Error) {\n throw reason_or_error\n }\n\n const { response } = reason_or_error\n switch (response.status) {\n case 500:\n case 502:\n case 503:\n case 504:\n return ({\n result_type: ResultTypeEnums.SERVER_ERROR,\n })\n case 401:\n return ({\n result_type: ResultTypeEnums.UNAUTHENTICATED,\n })\n case 422:\n return ({\n result_type: ResultTypeEnums.INVALID,\n })\n default:\n return ({\n result_type: ResultTypeEnums.INVALID,\n })\n }\n })\n}\n\nexport {\n destroy,\n ResultTypeEnums,\n}\n","\n// region JS Imports\n\n// region External Modules\nimport { EventEmitter } from \"events\"\nimport Promise from \"plugins/bluebird/index\"\n\nimport u from \"umbrellajs\"\n// endregion External Modules\n\n// Private Modules\n\nimport {\n isPresentString,\n} from \"app/utils/type_checking\"\n\nimport {\n refreshAndUpdateComponentPromise,\n} from \"app/authentication/remote_state\"\n\nimport {\n captureMessage,\n captureException,\n} from \"app/error_reporting/index\"\n\nimport {\n getContactInfoData,\n setContactInfoData,\n} from \"app/local_storages/contact_info_storage/index\"\n\nimport {\n create as create_user,\n ResultTypeEnums as CreateUserResultTypes,\n} from \"app/resources/users/create/index\"\n\nimport Auth_action from \"app/authentication/action\"\nimport Auth_callback_queue from \"app/authentication/callback_queue\"\nimport {\n isSignedIn,\n} from \"app/authentication/state\"\nimport {\n trackSignUp,\n} from \"app/authentication/tracking\"\nimport {\n getLastContactInfoSyncPromise,\n} from \"app/authentication/contact_info_caching\"\n\nimport {\n create as create_building_user_shortlisting,\n ResultTypeEnums as CreateBuildingUserShortlistingResultTypes,\n} from \"app/resources/building_user_shortlistings/create\"\n\nimport {\n destroy as destroy_building_user_shortlisting,\n ResultTypeEnums as DestroyBuildingUserShortlistingResultTypes,\n} from \"app/resources/building_user_shortlistings/destroy\"\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 RejectionReasons = {\n ERROR_REPORTED: \"ERROR_REPORTED\",\n}\n\nconst SOURCE_FILE_PATH = \"apps/spacious_website/components/buildings/shortlist_button/icon_only/factory\"\n\n\ninterface Inputs {\n container: HTMLElement,\n\n shortlisted_resource_ids: string[],\n}\n\ninterface Selector {\n container: HTMLElement,\n\n shortlist_button: string,\n unshortlist_button: string,\n}\n\nconst DEFAULT_SELECTOR = {\n shortlist_button: \".cell--buildings--shortlist-button--icon-only__link--shortlist\",\n unshortlist_button: \".cell--buildings--shortlist-button--icon-only__link--unshortlist\",\n}\n\nclass ShortlistButton extends EventEmitter {\n private readonly selector: Selector\n\n private readonly container_el: HTMLElement\n private readonly building_id: any\n\n private readonly $shortlist_button: UmbrellaInstance\n private readonly $unshortlist_button: UmbrellaInstance\n\n constructor(inputs: Inputs) {\n super()\n\n this.selector = Object.assign({}, DEFAULT_SELECTOR, inputs)\n\n this.container_el = this.selector.container\n const u_container_el = u(this.container_el)\n\n this.building_id = u_container_el.data(\"building-id\")\n\n this.$shortlist_button =\n u_container_el.find(this.selector.shortlist_button)\n this.$unshortlist_button =\n u_container_el.find(this.selector.unshortlist_button)\n\n this.bind_action()\n\n if (inputs.shortlisted_resource_ids.includes(this.building_id)) {\n this.displayAsShortlisted()\n }\n }\n\n private bind_action(){\n const $shortlist_button = this.$shortlist_button\n const $unshortlist_button = this.$unshortlist_button\n\n $shortlist_button\n .on(\"click\", (e) => {\n e.preventDefault()\n\n this.onShortlistClick()\n })\n\n $unshortlist_button\n .on(\"click\", (e) => {\n e.preventDefault()\n\n this.onUnshortlistClick()\n })\n\n return this\n }\n\n private onShortlistClick() {\n const local_contact_info_data = getContactInfoData()\n\n if (! isPresentString(local_contact_info_data.contact_email_address)) {\n Auth_callback_queue.add(() => {\n getLastContactInfoSyncPromise()\n .then(() => this.onShortlistClick())\n .done()\n }, \"event:shortlist_building\")\n\n Auth_action.showSignUpModal({\n enable_account_already_exists_error_message: false,\n })\n .then(({$modal, authentication_box}) => {\n authentication_box.on(\"sign_up:fail:account_conflict\", ({email_address}) => {\n $modal.modal(\"hide\")\n // Retry AFTER setting local contact email\n setContactInfoData({\n contact_email_address: email_address,\n })\n this.onShortlistClick()\n })\n })\n .done()\n return\n }\n\n let create_building_user_shortlisting_inputs = {}\n Promise.resolve()\n .then(() => {\n if (isSignedIn()) {\n return Promise.resolve()\n }\n\n return create_user({\n authentication_handle: local_contact_info_data.user_authentication_handle || local_contact_info_data.contact_email_address || \"\",\n email_address: local_contact_info_data.contact_email_address || \"\",\n sign_in_on_success: true,\n })\n .then(({result_type}) => {\n switch (result_type) {\n case CreateUserResultTypes.SUCCESS:\n trackSignUp()\n refreshAndUpdateComponentPromise().done()\n return\n case CreateUserResultTypes.CONFLICT:\n return\n default:\n captureMessage(\n `unexpected/unhandled result_type: <${result_type}>`,\n {\n source_file_path:\n SOURCE_FILE_PATH,\n }\n )\n throw RejectionReasons.ERROR_REPORTED\n }\n })\n })\n .then(() => {\n const inputs = {\n // Need `||` to make flow happy\n user_authentication_handle: local_contact_info_data.user_authentication_handle || local_contact_info_data.contact_email_address || \"\",\n\n building_id: this.building_id,\n }\n create_building_user_shortlisting_inputs = inputs\n return create_building_user_shortlisting(inputs)\n })\n .then(({result_type}) => {\n switch (result_type) {\n case CreateBuildingUserShortlistingResultTypes.SUCCESS:\n return\n default:\n captureMessage(\n `unexpected/unhandled result_type from create_building_user_shortlisting: <${result_type}>`,\n Object.assign({\n \"source_file_path\":\n SOURCE_FILE_PATH,\n \"local_contact_info_data.contact_email_address\":\n local_contact_info_data.contact_email_address || \"unknown\",\n }, create_building_user_shortlisting_inputs),\n )\n throw RejectionReasons.ERROR_REPORTED\n }\n })\n .then(() => {\n this.displayAsShortlisted()\n })\n .catch((whatever) => {\n if (whatever === RejectionReasons.ERROR_REPORTED) { return }\n\n if (whatever instanceof Error) {\n captureException(\n whatever,\n {\n source_file_path:\n SOURCE_FILE_PATH,\n }\n )\n return\n }\n\n captureMessage(\n whatever.toString(),\n {\n source_file_path:\n SOURCE_FILE_PATH,\n }\n )\n })\n .done()\n }\n\n private onUnshortlistClick() {\n const local_contact_info_data = getContactInfoData()\n\n if (! isPresentString(local_contact_info_data.contact_email_address)) {\n // Do nothing but just pretend to have unfollow\n this.displayAsNotShortlisted()\n return\n }\n\n Promise.resolve()\n .then(() => {\n return destroy_building_user_shortlisting({\n // Need `||` to make flow happy\n user_authentication_handle: local_contact_info_data.user_authentication_handle || local_contact_info_data.contact_email_address || \"\",\n\n building_id: this.building_id,\n })\n })\n .then(({result_type}) => {\n switch (result_type) {\n case DestroyBuildingUserShortlistingResultTypes.SUCCESS:\n return\n default:\n captureMessage(\n `unexpected/unhandled result_type from destroy_building_user_shortlisting: <${result_type}>`,\n {\n source_file_path:\n SOURCE_FILE_PATH,\n }\n )\n throw RejectionReasons.ERROR_REPORTED\n }\n })\n .then(() => {\n this.displayAsNotShortlisted()\n })\n .catch((whatever) => {\n if (whatever === RejectionReasons.ERROR_REPORTED) { return }\n\n if (whatever instanceof Error) {\n captureException(\n whatever,\n {\n source_file_path:\n SOURCE_FILE_PATH,\n }\n )\n return\n }\n\n captureMessage(\n whatever.toString(),\n {\n source_file_path:\n SOURCE_FILE_PATH,\n }\n )\n })\n .done()\n }\n\n private displayAsShortlisted() {\n this.container_el.classList.add(\"shortlisted\")\n }\n private displayAsNotShortlisted() {\n this.container_el.classList.remove(\"shortlisted\")\n }\n}\n\nconst Factory = {\n create(selector: Inputs){\n return new ShortlistButton(selector)\n },\n}\n\nexport {\n Factory,\n}\n","\n// region JS Imports\n\n// region External Modules\nimport u from \"umbrellajs\"\n// endregion External Modules\n\n// Private Modules\nimport {\n captureMessage,\n} from \"app/error_reporting\"\n\nimport {\n get_many as get_current_authenticated_user_buildings_shortlisted,\n ResultTypeEnums as GetCurrentAuthenticatedUserBuildingsShortlistedTypes,\n} from \"app/resources/current_authenticated_user/buildings_shortlisted/get_many/index\"\n// Private Modules\n\n// region Public Components\n// endregion Public Components\n\n// region Private Components\nimport { Factory } from \"./factory\"\n// endregion Private Components\n\n// endregion JS Imports\n\nconst CELL_CLASS_NAME = \"cell--buildings--shortlist-button--icon-only\"\nconst CELL_INITIALIZED_CLASS_NAME = `${CELL_CLASS_NAME}--js-spacious-initialized`\n\nconst initAllMatchingElements = () => {\n return get_current_authenticated_user_buildings_shortlisted()\n .then(({result_type, data}) => {\n switch (result_type) {\n case GetCurrentAuthenticatedUserBuildingsShortlistedTypes.SUCCESS:\n case GetCurrentAuthenticatedUserBuildingsShortlistedTypes.NOT_SIGNED_IN:\n case GetCurrentAuthenticatedUserBuildingsShortlistedTypes.SERVER_ERROR:\n case GetCurrentAuthenticatedUserBuildingsShortlistedTypes.TOO_MANY_REQUEST:\n return data || []\n default:\n captureMessage(\n `unexpected/unhandled result_type from get_current_authenticated_user_buildings_shortlisted: <${result_type}>`,\n {\n source_file_path:\n \"apps/spacious_website/components/buildings/shortlist_button/icon_only\",\n }\n )\n // Still need to init elements\n return []\n }\n })\n .then((buildings) => {\n u(`.${CELL_CLASS_NAME}`).each((el) => {\n if (el.classList.contains(CELL_INITIALIZED_CLASS_NAME)) { return }\n el.classList.add(CELL_INITIALIZED_CLASS_NAME)\n\n Factory.create({\n container: el,\n\n shortlisted_resource_ids: buildings.map((b) => b.id),\n })\n })\n })\n}\n\n\nexport {\n initAllMatchingElements,\n}\n"],"file":"assets/index-3jUs5Yov.js"}