{"version":3,"file":"PaymentMethods.js","names":["defineDs","m","Button","Api","LoginCache","MembershipPaymentCard","PaymentMethods","controller","args","userData","prop","getUserObj","customerInfo","initiatedDelete","initiatedChange","setInitiatedDelete","id","setInitiatedChange","resetInitation","addPaymentMethod","data","first_name","firstName","last_name","lastName","accept_url","window","location","href","cancel_url","then","response","url","deletePaymentMethod","fetchData","catch","changePaymentMethod","payment_method_id","subscriptionData","handle","view","ctrl","_ref","_paymentCardsData","_paymentCardsData2","_paymentCardsData$oth","_paymentCardsData$oth2","isLoading","paymentCardsData","goBack","className","xmlns","fill","viewBox","cx","cy","r","stroke","d","active","length","map","_data$card","_data$card2","classNames","icon","card","types","cardNumber","masked_card","other","_data$card3","_data$card4","alternative","concat","variant","onClick"],"sources":["DanskeSpil/Domain/Feature.LoyaltyClub/Components/MembershipFlow/PaymentMethods.js"],"sourcesContent":["/* eslint-disable camelcase */\r\ndefineDs('DanskeSpil/Domain/Feature.LoyaltyClub/Components/MembershipFlow/PaymentMethods', [\r\n 'Shared/Framework/Mithril/Scripts/Core/Mithril',\r\n 'DanskeSpil/Domain/Feature.LoyaltyClub/Components/Button/Button',\r\n 'DanskeSpil/Domain/Feature.LoyaltyClub/Helpers/Api',\r\n 'DanskeSpil/Domain/Authentification/Scripts/LoginCache',\r\n 'DanskeSpil/Domain/Feature.LoyaltyClub/Components/MembershipPaymentCard/MembershipPaymentCard',\r\n],\r\nfunction (m, Button, Api, LoginCache, MembershipPaymentCard) {\r\n const PaymentMethods = {\r\n controller: function (args) {\r\n const userData = m.prop(LoginCache.getUserObj().customerInfo);\r\n const initiatedDelete = m.prop(false);\r\n const initiatedChange = m.prop(false);\r\n\r\n const setInitiatedDelete = (id) => {\r\n initiatedChange(false);\r\n initiatedDelete(id);\r\n };\r\n\r\n const setInitiatedChange = (id) => {\r\n initiatedDelete(false);\r\n initiatedChange(id);\r\n };\r\n\r\n const resetInitation = () => {\r\n initiatedDelete(false);\r\n initiatedChange(false);\r\n };\r\n\r\n const addPaymentMethod = () => {\r\n const data = {\r\n first_name: userData().firstName,\r\n last_name: userData().lastName,\r\n accept_url: window.location.href,\r\n cancel_url: window.location.href,\r\n };\r\n Api.addPaymentMethod(data)\r\n .then((response) => {\r\n window.location.href = response.url;\r\n });\r\n };\r\n\r\n const deletePaymentMethod = (id) => {\r\n Api.deletePaymentMethod(id)\r\n .then(() => {\r\n resetInitation();\r\n args.fetchData();\r\n }).catch(() => {\r\n resetInitation();\r\n });\r\n };\r\n\r\n const changePaymentMethod = (id) => {\r\n const data = {\r\n payment_method_id: id\r\n };\r\n Api.changePaymentMethod(args.subscriptionData().handle, data)\r\n .then(() => {\r\n resetInitation();\r\n args.fetchData();\r\n }).catch(() => {\r\n resetInitation();\r\n });\r\n };\r\n\r\n return { addPaymentMethod, deletePaymentMethod, changePaymentMethod, initiatedDelete, initiatedChange, resetInitation, setInitiatedDelete, setInitiatedChange };\r\n },\r\n view: function (ctrl, { isLoading, paymentCardsData, goBack }) {\r\n if (isLoading()) {\r\n return (\r\n
Valgt betalingsmetode
\r\n { paymentCardsData()?.active?.length > 0 ?\r\n paymentCardsData()?.active?.map((data) =>\r\nIngen valgt betalingsmetode
}\r\nAndre betalingsmetoder
\r\n { paymentCardsData().other?.length > 0 ?\r\n paymentCardsData().other?.map((data) =>\r\nIngen andre betalingsmetoder
}\r\n