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jB,OAHA9B,EAVe,cAUI,CACjB+B,WATwBC,IACxBN,QAAQO,IAAI,aAAcD,GAC1BlG,GAASoG,EAAAA,EAAAA,OACLF,GAAcA,EAAW9F,qBAC3BJ,GAASF,EAAAA,EAAAA,IAA4BoG,GACvC,IAMKG,EAAAA,cAACC,EAAAA,SAAQ,KAAY,C","sources":["webpack:///./Scripts/Actions/SavedCart.action.js","webpack:///./Scripts/useSignalR.js","webpack:///./Scripts/SignalR.js"],"sourcesContent":["import { get, post, put } from '../Services/http';\r\nimport { catchError } from './Error.action';\r\nimport { receive } from './Cart.action';\r\nimport {\r\n SAVED_CART_LIST_RECEIVE,\r\n SAVED_CART_OPEN,\r\n SAVED_CART_CLOSE,\r\n SAVED_CART_PRODUCT_SELECTION,\r\n SAVED_CART_PRODUCT_DESELECTION,\r\n UPDATE_CART_ROW_STATUS,\r\n UPDATE_CART_ROW_INIT_STATUS,\r\n SAVED_CART_LIST_ADD_TO_CART_CLEAR,\r\n DELETE_CART,\r\n UPDATE_CART_NAME,\r\n SAVED_CART_LOAD_ERROR,\r\n} from '../constants';\r\nimport { googleAnalyticsAddToCart } from '../Services/googleAnalytics'\r\n\r\nconst apiBaseUrl = '/api/savedcart';\r\n\r\nexport const open = (id) => ({\r\n type: SAVED_CART_OPEN,\r\n payload: id,\r\n});\r\n\r\nexport const close = () => ({\r\n type: SAVED_CART_CLOSE,\r\n});\r\n\r\nexport const selectSavedCartProduct = (id) => ({\r\n type: SAVED_CART_PRODUCT_SELECTION,\r\n payload: id,\r\n});\r\n\r\nexport const deselectSavedCartProduct = (id) => ({\r\n type: SAVED_CART_PRODUCT_DESELECTION,\r\n payload: id,\r\n});\r\n\r\nexport const updateCartRowStatus = (id, rowStatus) => ({\r\n type: UPDATE_CART_ROW_STATUS,\r\n payload: { id, rowStatus },\r\n});\r\n\r\nexport const updateCartRowInitStatus = (cartRowStatusList) => ({\r\n type: UPDATE_CART_ROW_INIT_STATUS,\r\n payload: { cartRowStatusList },\r\n});\r\n\r\nexport const receiveSelectedCart = (carts, selectedOrderRowList) => ({\r\n type: SAVED_CART_LIST_RECEIVE,\r\n payload: {\r\n selectedCart: carts,\r\n loadingStatus: 'Completed',\r\n selectedOrderRowList,\r\n },\r\n});\r\n\r\nconst hideShowButton = () => ({\r\n type: SAVED_CART_LIST_RECEIVE,\r\n payload: {\r\n showUpdateButton: false,\r\n },\r\n});\r\n\r\nexport const clearSelectedCart = () => ({\r\n type: SAVED_CART_LIST_RECEIVE,\r\n payload: {\r\n selectedCart: {},\r\n loadingStatus: 'Loading',\r\n selectedOrderRowList: [],\r\n },\r\n});\r\n\r\nexport const clearCartRowStatusList = () => ({\r\n type: SAVED_CART_LIST_ADD_TO_CART_CLEAR,\r\n payload: {\r\n cartRowStatusList: [],\r\n },\r\n});\r\n\r\nexport const deleteCart = (cartId) => ({\r\n type: DELETE_CART,\r\n payload: { cartId },\r\n});\r\n\r\nexport const updateCartName = (cartId, name) => ({\r\n type: UPDATE_CART_NAME,\r\n payload: { cartId, name },\r\n});\r\n\r\nconst receiveCarts = (status, carts) => ({\r\n type: SAVED_CART_LIST_RECEIVE,\r\n payload: {\r\n savedCarts: carts,\r\n loadingStatus: 'Completed',\r\n showUpdateButton: status,\r\n },\r\n});\r\n\r\nconst receiveCartLists = (status, carts) => ({\r\n type: SAVED_CART_LIST_RECEIVE,\r\n payload: {\r\n ...carts,\r\n loadingStatus: 'Completed',\r\n showUpdateButton: status,\r\n },\r\n});\r\n\r\nconst clearReceiveCarts = () => ({\r\n type: SAVED_CART_LIST_RECEIVE,\r\n payload: {\r\n savedCarts: [],\r\n loadingStatus: 'Loading',\r\n },\r\n});\r\n\r\nconst setUserId = (value) => ({\r\n type: SAVED_CART_LIST_RECEIVE,\r\n payload: {\r\n selectedUserId: value,\r\n },\r\n});\r\n\r\nexport const loadError = (error) => ({\r\n type: SAVED_CART_LOAD_ERROR,\r\n payload: {\r\n error,\r\n },\r\n});\r\n\r\nexport const updateSavedCartRowAddStatus =\r\n (message) => (dispatch, getState) => {\r\n dispatch(updateCartRowStatus(message.savedCartOrderRowId, message.error ? 3 : 2));\r\n };\r\n\r\nexport const setReceiveSelectedCart = (carts) => (dispatch, getState) => {\r\n const orderRows = carts.orderRows || [];\r\n\r\n const selectedOrderRowList = orderRows.filter((row) => row.rowSystemId && row.isPublished === true && row.isHideProductPurchase === false)\r\n .map((row) => row.rowSystemId);\r\n\r\n dispatch(receiveSelectedCart(carts, selectedOrderRowList));\r\n};\r\n\r\nexport const updateCartRowInitAddStatus =\r\n (selectedOrderRowList) => (dispatch, getState) => {\r\n const cartRowStatusList = selectedOrderRowList.map((orderRowId) => ({\r\n id: orderRowId,\r\n rowStatus: 1,\r\n }));\r\n dispatch(updateCartRowInitStatus(cartRowStatusList));\r\n };\r\n\r\nexport const setShowButton = (status, savedCarts) => (dispatch) => {\r\n let arrayItem = [];\r\n savedCarts.map((cart, index) => {\r\n cart.isDelete = false;\r\n arrayItem.push(cart);\r\n });\r\n dispatch(receiveCarts(status, arrayItem));\r\n};\r\n\r\nexport const updateSavedCart = (savedCarts) => (dispatch) => {\r\n dispatch(hideShowButton());\r\n return put(apiBaseUrl + '/update', savedCarts)\r\n .then((response) => {\r\n dispatch(receiveCarts(false, savedCarts.filter((cart) => !cart.isDelete)));\r\n })\r\n .catch((ex) =>\r\n dispatch(\r\n catchError(ex, (error) => {\r\n return loadError(error);\r\n })\r\n )\r\n );\r\n};\r\n\r\nexport const addToCart =\r\n (selectedOrderId, selectedOrderRowList, isListPage = false) => (dispatch) => {\r\n if (!isListPage) {\r\n dispatch(clearCartRowStatusList());\r\n dispatch(updateCartRowInitAddStatus(selectedOrderRowList));\r\n }\r\n return post('/api/savedcart/addtocart', {\r\n selectedOrderId,\r\n selectedOrderRowList,\r\n })\r\n .then((response) => response.json())\r\n .then((cart) => {\r\n renderGoogleAnalytics(cart.orderRows, selectedOrderRowList);\r\n dispatch(receive({ ...cart }));\r\n })\r\n .catch((ex) =>\r\n dispatch(catchError(ex, (error) => { return loadError(error); }))\r\n );\r\n };\r\n\r\nexport const getSelectedCart = (orderId) => (dispatch) => {\r\n if (orderId) {\r\n dispatch(clearSelectedCart());\r\n return get(apiBaseUrl + '/order/' + orderId)\r\n .then((response) => response.json())\r\n .then((data) => {\r\n dispatch(setReceiveSelectedCart(data));\r\n dispatch(receive({ ...data }));\r\n })\r\n .catch((ex) =>\r\n dispatch(catchError(ex, (error) => { return loadError(error); }))\r\n );\r\n }\r\n};\r\n\r\nexport const getUserCarts = (userId) => (dispatch) => {\r\n dispatch(clearReceiveCarts());\r\n dispatch(hideShowButton());\r\n dispatch(setUserId(userId));\r\n if (!userId) {\r\n dispatch(receiveCarts(false, []));\r\n return;\r\n }\r\n return get(apiBaseUrl + '/user/' + userId)\r\n .then((response) => response.json())\r\n .then((data) => dispatch(receiveCarts(false, data)))\r\n .catch((ex) =>\r\n dispatch(\r\n catchError(ex, (error) => {\r\n return loadError(error);\r\n })\r\n )\r\n );\r\n};\r\n\r\nexport const updateSavedCartName =\r\n (SelectedOrderId, SelectedOrderName) => (dispatch) => {\r\n return put(apiBaseUrl + '/titleupdate/', {\r\n SelectedOrderId,\r\n SelectedOrderName,\r\n })\r\n .then((response) => response.json())\r\n .then((data) => {\r\n dispatch(updateCartName(SelectedOrderId, SelectedOrderName));\r\n })\r\n .catch((ex) =>\r\n dispatch(\r\n catchError(ex, (error) => {\r\n return loadError(error);\r\n })\r\n )\r\n );\r\n };\r\n\r\nexport const getSavedCartsList = (userId) => (dispatch) => {\r\n dispatch(clearSelectedCart());\r\n return get(apiBaseUrl)\r\n .then((response) => response.json())\r\n .then((data) => dispatch(receiveCartLists(false, data)))\r\n .catch((ex) =>\r\n dispatch(\r\n catchError(ex, (error) => {\r\n return loadError(error);\r\n })\r\n )\r\n );\r\n};\r\n\r\nconst renderGoogleAnalytics = (orderRows, selectedOrderRowList) => {\r\n\r\n let matchedRows = orderRows.filter(orderRow => selectedOrderRowList.includes(orderRow.rowSystemId));\r\n\r\n if (matchedRows && matchedRows.length > 0) {\r\n const products = matchedRows.map(row => ({\r\n name: row.name,\r\n id: row.articleNumber,\r\n category: row.breadcrumbs,\r\n campaignProduct: row.isCampaignProduct,\r\n }));\r\n\r\n googleAnalyticsAddToCart(products)\r\n }\r\n\r\n};","import { useEffect, useState } from 'react';\r\nimport * as signalR from '@microsoft/signalr';\r\n\r\nconst useSignalR = (hubUrl, eventHandlers) => {\r\n const [connection, setConnection] = useState(null);\r\n\r\n useEffect(() => {\r\n const newConnection = new signalR.HubConnectionBuilder()\r\n .withUrl(hubUrl)\r\n .withAutomaticReconnect()\r\n .configureLogging(signalR.LogLevel.Information)\r\n .build();\r\n\r\n setConnection(newConnection);\r\n\r\n return () => {\r\n if (newConnection) {\r\n newConnection.stop();\r\n }\r\n };\r\n }, [hubUrl]);\r\n\r\n useEffect(() => {\r\n if (connection) {\r\n connection\r\n .start()\r\n .then(() => {\r\n for (const [event, handler] of Object.entries(eventHandlers)) {\r\n connection.on(event, handler);\r\n }\r\n })\r\n .catch((error) => console.error('Connection failed: ', error));\r\n }\r\n\r\n return () => {\r\n if (connection) {\r\n for (const event of Object.keys(eventHandlers)) {\r\n connection.off(event, eventHandlers[event]);\r\n }\r\n }\r\n };\r\n }, [connection, eventHandlers]);\r\n\r\n return connection;\r\n};\r\n\r\nexport default useSignalR;\r\n","import React, { Fragment } from 'react';\r\nimport { useDispatch } from 'react-redux';\r\nimport useSignalR from './useSignalR';\r\nimport { load as loadCart } from './Actions/Cart.action';\r\nimport { updateSavedCartRowAddStatus } from './Actions/SavedCart.action';\r\n\r\nconst SignalR = () => {\r\n const dispatch = useDispatch();\r\n const hubUrl = '/signalRHub';\r\n\r\n const handleCreateLine = (createLine) => {\r\n console.log('createLine', createLine);\r\n dispatch(loadCart());\r\n if (createLine && createLine.savedCartOrderRowId) {\r\n dispatch(updateSavedCartRowAddStatus(createLine));\r\n }\r\n };\r\n\r\n useSignalR(hubUrl, {\r\n CreateLine: handleCreateLine,\r\n });\r\n return ;\r\n};\r\n\r\nexport default SignalR;\r\n"],"names":["apiBaseUrl","open","id","type","SAVED_CART_OPEN","payload","close","SAVED_CART_CLOSE","selectSavedCartProduct","SAVED_CART_PRODUCT_SELECTION","deselectSavedCartProduct","SAVED_CART_PRODUCT_DESELECTION","hideShowButton","SAVED_CART_LIST_RECEIVE","showUpdateButton","clearSelectedCart","selectedCart","loadingStatus","selectedOrderRowList","deleteCart","cartId","DELETE_CART","updateCartName","name","UPDATE_CART_NAME","receiveCarts","status","carts","savedCarts","loadError","error","SAVED_CART_LOAD_ERROR","updateSavedCartRowAddStatus","message","dispatch","getState","updateCartRowStatus","rowStatus","savedCartOrderRowId","UPDATE_CART_ROW_STATUS","setReceiveSelectedCart","orderRows","filter","row","rowSystemId","isPublished","isHideProductPurchase","map","receiveSelectedCart","updateCartRowInitAddStatus","cartRowStatusList","UPDATE_CART_ROW_INIT_STATUS","updateCartRowInitStatus","orderRowId","setShowButton","arrayItem","cart","index","isDelete","push","updateSavedCart","put","then","response","catch","ex","catchError","addToCart","selectedOrderId","isListPage","SAVED_CART_LIST_ADD_TO_CART_CLEAR","post","json","renderGoogleAnalytics","receive","_objectSpread","getSelectedCart","orderId","get","data","getUserCarts","userId","value","selectedUserId","updateSavedCartName","SelectedOrderId","SelectedOrderName","getSavedCartsList","receiveCartLists","matchedRows","orderRow","includes","length","products","articleNumber","category","breadcrumbs","campaignProduct","isCampaignProduct","googleAnalyticsAddToCart","useSignalR","hubUrl","eventHandlers","_useState","useState","_useState2","_slicedToArray","connection","setConnection","useEffect","newConnection","signalR","withUrl","withAutomaticReconnect","configureLogging","Information","build","stop","start","_ref","Object","entries","_ref2","event","handler","on","console","keys","off","SignalR","useDispatch","CreateLine","createLine","log","loadCart","React","Fragment"],"sourceRoot":""}