tango-app-ui-shared 3.5.1-task.2 → 3.5.1-task.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) hide show
  1. package/esm2022/lib/guards/auth.guard.mjs +26 -0
  2. package/esm2022/lib/guards/lead.guard.mjs +16 -0
  3. package/esm2022/lib/guards/stores.guard.mjs +16 -0
  4. package/esm2022/lib/guards/tickets.guard.mjs +16 -0
  5. package/esm2022/lib/i18n/index.mjs +3 -0
  6. package/esm2022/lib/i18n/translation.module.mjs +17 -0
  7. package/esm2022/lib/i18n/translation.service.mjs +53 -0
  8. package/esm2022/lib/i18n/vocabs/ch.mjs +106 -0
  9. package/esm2022/lib/i18n/vocabs/de.mjs +106 -0
  10. package/esm2022/lib/i18n/vocabs/en.mjs +106 -0
  11. package/esm2022/lib/i18n/vocabs/es.mjs +106 -0
  12. package/esm2022/lib/i18n/vocabs/fr.mjs +106 -0
  13. package/esm2022/lib/i18n/vocabs/jp.mjs +106 -0
  14. package/esm2022/lib/interceptors/http-auth-interceptor.mjs +201 -0
  15. package/esm2022/lib/interfaces/global-state.mjs +2 -0
  16. package/esm2022/lib/modules/common/common-shared.module.mjs +31 -0
  17. package/esm2022/lib/modules/common/custom-select/custom-select.component.mjs +155 -0
  18. package/esm2022/lib/modules/common/filters/filters.component.mjs +179 -0
  19. package/esm2022/lib/modules/common/pagination/pagination.component.mjs +49 -0
  20. package/esm2022/lib/modules/errors/error403/error403.component.mjs +33 -0
  21. package/esm2022/lib/modules/errors/error404/error404.component.mjs +44 -0
  22. package/esm2022/lib/modules/errors/error500/error500.component.mjs +45 -0
  23. package/esm2022/lib/modules/errors/errors-routing.module.mjs +48 -0
  24. package/esm2022/lib/modules/errors/errors.component.mjs +39 -0
  25. package/esm2022/lib/modules/errors/errors.module.mjs +37 -0
  26. package/esm2022/lib/modules/errors/invalid-ip/invalid-ip.component.mjs +44 -0
  27. package/esm2022/lib/modules/intro/contact-support/contact-support.component.mjs +19 -0
  28. package/esm2022/lib/modules/intro/intro-routing.module.mjs +24 -0
  29. package/esm2022/lib/modules/intro/intro.module.mjs +32 -0
  30. package/esm2022/lib/modules/intro/lead-intro/lead-intro.component.mjs +110 -0
  31. package/esm2022/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.mjs +31 -0
  32. package/esm2022/lib/modules/layout/content/content.component.mjs +107 -0
  33. package/esm2022/lib/modules/layout/footer/footer.component.mjs +17 -0
  34. package/esm2022/lib/modules/layout/header/header-menu/header-menu.component.mjs +41 -0
  35. package/esm2022/lib/modules/layout/header/header.component.mjs +100 -0
  36. package/esm2022/lib/modules/layout/header/navbar/navbar.component.mjs +256 -0
  37. package/esm2022/lib/modules/layout/header/notifications-inner/notifications-inner.component.mjs +79 -0
  38. package/esm2022/lib/modules/layout/header/page-title/page-title.component.mjs +56 -0
  39. package/esm2022/lib/modules/layout/keenicon/icons.json +1 -0
  40. package/esm2022/lib/modules/layout/keenicon/keenicon.component.mjs +37 -0
  41. package/esm2022/lib/modules/layout/layout/layout.component.mjs +314 -0
  42. package/esm2022/lib/modules/layout/layout.module.mjs +195 -0
  43. package/esm2022/lib/modules/layout/scripts-init/scripts-init.component.mjs +74 -0
  44. package/esm2022/lib/modules/layout/scroll-top/scroll-top.component.mjs +74 -0
  45. package/esm2022/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.mjs +118 -0
  46. package/esm2022/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.mjs +45 -0
  47. package/esm2022/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.mjs +111 -0
  48. package/esm2022/lib/modules/layout/sidebar/sidebar.component.mjs +134 -0
  49. package/esm2022/lib/modules/layout/toolbar/accounting/accounting.component.mjs +16 -0
  50. package/esm2022/lib/modules/layout/toolbar/classic/classic.component.mjs +331 -0
  51. package/esm2022/lib/modules/layout/toolbar/client-settings/client-settings.component.mjs +88 -0
  52. package/esm2022/lib/modules/layout/toolbar/date-single-select/date-single-select.component.mjs +201 -0
  53. package/esm2022/lib/modules/layout/toolbar/datepicker/datepicker.component.mjs +150 -0
  54. package/esm2022/lib/modules/layout/toolbar/extended/extended.component.mjs +15 -0
  55. package/esm2022/lib/modules/layout/toolbar/metrics-header/metrics-header.component.mjs +1321 -0
  56. package/esm2022/lib/modules/layout/toolbar/reports/reports.component.mjs +18 -0
  57. package/esm2022/lib/modules/layout/toolbar/saas/saas.component.mjs +18 -0
  58. package/esm2022/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.mjs +11 -0
  59. package/esm2022/lib/modules/layout/toolbar/single-store/single-store.component.mjs +176 -0
  60. package/esm2022/lib/modules/layout/toolbar/single-storedate/single-storedate.component.mjs +166 -0
  61. package/esm2022/lib/modules/layout/toolbar/storesingle/storesingle.component.mjs +105 -0
  62. package/esm2022/lib/modules/layout/toolbar/toolbar.component.mjs +314 -0
  63. package/esm2022/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.mjs +1060 -0
  64. package/esm2022/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.mjs +795 -0
  65. package/esm2022/lib/modules/layout/toolbar/trax-header/trax-header.component.mjs +880 -0
  66. package/esm2022/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.mjs +729 -0
  67. package/esm2022/lib/modules/notification/conformation/conformation.component.mjs +22 -0
  68. package/esm2022/lib/modules/notification/notification/notification.component.mjs +317 -0
  69. package/esm2022/lib/modules/notification/notification-routing.module.mjs +28 -0
  70. package/esm2022/lib/modules/notification/notification.module.mjs +32 -0
  71. package/esm2022/lib/pipes/customDate.pipe.mjs +22 -0
  72. package/esm2022/lib/routes/route-wraper-modules/edge-wrapper.module.mjs +18 -0
  73. package/esm2022/lib/routes/route-wraper-modules/manage-wrapper.module.mjs +18 -0
  74. package/esm2022/lib/routes/route-wraper-modules/profile-wrapper.module.mjs +18 -0
  75. package/esm2022/lib/routes/route-wraper-modules/store-wrapper.module.mjs +18 -0
  76. package/esm2022/lib/routes/route-wraper-modules/ticket-wrapper.module.mjs +18 -0
  77. package/esm2022/lib/routes/routing.mjs +53 -0
  78. package/esm2022/lib/services/auth.service.mjs +154 -0
  79. package/esm2022/lib/services/notification.service.mjs +74 -0
  80. package/esm2022/lib/services/toast.service.mjs +83 -0
  81. package/esm2022/public-api.mjs +56 -0
  82. package/esm2022/tango-app-ui-shared.mjs +5 -0
  83. package/fesm2022/tango-app-ui-shared-edge-wrapper.module-CFDk0tvS.mjs +21 -0
  84. package/fesm2022/tango-app-ui-shared-edge-wrapper.module-CFDk0tvS.mjs.map +1 -0
  85. package/fesm2022/tango-app-ui-shared-intro.module-DYh4ZRha.mjs +188 -0
  86. package/fesm2022/tango-app-ui-shared-intro.module-DYh4ZRha.mjs.map +1 -0
  87. package/fesm2022/tango-app-ui-shared-manage-wrapper.module-BHyh4Njw.mjs +21 -0
  88. package/fesm2022/tango-app-ui-shared-manage-wrapper.module-BHyh4Njw.mjs.map +1 -0
  89. package/fesm2022/tango-app-ui-shared-notification.module-C5ZmCf8U.mjs +400 -0
  90. package/fesm2022/tango-app-ui-shared-notification.module-C5ZmCf8U.mjs.map +1 -0
  91. package/fesm2022/tango-app-ui-shared-profile-wrapper.module-BNC1AGOk.mjs +21 -0
  92. package/fesm2022/tango-app-ui-shared-profile-wrapper.module-BNC1AGOk.mjs.map +1 -0
  93. package/fesm2022/tango-app-ui-shared-store-wrapper.module-DdaCYHdv.mjs +21 -0
  94. package/fesm2022/tango-app-ui-shared-store-wrapper.module-DdaCYHdv.mjs.map +1 -0
  95. package/fesm2022/tango-app-ui-shared-ticket-wrapper.module-r32uKkDO.mjs +21 -0
  96. package/fesm2022/tango-app-ui-shared-ticket-wrapper.module-r32uKkDO.mjs.map +1 -0
  97. package/fesm2022/tango-app-ui-shared.mjs +11121 -0
  98. package/fesm2022/tango-app-ui-shared.mjs.map +1 -0
  99. package/index.d.ts +5 -0
  100. package/lib/guards/auth.guard.d.ts +10 -0
  101. package/lib/guards/lead.guard.d.ts +2 -0
  102. package/lib/guards/stores.guard.d.ts +2 -0
  103. package/lib/guards/tickets.guard.d.ts +2 -0
  104. package/{src/lib/i18n/index.ts → lib/i18n/index.d.ts} +2 -2
  105. package/lib/i18n/translation.module.d.ts +8 -0
  106. package/lib/i18n/translation.service.d.ts +19 -0
  107. package/lib/i18n/vocabs/ch.d.ts +104 -0
  108. package/lib/i18n/vocabs/de.d.ts +104 -0
  109. package/lib/i18n/vocabs/en.d.ts +104 -0
  110. package/lib/i18n/vocabs/es.d.ts +104 -0
  111. package/lib/i18n/vocabs/fr.d.ts +104 -0
  112. package/lib/i18n/vocabs/jp.d.ts +104 -0
  113. package/lib/interceptors/http-auth-interceptor.d.ts +20 -0
  114. package/lib/interfaces/global-state.d.ts +5 -0
  115. package/lib/modules/common/common-shared.module.d.ts +13 -0
  116. package/lib/modules/common/custom-select/custom-select.component.d.ts +33 -0
  117. package/lib/modules/common/filters/filters.component.d.ts +38 -0
  118. package/lib/modules/common/pagination/pagination.component.d.ts +18 -0
  119. package/lib/modules/errors/error403/error403.component.d.ts +14 -0
  120. package/lib/modules/errors/error404/error404.component.d.ts +15 -0
  121. package/lib/modules/errors/error500/error500.component.d.ts +15 -0
  122. package/lib/modules/errors/errors-routing.module.d.ts +7 -0
  123. package/lib/modules/errors/errors.component.d.ts +13 -0
  124. package/lib/modules/errors/errors.module.d.ts +13 -0
  125. package/lib/modules/errors/invalid-ip/invalid-ip.component.d.ts +17 -0
  126. package/lib/modules/intro/contact-support/contact-support.component.d.ts +9 -0
  127. package/lib/modules/intro/intro-routing.module.d.ts +7 -0
  128. package/lib/modules/intro/intro.module.d.ts +11 -0
  129. package/lib/modules/intro/lead-intro/lead-intro.component.d.ts +31 -0
  130. package/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.d.ts +13 -0
  131. package/lib/modules/layout/content/content.component.d.ts +25 -0
  132. package/lib/modules/layout/footer/footer.component.d.ts +8 -0
  133. package/lib/modules/layout/header/header-menu/header-menu.component.d.ts +18 -0
  134. package/lib/modules/layout/header/header.component.d.ts +30 -0
  135. package/lib/modules/layout/header/navbar/navbar.component.d.ts +45 -0
  136. package/lib/modules/layout/header/notifications-inner/notifications-inner.component.d.ts +25 -0
  137. package/lib/modules/layout/header/page-title/page-title.component.d.ts +23 -0
  138. package/lib/modules/layout/keenicon/keenicon.component.d.ts +13 -0
  139. package/lib/modules/layout/layout/layout.component.d.ts +82 -0
  140. package/lib/modules/layout/layout.module.d.ts +49 -0
  141. package/lib/modules/layout/scripts-init/scripts-init.component.d.ts +19 -0
  142. package/lib/modules/layout/scroll-top/scroll-top.component.d.ts +19 -0
  143. package/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.d.ts +39 -0
  144. package/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.d.ts +19 -0
  145. package/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.d.ts +23 -0
  146. package/lib/modules/layout/sidebar/sidebar.component.d.ts +36 -0
  147. package/lib/modules/layout/toolbar/accounting/accounting.component.d.ts +8 -0
  148. package/lib/modules/layout/toolbar/classic/classic.component.d.ts +48 -0
  149. package/lib/modules/layout/toolbar/client-settings/client-settings.component.d.ts +16 -0
  150. package/lib/modules/layout/toolbar/date-single-select/date-single-select.component.d.ts +28 -0
  151. package/lib/modules/layout/toolbar/datepicker/datepicker.component.d.ts +28 -0
  152. package/lib/modules/layout/toolbar/extended/extended.component.d.ts +8 -0
  153. package/lib/modules/layout/toolbar/metrics-header/metrics-header.component.d.ts +103 -0
  154. package/lib/modules/layout/toolbar/reports/reports.component.d.ts +9 -0
  155. package/lib/modules/layout/toolbar/saas/saas.component.d.ts +9 -0
  156. package/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.d.ts +5 -0
  157. package/lib/modules/layout/toolbar/single-store/single-store.component.d.ts +33 -0
  158. package/lib/modules/layout/toolbar/single-storedate/single-storedate.component.d.ts +34 -0
  159. package/lib/modules/layout/toolbar/storesingle/storesingle.component.d.ts +24 -0
  160. package/lib/modules/layout/toolbar/toolbar.component.d.ts +55 -0
  161. package/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.d.ts +93 -0
  162. package/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.d.ts +80 -0
  163. package/lib/modules/layout/toolbar/trax-header/trax-header.component.d.ts +83 -0
  164. package/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.d.ts +74 -0
  165. package/lib/modules/notification/conformation/conformation.component.d.ts +10 -0
  166. package/lib/modules/notification/notification/notification.component.d.ts +63 -0
  167. package/lib/modules/notification/notification-routing.module.d.ts +7 -0
  168. package/lib/modules/notification/notification.module.d.ts +11 -0
  169. package/lib/pipes/customDate.pipe.d.ts +7 -0
  170. package/lib/routes/route-wraper-modules/edge-wrapper.module.d.ts +7 -0
  171. package/lib/routes/route-wraper-modules/manage-wrapper.module.d.ts +7 -0
  172. package/lib/routes/route-wraper-modules/profile-wrapper.module.d.ts +7 -0
  173. package/lib/routes/route-wraper-modules/store-wrapper.module.d.ts +7 -0
  174. package/lib/routes/route-wraper-modules/ticket-wrapper.module.d.ts +7 -0
  175. package/lib/routes/routing.d.ts +3 -0
  176. package/lib/services/auth.service.d.ts +52 -0
  177. package/lib/services/notification.service.d.ts +30 -0
  178. package/lib/services/toast.service.d.ts +10 -0
  179. package/package.json +25 -12
  180. package/{src/public-api.ts → public-api.d.ts} +44 -71
  181. package/.eslintrc.json +0 -37
  182. package/ng-package.json +0 -7
  183. package/src/lib/guards/auth.guard.ts +0 -20
  184. package/src/lib/guards/lead.guard.ts +0 -16
  185. package/src/lib/guards/stores.guard.ts +0 -16
  186. package/src/lib/guards/tickets.guard.ts +0 -16
  187. package/src/lib/i18n/translation.module.ts +0 -9
  188. package/src/lib/i18n/translation.service.ts +0 -61
  189. package/src/lib/i18n/vocabs/ch.ts +0 -105
  190. package/src/lib/i18n/vocabs/de.ts +0 -105
  191. package/src/lib/i18n/vocabs/en.ts +0 -105
  192. package/src/lib/i18n/vocabs/es.ts +0 -105
  193. package/src/lib/i18n/vocabs/fr.ts +0 -105
  194. package/src/lib/i18n/vocabs/jp.ts +0 -105
  195. package/src/lib/interceptors/http-auth-interceptor.ts +0 -225
  196. package/src/lib/interfaces/global-state.ts +0 -6
  197. package/src/lib/modules/common/common-shared.module.ts +0 -20
  198. package/src/lib/modules/common/custom-select/custom-select.component.html +0 -42
  199. package/src/lib/modules/common/custom-select/custom-select.component.scss +0 -131
  200. package/src/lib/modules/common/custom-select/custom-select.component.spec.ts +0 -23
  201. package/src/lib/modules/common/custom-select/custom-select.component.ts +0 -149
  202. package/src/lib/modules/common/filters/filters.component.html +0 -76
  203. package/src/lib/modules/common/filters/filters.component.scss +0 -131
  204. package/src/lib/modules/common/filters/filters.component.spec.ts +0 -23
  205. package/src/lib/modules/common/filters/filters.component.ts +0 -181
  206. package/src/lib/modules/common/pagination/pagination.component.html +0 -26
  207. package/src/lib/modules/common/pagination/pagination.component.scss +0 -63
  208. package/src/lib/modules/common/pagination/pagination.component.spec.ts +0 -23
  209. package/src/lib/modules/common/pagination/pagination.component.ts +0 -46
  210. package/src/lib/modules/errors/error403/error403.component.html +0 -25
  211. package/src/lib/modules/errors/error403/error403.component.scss +0 -0
  212. package/src/lib/modules/errors/error403/error403.component.spec.ts +0 -23
  213. package/src/lib/modules/errors/error403/error403.component.ts +0 -28
  214. package/src/lib/modules/errors/error404/error404.component.html +0 -24
  215. package/src/lib/modules/errors/error404/error404.component.scss +0 -0
  216. package/src/lib/modules/errors/error404/error404.component.spec.ts +0 -25
  217. package/src/lib/modules/errors/error404/error404.component.ts +0 -50
  218. package/src/lib/modules/errors/error500/error500.component.html +0 -24
  219. package/src/lib/modules/errors/error500/error500.component.scss +0 -0
  220. package/src/lib/modules/errors/error500/error500.component.spec.ts +0 -25
  221. package/src/lib/modules/errors/error500/error500.component.ts +0 -50
  222. package/src/lib/modules/errors/errors-routing.module.ts +0 -40
  223. package/src/lib/modules/errors/errors.component.html +0 -15
  224. package/src/lib/modules/errors/errors.component.scss +0 -4
  225. package/src/lib/modules/errors/errors.component.spec.ts +0 -25
  226. package/src/lib/modules/errors/errors.component.ts +0 -42
  227. package/src/lib/modules/errors/errors.module.ts +0 -25
  228. package/src/lib/modules/errors/invalid-ip/invalid-ip.component.html +0 -16
  229. package/src/lib/modules/errors/invalid-ip/invalid-ip.component.scss +0 -0
  230. package/src/lib/modules/errors/invalid-ip/invalid-ip.component.spec.ts +0 -23
  231. package/src/lib/modules/errors/invalid-ip/invalid-ip.component.ts +0 -43
  232. package/src/lib/modules/intro/contact-support/contact-support.component.html +0 -30
  233. package/src/lib/modules/intro/contact-support/contact-support.component.scss +0 -60
  234. package/src/lib/modules/intro/contact-support/contact-support.component.spec.ts +0 -23
  235. package/src/lib/modules/intro/contact-support/contact-support.component.ts +0 -17
  236. package/src/lib/modules/intro/intro-routing.module.ts +0 -16
  237. package/src/lib/modules/intro/intro.module.ts +0 -21
  238. package/src/lib/modules/intro/lead-intro/lead-intro.component.html +0 -325
  239. package/src/lib/modules/intro/lead-intro/lead-intro.component.scss +0 -185
  240. package/src/lib/modules/intro/lead-intro/lead-intro.component.spec.ts +0 -23
  241. package/src/lib/modules/intro/lead-intro/lead-intro.component.ts +0 -120
  242. package/src/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.html +0 -44
  243. package/src/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.scss +0 -28
  244. package/src/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.spec.ts +0 -23
  245. package/src/lib/modules/layout/components/csm-assign-confirmation/csm-assign-confirmation.component.ts +0 -24
  246. package/src/lib/modules/layout/content/content.component.html +0 -12
  247. package/src/lib/modules/layout/content/content.component.scss +0 -0
  248. package/src/lib/modules/layout/content/content.component.ts +0 -102
  249. package/src/lib/modules/layout/footer/footer.component.html +0 -29
  250. package/src/lib/modules/layout/footer/footer.component.scss +0 -7
  251. package/src/lib/modules/layout/footer/footer.component.spec.ts +0 -25
  252. package/src/lib/modules/layout/footer/footer.component.ts +0 -13
  253. package/src/lib/modules/layout/header/header-menu/header-menu.component.html +0 -27
  254. package/src/lib/modules/layout/header/header-menu/header-menu.component.scss +0 -4
  255. package/src/lib/modules/layout/header/header-menu/header-menu.component.spec.ts +0 -25
  256. package/src/lib/modules/layout/header/header-menu/header-menu.component.ts +0 -38
  257. package/src/lib/modules/layout/header/header.component.html +0 -90
  258. package/src/lib/modules/layout/header/header.component.scss +0 -7
  259. package/src/lib/modules/layout/header/header.component.spec.ts +0 -25
  260. package/src/lib/modules/layout/header/header.component.ts +0 -139
  261. package/src/lib/modules/layout/header/navbar/navbar.component.html +0 -156
  262. package/src/lib/modules/layout/header/navbar/navbar.component.scss +0 -223
  263. package/src/lib/modules/layout/header/navbar/navbar.component.spec.ts +0 -23
  264. package/src/lib/modules/layout/header/navbar/navbar.component.ts +0 -255
  265. package/src/lib/modules/layout/header/notifications-inner/notifications-inner.component.html +0 -200
  266. package/src/lib/modules/layout/header/notifications-inner/notifications-inner.component.scss +0 -139
  267. package/src/lib/modules/layout/header/notifications-inner/notifications-inner.component.ts +0 -76
  268. package/src/lib/modules/layout/header/page-title/page-title.component.html +0 -32
  269. package/src/lib/modules/layout/header/page-title/page-title.component.scss +0 -11
  270. package/src/lib/modules/layout/header/page-title/page-title.component.ts +0 -47
  271. package/src/lib/modules/layout/keenicon/icons.json +0 -1
  272. package/src/lib/modules/layout/keenicon/keenicon.component.html +0 -4
  273. package/src/lib/modules/layout/keenicon/keenicon.component.scss +0 -0
  274. package/src/lib/modules/layout/keenicon/keenicon.component.spec.ts +0 -23
  275. package/src/lib/modules/layout/keenicon/keenicon.component.ts +0 -30
  276. package/src/lib/modules/layout/layout/layout.component.html +0 -71
  277. package/src/lib/modules/layout/layout/layout.component.scss +0 -23
  278. package/src/lib/modules/layout/layout/layout.component.ts +0 -425
  279. package/src/lib/modules/layout/layout.module.ts +0 -127
  280. package/src/lib/modules/layout/scripts-init/scripts-init.component.html +0 -0
  281. package/src/lib/modules/layout/scripts-init/scripts-init.component.ts +0 -81
  282. package/src/lib/modules/layout/scroll-top/scroll-top.component.html +0 -1
  283. package/src/lib/modules/layout/scroll-top/scroll-top.component.ts +0 -75
  284. package/src/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.html +0 -70
  285. package/src/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.scss +0 -57
  286. package/src/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.spec.ts +0 -23
  287. package/src/lib/modules/layout/sidebar/sidebar-footer/sidebar-footer.component.ts +0 -101
  288. package/src/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.html +0 -26
  289. package/src/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.scss +0 -0
  290. package/src/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.spec.ts +0 -23
  291. package/src/lib/modules/layout/sidebar/sidebar-logo/sidebar-logo.component.ts +0 -36
  292. package/src/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.html +0 -705
  293. package/src/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.scss +0 -38
  294. package/src/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.spec.ts +0 -23
  295. package/src/lib/modules/layout/sidebar/sidebar-menu/sidebar-menu.component.ts +0 -118
  296. package/src/lib/modules/layout/sidebar/sidebar.component.html +0 -16
  297. package/src/lib/modules/layout/sidebar/sidebar.component.scss +0 -3
  298. package/src/lib/modules/layout/sidebar/sidebar.component.spec.ts +0 -23
  299. package/src/lib/modules/layout/sidebar/sidebar.component.ts +0 -203
  300. package/src/lib/modules/layout/toolbar/accounting/accounting.component.html +0 -84
  301. package/src/lib/modules/layout/toolbar/accounting/accounting.component.scss +0 -0
  302. package/src/lib/modules/layout/toolbar/accounting/accounting.component.spec.ts +0 -23
  303. package/src/lib/modules/layout/toolbar/accounting/accounting.component.ts +0 -14
  304. package/src/lib/modules/layout/toolbar/classic/classic.component.html +0 -69
  305. package/src/lib/modules/layout/toolbar/classic/classic.component.scss +0 -238
  306. package/src/lib/modules/layout/toolbar/classic/classic.component.spec.ts +0 -23
  307. package/src/lib/modules/layout/toolbar/classic/classic.component.ts +0 -389
  308. package/src/lib/modules/layout/toolbar/client-settings/client-settings.component.html +0 -4
  309. package/src/lib/modules/layout/toolbar/client-settings/client-settings.component.scss +0 -3
  310. package/src/lib/modules/layout/toolbar/client-settings/client-settings.component.spec.ts +0 -23
  311. package/src/lib/modules/layout/toolbar/client-settings/client-settings.component.ts +0 -91
  312. package/src/lib/modules/layout/toolbar/date-single-select/date-single-select.component.html +0 -22
  313. package/src/lib/modules/layout/toolbar/date-single-select/date-single-select.component.scss +0 -156
  314. package/src/lib/modules/layout/toolbar/date-single-select/date-single-select.component.spec.ts +0 -23
  315. package/src/lib/modules/layout/toolbar/date-single-select/date-single-select.component.ts +0 -229
  316. package/src/lib/modules/layout/toolbar/datepicker/datepicker.component.html +0 -14
  317. package/src/lib/modules/layout/toolbar/datepicker/datepicker.component.scss +0 -149
  318. package/src/lib/modules/layout/toolbar/datepicker/datepicker.component.spec.ts +0 -23
  319. package/src/lib/modules/layout/toolbar/datepicker/datepicker.component.ts +0 -174
  320. package/src/lib/modules/layout/toolbar/extended/extended.component.html +0 -100
  321. package/src/lib/modules/layout/toolbar/extended/extended.component.scss +0 -0
  322. package/src/lib/modules/layout/toolbar/extended/extended.component.spec.ts +0 -23
  323. package/src/lib/modules/layout/toolbar/extended/extended.component.ts +0 -12
  324. package/src/lib/modules/layout/toolbar/metrics-header/metrics-header.component.html +0 -311
  325. package/src/lib/modules/layout/toolbar/metrics-header/metrics-header.component.scss +0 -311
  326. package/src/lib/modules/layout/toolbar/metrics-header/metrics-header.component.spec.ts +0 -23
  327. package/src/lib/modules/layout/toolbar/metrics-header/metrics-header.component.ts +0 -1555
  328. package/src/lib/modules/layout/toolbar/reports/reports.component.html +0 -62
  329. package/src/lib/modules/layout/toolbar/reports/reports.component.scss +0 -0
  330. package/src/lib/modules/layout/toolbar/reports/reports.component.spec.ts +0 -23
  331. package/src/lib/modules/layout/toolbar/reports/reports.component.ts +0 -14
  332. package/src/lib/modules/layout/toolbar/saas/saas.component.html +0 -77
  333. package/src/lib/modules/layout/toolbar/saas/saas.component.scss +0 -0
  334. package/src/lib/modules/layout/toolbar/saas/saas.component.spec.ts +0 -23
  335. package/src/lib/modules/layout/toolbar/saas/saas.component.ts +0 -14
  336. package/src/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.html +0 -1
  337. package/src/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.scss +0 -0
  338. package/src/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.spec.ts +0 -23
  339. package/src/lib/modules/layout/toolbar/single-clientstore-date/single-clientstore-date.component.ts +0 -10
  340. package/src/lib/modules/layout/toolbar/single-store/single-store.component.html +0 -39
  341. package/src/lib/modules/layout/toolbar/single-store/single-store.component.scss +0 -172
  342. package/src/lib/modules/layout/toolbar/single-store/single-store.component.spec.ts +0 -23
  343. package/src/lib/modules/layout/toolbar/single-store/single-store.component.ts +0 -186
  344. package/src/lib/modules/layout/toolbar/single-storedate/single-storedate.component.html +0 -17
  345. package/src/lib/modules/layout/toolbar/single-storedate/single-storedate.component.scss +0 -172
  346. package/src/lib/modules/layout/toolbar/single-storedate/single-storedate.component.spec.ts +0 -23
  347. package/src/lib/modules/layout/toolbar/single-storedate/single-storedate.component.ts +0 -179
  348. package/src/lib/modules/layout/toolbar/storesingle/storesingle.component.html +0 -4
  349. package/src/lib/modules/layout/toolbar/storesingle/storesingle.component.scss +0 -19
  350. package/src/lib/modules/layout/toolbar/storesingle/storesingle.component.spec.ts +0 -23
  351. package/src/lib/modules/layout/toolbar/storesingle/storesingle.component.ts +0 -105
  352. package/src/lib/modules/layout/toolbar/toolbar.component.html +0 -56
  353. package/src/lib/modules/layout/toolbar/toolbar.component.scss +0 -0
  354. package/src/lib/modules/layout/toolbar/toolbar.component.spec.ts +0 -25
  355. package/src/lib/modules/layout/toolbar/toolbar.component.ts +0 -352
  356. package/src/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.html +0 -259
  357. package/src/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.scss +0 -311
  358. package/src/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.spec.ts +0 -23
  359. package/src/lib/modules/layout/toolbar/traffic-header/traffic-header/traffic-header.component.ts +0 -1200
  360. package/src/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.html +0 -199
  361. package/src/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.scss +0 -311
  362. package/src/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.spec.ts +0 -23
  363. package/src/lib/modules/layout/toolbar/traffic-nob/traffic-nob.component.ts +0 -899
  364. package/src/lib/modules/layout/toolbar/trax-header/trax-header.component.html +0 -204
  365. package/src/lib/modules/layout/toolbar/trax-header/trax-header.component.scss +0 -311
  366. package/src/lib/modules/layout/toolbar/trax-header/trax-header.component.spec.ts +0 -23
  367. package/src/lib/modules/layout/toolbar/trax-header/trax-header.component.ts +0 -1045
  368. package/src/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.html +0 -190
  369. package/src/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.scss +0 -311
  370. package/src/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.spec.ts +0 -23
  371. package/src/lib/modules/layout/toolbar/trax-withoutdate/trax-withoutdate.component.ts +0 -825
  372. package/src/lib/modules/notification/conformation/conformation.component.html +0 -25
  373. package/src/lib/modules/notification/conformation/conformation.component.scss +0 -0
  374. package/src/lib/modules/notification/conformation/conformation.component.spec.ts +0 -23
  375. package/src/lib/modules/notification/conformation/conformation.component.ts +0 -23
  376. package/src/lib/modules/notification/notification/notification.component.html +0 -209
  377. package/src/lib/modules/notification/notification/notification.component.scss +0 -211
  378. package/src/lib/modules/notification/notification/notification.component.spec.ts +0 -23
  379. package/src/lib/modules/notification/notification/notification.component.ts +0 -310
  380. package/src/lib/modules/notification/notification-routing.module.ts +0 -20
  381. package/src/lib/modules/notification/notification.module.ts +0 -21
  382. package/src/lib/pipes/customDate.pipe.ts +0 -18
  383. package/src/lib/routes/route-wraper-modules/analyse-wrapper.module.ts +0 -12
  384. package/src/lib/routes/route-wraper-modules/edge-wrapper.module.ts +0 -11
  385. package/src/lib/routes/route-wraper-modules/manage-wrapper.module.ts +0 -11
  386. package/src/lib/routes/route-wraper-modules/profile-wrapper.module.ts +0 -12
  387. package/src/lib/routes/route-wraper-modules/store-wrapper.module.ts +0 -11
  388. package/src/lib/routes/route-wraper-modules/ticket-wrapper.module.ts +0 -10
  389. package/src/lib/routes/routing.ts +0 -56
  390. package/src/lib/services/auth.service.ts +0 -173
  391. package/src/lib/services/notification.service.spec.ts +0 -16
  392. package/src/lib/services/notification.service.ts +0 -73
  393. package/src/lib/services/toast.service.ts +0 -82
  394. package/tsconfig.lib.json +0 -14
  395. package/tsconfig.lib.prod.json +0 -10
  396. package/tsconfig.spec.json +0 -14
@@ -1,1200 +0,0 @@
1
- import {
2
- ChangeDetectorRef,
3
- Component,
4
- HostListener,
5
- OnInit,
6
- } from "@angular/core";
7
- import dayjs from "dayjs";
8
- import "dayjs/locale/en";
9
- import { AuthService } from "../../../../../services/auth.service";
10
- import { GlobalStateService } from "tango-app-ui-global";
11
- import { NavigationEnd, Router } from "@angular/router";
12
- @Component({
13
- selector: "lib-traffic-header",
14
- templateUrl: "./traffic-header.component.html",
15
- styleUrl: "./traffic-header.component.scss",
16
- })
17
- export class TrafficHeaderComponent implements OnInit {
18
- dayjs = dayjs;
19
- isCustomDate = (m: dayjs.Dayjs) => {
20
- const isValidDate = m > this.dayjs();
21
- return isValidDate ? "invalid-date" : false;
22
- };
23
-
24
- selectedDateRange: any = { startDate: dayjs().subtract(30, 'days'),
25
- endDate: dayjs().subtract(1, "days"),};
26
- selectedFilters: any = {
27
- client: null,
28
- clientName: null,
29
- clients: [],
30
- store: null,
31
- stores: [],
32
- date: null,
33
- group: [],
34
- location: [],
35
- country: [],
36
- };
37
- Opendropdown: boolean = false;
38
- dropdownOpen: string | null = null; // 'location' or 'group'
39
- searchLocationText: string = "";
40
- searchGroupText: string = "";
41
- locations: any[] = [];
42
- filteredLocations: any[] = [];
43
- groupsData: any[] = [];
44
- filteredGroups: any[] = [];
45
- filteredStores: any[] = [];
46
- stores:any[] = []
47
- searchStoreText:string = '';
48
- clientList:any = []
49
- selectedClient:any
50
- locationLabel: any[]=[];
51
- groupLabel: any[]=[];
52
- users: any;
53
- url: any;
54
- filteredCountries: any[] = [];
55
- countryLabel: any[]=[];
56
- searchCountryText: string = "";
57
- countries: any[] = [];
58
- constructor(
59
- private auth: AuthService, private router: Router,
60
- public gs: GlobalStateService,
61
- private cd: ChangeDetectorRef,
62
- ) {}
63
-
64
- @HostListener('document:click', ['$event'])
65
- onClick (event: MouseEvent) {
66
- const target = event.target as HTMLElement;
67
- if(!target.closest('.dropdown2')) {
68
- this.Opendropdown = false;
69
- }
70
- }
71
- closeDropdown1(){
72
- this.Opendropdown = false;
73
- }
74
- ngOnInit(): void {
75
- // this.setRangesBasedOnRoute();
76
-
77
- // Listen for route changes to update ranges
78
- // this.router?.events?.subscribe((event) => {
79
- // if (event instanceof NavigationEnd) {
80
- // this.setRangesBasedOnRoute();
81
- // }
82
- // });
83
- this.url = this.router.url.split("?")[0].split('/');
84
- const user = JSON.parse(localStorage.getItem('user-info') as string);
85
- this.users = user;
86
- this.gs?.manageRefreshTrigger?.subscribe((e) => {
87
- if (e) {
88
- if (user.userType === 'tango') {
89
- this.getClient();
90
- } else{
91
- const storedFilters = localStorage.getItem("header-filters");
92
- if (storedFilters) {
93
- const headerFilters = JSON.parse(storedFilters);
94
- this.filteredStores = headerFilters?.stores.map((store:any) => ({
95
- ...store,
96
- checked: store.checked
97
- }));
98
- }
99
- }
100
- }
101
- });
102
-
103
- // Fetch client data if the user is of type 'tango'
104
- if (user.userType === 'tango') {
105
- this.getClient();
106
- } else {
107
- this.getCountry();
108
- this.getLocations();
109
- this.getGroups();
110
- this.getStore();
111
- const clientFilters = localStorage.getItem("client-details");
112
- if (clientFilters) {
113
- const headerclientFilters = JSON.parse(clientFilters);
114
- this.selectedClient = {
115
- trafficDateRange : headerclientFilters.trafficDateRange
116
- }
117
- }
118
- }
119
-
120
- // Load filters from localStorage if they exist
121
- const storedFilters = localStorage.getItem("header-filters");
122
- if (storedFilters) {
123
- const headerFilters = JSON.parse(storedFilters);
124
-
125
- // Initialize selectedFilters with defaults or existing values
126
- this.selectedFilters = {
127
- client: headerFilters.client || this.users.client,
128
- clientName: headerFilters.clientName || '',
129
- clients: headerFilters.clients || [],
130
- store: headerFilters.store || null,
131
- date: headerFilters.date || {},
132
- stores: headerFilters.stores || [],
133
- group: headerFilters.group || [],
134
- location: headerFilters.location || [],
135
- country: headerFilters.country || []
136
- };
137
-
138
- // Sync filtered data with stored selections
139
- this.filteredCountries = this.syncWithLocalStorage(headerFilters.country);
140
- this.filteredLocations = this.syncWithLocalStorage(headerFilters.location);
141
- this.filteredGroups = this.syncWithLocalStorage(headerFilters.group);
142
- this.filteredStores = this.syncWithLocalStorage(headerFilters.stores);
143
-
144
- // Format date range if it exists
145
- if (headerFilters.date) {
146
-
147
- this.selectedDateRange = {
148
- startDate: this.dayjs(headerFilters.date.startDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
149
- endDate: this.dayjs(headerFilters.date.endDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
150
- };
151
- } else {
152
- this.selectedDateRange = {
153
- startDate: this.dayjs(this.selectedDateRange.startDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
154
- endDate: this.dayjs(this.selectedDateRange.endDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
155
- };
156
- }
157
- // console.log("3")
158
- // Emit data via service and update localStorage
159
- this.emitAndStoreFilters();
160
- } else {
161
- // Initialize empty states if no header filters are present in localStorage
162
- this.resetFilters();
163
- // console.log("2")
164
- }
165
- }
166
- private syncWithLocalStorage(items: any[]): any[] {
167
- return items
168
- ? items.map((item: any) => ({
169
- ...item,
170
- checked: item.checked === true
171
- }))
172
- : [];
173
- }
174
-
175
- private emitAndStoreFilters(): void {
176
- this.gs.dataRangeValue.next(this.selectedFilters);
177
- localStorage.setItem("header-filters", JSON.stringify(this.selectedFilters));
178
- // console.log("1")
179
- }
180
-
181
- /**
182
- * Reset selectedFilters and all related arrays to empty states
183
- */
184
- private resetFilters(): void {
185
- this.selectedFilters = {
186
- client: null,
187
- clientName: '',
188
- clients: [],
189
- store: null,
190
- date: {},
191
- stores: [],
192
- group: [],
193
- location: [],
194
- country: []
195
- };
196
- this.filteredLocations = [];
197
- this.filteredGroups = [];
198
- this.filteredStores = [];
199
- this.filteredCountries = [];
200
- }
201
- getClient(){
202
- this.auth.getClients().subscribe({
203
- next: (e) => {
204
- if (e) {
205
- this.clientList = e.data.result;
206
- const headerFilters: any = JSON.parse(
207
- localStorage.getItem("header-filters") || "{}"
208
- );
209
- if (headerFilters.client) {
210
- this.clientList.find((obj: any) => {
211
- if (obj.clientId === headerFilters.client) {
212
- this.selectedClient = obj;
213
- }
214
- });
215
- // const startDate = this.dayjs(headerFilters.date.startDate);
216
- // const endDate = this.dayjs(headerFilters.date.endDate);
217
- // const differenceInDays = endDate.diff(startDate, 'days');
218
- // if (differenceInDays >= 90 && this.selectedClient?.trafficDateRange === 90) {
219
- // this.selectedDateRange = {
220
- // startDate: this.dayjs(headerFilters.date.startDate, "YYYY-MM-DD").subtract(-90, 'days').format("DD-MM-YYYY"),
221
- // endDate: this.dayjs(headerFilters.date.endDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
222
- // };
223
- // } else {
224
- // this.selectedDateRange = {
225
- // startDate: this.dayjs(this.selectedDateRange.startDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
226
- // endDate: this.dayjs(this.selectedDateRange.endDate, "YYYY-MM-DD").format("DD-MM-YYYY"),
227
- // };
228
- // }
229
- this.selectedFilters.client = headerFilters.client;
230
- this.selectedFilters.clientName = headerFilters.clientName;
231
- this.selectedFilters.clients = headerFilters.clients;
232
- this.selectedFilters.store = headerFilters.store;
233
- this.selectedFilters.date = headerFilters.date;
234
- this.selectedFilters.stores = headerFilters.stores;
235
- this.selectedFilters.group = headerFilters.group;
236
- this.selectedFilters.location = headerFilters.location;
237
- this.selectedFilters.country = headerFilters.country;
238
- this.gs.dataRangeValue.next(this.selectedFilters);
239
- // console.log("2")
240
- // Ensure locations and groups are loaded before fetching stores
241
- this.getCountry();
242
- this.getLocations();
243
- this.getGroups();
244
- // Fetch stores only after locations and groups are set
245
- this.getStore();
246
- } else {
247
- this.selectedClient = this.clientList[0];
248
- this.selectedFilters.client = this.selectedClient.clientId;
249
- this.selectedFilters.clientName = this.selectedClient.clientName
250
- this.selectedFilters.clients = headerFilters.clients;
251
- this.selectedFilters.store = headerFilters.store;
252
- this.selectedFilters.date = headerFilters.date;
253
- this.selectedFilters.stores = headerFilters.stores;
254
- this.selectedFilters.group = headerFilters.group;
255
- this.selectedFilters.location = headerFilters.location;
256
- this.selectedFilters.country = headerFilters.country;
257
- localStorage.setItem(
258
- "header-filters",
259
- JSON.stringify(this.selectedFilters)
260
- );
261
- this.gs.dataRangeValue.next(this.selectedFilters);
262
- // console.log("3")
263
- this.cd.detectChanges();
264
- // Ensure locations and groups are loaded before fetching stores
265
- this.getCountry();
266
- this.getLocations();
267
- this.getGroups();
268
- // Fetch stores only after locations and groups are set
269
- this.getStore();
270
- }
271
-
272
-
273
- } else {
274
- this.selectedClient = this.clientList[0];
275
- this.selectedFilters.client = this.selectedClient.clientId;
276
- this.selectedFilters.clientName = this.selectedClient.clientName
277
- // Ensure locations and groups are loaded before fetching stores
278
- this.getCountry();
279
- this.getLocations();
280
- this.getGroups();
281
- // Fetch stores only after locations and groups are set
282
- this.getStore();
283
- localStorage.setItem(
284
- "header-filters",
285
- JSON.stringify(this.selectedFilters)
286
- );
287
- this.gs.dataRangeValue.next(this.selectedFilters);
288
- // console.log("4")
289
- this.cd.detectChanges();
290
- }
291
- this.getUserInfo(this.selectedFilters.client);
292
-
293
- },
294
- });
295
- }
296
- getUserInfo(client:any){
297
- let obj ={
298
- clientId: client ? client :''
299
- }
300
- if(client){
301
- this.auth.getHeaderUsers(obj).subscribe({
302
- next: (e) => {
303
- localStorage.setItem(
304
- "usersEmail-info",
305
- JSON.stringify(e?.data?.userEmailData || [])
306
- );
307
- }
308
- })
309
- }
310
- }
311
- onClientSelect(event: any): void {
312
- // Update the selected client
313
- this.selectedClient = event;
314
- // Clear previous filtered data and selections
315
- this.filteredGroups = [];
316
- this.filteredStores = [];
317
- this.filteredLocations = [];
318
- this.selectedFilters.stores = [];
319
- this.selectedFilters.group = [];
320
- this.selectedFilters.location = [];
321
- this.selectedFilters.country = [];
322
-
323
-
324
- // Fetch header filters from localStorage
325
- const headerFilters: any = JSON.parse(localStorage.getItem("header-filters") || "{}");
326
-
327
- // Update the selected filters with the new client
328
- this.selectedFilters.client = this.selectedClient.clientId;
329
- this.selectedFilters.clientName = this.selectedClient.clientName;
330
-
331
- // Remove old store, group, and location data from the header filters
332
- delete headerFilters.stores;
333
- delete headerFilters.groups;
334
- delete headerFilters.location;
335
- delete headerFilters.country;
336
-
337
-
338
- // Fetch new data based on the new client
339
- this.getCountry();
340
- this.getLocations();
341
- this.getStore();
342
- this.getGroups();
343
-
344
- // Update localStorage with the new client selection and empty filter data
345
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
346
- window.location.reload()
347
- // Emit data to the global service
348
- // this.gs.dataRangeValue.next(this.selectedFilters);
349
- // Trigger change detection to reflect UI changes
350
- this.cd.detectChanges();
351
- }
352
-
353
-
354
-
355
- ranges:any = {
356
- Today: [dayjs(), dayjs()],
357
- Yesterday: [dayjs().subtract(1, 'days'), dayjs().subtract(1, 'days')],
358
- 'This Week': [dayjs().subtract(7, 'days'), dayjs().subtract(1, 'days')],
359
- 'Last Week': [
360
- dayjs().subtract(14, 'days').startOf('day'),
361
- dayjs().subtract(8, 'days').endOf('day'),
362
- ],
363
- 'This Month': [dayjs().subtract(30, 'days'), dayjs().subtract(1, 'days')],
364
- 'Last Month': [
365
- dayjs().subtract(1, 'month').startOf('month'),
366
- dayjs().subtract(1, 'month').endOf('month'),
367
- ],
368
- };
369
-
370
- onStartDateChange(event: any) {
371
- if (this.dayjs(event.startDate).isValid()) {
372
- if(this.selectedClient?.traxDateRange === 90){
373
- this.isCustomDate = (m: dayjs.Dayjs) => {
374
- const isValidDate =
375
- m > this.dayjs() || m > this.dayjs(event.startDate.add(90, "days"));
376
- return isValidDate ? "invalid-date" : false;
377
- };
378
- } else {
379
- this.isCustomDate = (m: dayjs.Dayjs) => {
380
- const isValidDate =
381
- m > this.dayjs() || m > this.dayjs(event.startDate.add(180, "days"));
382
- return isValidDate ? "invalid-date" : false;
383
- };
384
- }
385
-
386
- }
387
- }
388
-
389
- datechange(event: any) {
390
- if (event && event.startDate && event.endDate) {
391
- if (
392
- this.dayjs(event.startDate).isValid() &&
393
- this.dayjs(event.endDate).isValid()
394
- ) {
395
- this.selectedDateRange.startDate = event.startDate;
396
- this.selectedDateRange.endDate = event.endDate;
397
- var datetime = {
398
- startDate: this.dayjs(event.startDate, "DD-MM-YYYY").format(
399
- "YYYY-MM-DD"
400
- ),
401
- endDate: this.dayjs(event.endDate, "DD-MM-YYYY").format("YYYY-MM-DD"),
402
- };
403
- this.selectedFilters.date = datetime;
404
- localStorage.setItem(
405
- "header-filters",
406
- JSON.stringify(this.selectedFilters)
407
- );
408
- window.location.reload()
409
- // this.gs.dataRangeValue.next(this.selectedFilters);
410
- }
411
- }
412
- }
413
- opendropdown(e:MouseEvent) {
414
- e.stopPropagation();
415
- this.Opendropdown = !this.Opendropdown;
416
- }
417
- getLocations(): void {
418
- const country = this.countries
419
- .filter(country => country.checked)
420
- .map(country => country.country);
421
- // const headerFilters: any = JSON.parse(localStorage.getItem("header-filters") || "{}");
422
- let obj ={
423
- clientId: this.selectedFilters.client ? this.selectedFilters.client :this.users.clientId,
424
- country,
425
- city: [],
426
- group: [],
427
- }
428
- this.auth.getLocation(obj).subscribe({
429
- next: (res: any) => {
430
- let cityList = this.selectedFilters?.location?.filter((location:any) => location.checked).map((loc:any) => loc.city);
431
- // Map the fetched locations with default unchecked state
432
- this.locations = res?.data?.locationData.map((city: any) => ({
433
- city: city.city,
434
- // checked: cityList?.length ? cityList.includes(city.city) : true,
435
- checked: cityList?.includes(city.city) ? true : false,
436
- }));
437
-
438
- // Sync the fetched locations with any stored checked values in localStorage
439
- if (this.selectedFilters.location && Array.isArray(this.selectedFilters.location)) {
440
- this.filteredLocations = this.locations.map(location => {
441
- const matchedLocation = this.selectedFilters.location.find((loc: any) => loc.city === location.city);
442
- return matchedLocation ? { ...location, checked: matchedLocation.checked } : location;
443
- });
444
- } else {
445
- this.filteredLocations = this.locations;
446
- }
447
-
448
- if(this.searchLocationText) {
449
- this.filteredLocations = this.locations.filter((location:any) => location.city.toLowerCase().includes(this.searchLocationText.toLowerCase()))
450
- }
451
- const selectedLocations = this.locations.filter((location) => location.checked).map((location) => location.city);
452
- if (selectedLocations.length > 0) {
453
- setTimeout(()=>{
454
- this.getGroups();
455
- this.getStore(); // Fetch stores based on selected groups
456
- },1000)
457
- }
458
-
459
- if(!selectedLocations.length && country.length) {
460
- this.getGroups();
461
- }
462
- },
463
- error: (err) => {
464
- console.error("Failed to fetch locations", err);
465
- },
466
- });
467
- }
468
-
469
- isAllLocationsSelected(): boolean {
470
- return this.filteredLocations.every(location => location.checked);
471
-
472
- }
473
-
474
- selectedLocationsLabel(): string {
475
- const selectedLocations = this.locationLabel = this.searchLocationText.length ? this.locations
476
- .filter(location => location.checked).map(location => location.city) : this.filteredLocations
477
- .filter(location => location.checked).map(location => location.city);
478
- return selectedLocations.length === 0
479
- ? ''
480
- : selectedLocations.length === 1
481
- ? selectedLocations[0]
482
- : `${selectedLocations.length} locations`;
483
- }
484
-
485
- removeLocation(): void {
486
- this.Reset();
487
- }
488
-
489
- getGroups(): void {
490
- const country = this.countries
491
- .filter(country => country.checked)
492
- .map(country => country.country);
493
- let city;
494
- city = this.locations
495
- .filter(location => location.checked)
496
- .map(location => location.city);
497
-
498
- if(!city.length && country.length) {
499
- city = this.locations.map((loc) => loc.city);
500
- }
501
- const obj = { country,city,clientId:this.selectedFilters.client ? this.selectedFilters.client :this.users.clientId,group:[] };
502
- this.auth.getGroups(obj).subscribe({
503
- next: (res: any) => {
504
- let checkedGroup = this.selectedFilters?.group?.filter((group:any) => group.checked).map((group:any) => group.groupName);
505
- const combinedGroups = res?.data?.groupData?.map((groupName: any) => ({
506
- groupName: groupName.groupName,
507
- checked: checkedGroup?.includes(groupName.groupName) ? true : false,
508
- // checked: checkedGroup?.length ? checkedGroup.includes(groupName.groupName) : true,
509
- }));
510
- this.groupsData = combinedGroups;
511
- if(this.searchGroupText.length) {
512
- this.filteredGroups = combinedGroups.filter((item:any) => item.groupName.toLowerCase().includes(this.searchGroupText));
513
- }
514
- else {
515
- this.filteredGroups = combinedGroups;
516
- }
517
-
518
- // Auto-fetch stores when groups are selected
519
- const selectedGroups = this.groupsData.filter((group) => group.checked).map((group) => group.groupName);
520
- if (selectedGroups.length > 0) {
521
- setTimeout(()=>{
522
- this.getStore(); // Fetch stores based on selected groups
523
- },1000)
524
- }
525
- },
526
- error: (err) => {
527
- console.error("Failed to fetch groups", err);
528
- },
529
- });
530
- }
531
-
532
- toggleDropdown(type: 'country' | 'location' | 'group' | 'store'): void {
533
- if (this.dropdownOpen === type) {
534
- // If the dropdown is open, close it and avoid resetting the selected values unnecessarily
535
- this.dropdownOpen = null;
536
- } else {
537
- // Open the specific dropdown and handle data fetching only if necessary
538
- this.dropdownOpen = type;
539
-
540
- if (type === 'country') {
541
- // Fetch countries only if not already fetched and no search text exists
542
- if ((!this.filteredCountries || this.filteredCountries.length === 0) && !this.searchCountryText.trim()) {
543
- this.getCountry();
544
- }
545
- }
546
-
547
- if (type === 'group') {
548
- // Fetch groups only if there are selected cities and no active search text
549
- const selectedCities = this.locations
550
- .filter((location) => location.checked)
551
- .map((location) => location.city);
552
-
553
- // Fetch groups only if locations are selected, no search text exists, and dropdown is opened
554
- if (this.filteredLocations.length > 0 || (selectedCities.length > 0 && !this.searchGroupText.trim())) {
555
- this.getGroups();
556
- } else {
557
- this.filteredGroups = []; // Clear groups if no locations are selected
558
- }
559
- }
560
-
561
- if (type === 'store') {
562
- // Fetch stores only if not already fetched and no search text is active
563
- if ((!this.filteredStores || this.filteredStores.length === 0) && !this.searchStoreText.trim()) {
564
- this.getStore();
565
- }
566
- }
567
- }
568
- }
569
-
570
-
571
- handleGroupDropdownClick(): void {
572
- if (this.dropdownOpen === 'group') {
573
- this.resetSelectedGroups();
574
- }
575
- this.toggleDropdown('group');
576
- }
577
-
578
- resetSelectedGroups(): void {
579
- this.filteredGroups.forEach((group) => (group.checked = false));
580
- this.searchGroupText = "";
581
- }
582
- selectedGroupsLabel(): string {
583
- const selectedGroups = this.groupLabel = this.searchGroupText.length ? this.groupsData.filter((group) => group.checked) : this.filteredGroups.filter((group) => group.checked);
584
- return selectedGroups.length === 0
585
- ? ""
586
- : selectedGroups.length === 1
587
- ? selectedGroups[0].groupName
588
- : `${selectedGroups.length} Clusters`;
589
- }
590
- removeGroup(): void {
591
- this.Reset();
592
-
593
- }
594
-
595
-
596
- isAllGroupsSelected(): boolean {
597
-
598
- return this.filteredGroups.length ? this.filteredGroups.every((group) => group.checked) : false;
599
- }
600
-
601
- getStore(): void {
602
- const country = this.countries
603
- .filter(country => country.checked)
604
- .map(country => country.country);
605
- const city = this.locations
606
- .filter(location => location.checked)
607
- .map(location => location.city);
608
- const group = this.groupsData
609
- .filter(group => group.checked)
610
- .map(group => group.groupName);
611
-
612
- const data = {
613
- country,
614
- city,
615
- clusters: group,
616
- clientId: this.users.clientId || this.selectedFilters.client
617
- };
618
-
619
- this.auth.getHeaderStores(data).subscribe({
620
- next: (res: any) => {
621
- if (res && res.code === 200) {
622
- // Initialize stores from API response
623
- this.stores = res.data.storesData;
624
- // Check if there are previously selected stores
625
- const checkedStoreIds = this.selectedFilters?.stores
626
- ? this.selectedFilters.stores.filter((store:any) => store.checked).map((store:any) => store.storeId)
627
- : [];
628
- // Sync the `checked` state
629
- this.stores.forEach(store => {
630
- store.checked = checkedStoreIds.length
631
- ? checkedStoreIds.includes(store.storeId) // Use previous selection
632
- : true; // Default to true if no previous selection
633
- });
634
-
635
- // Apply search filter if search text is present
636
- if (this.searchStoreText.length) {
637
- this.filteredStores = this.stores.filter(store =>
638
- store.storeName.toLowerCase().includes(this.searchStoreText.toLowerCase())
639
- );
640
- } else {
641
- this.filteredStores = [...this.stores];
642
- }
643
-
644
- // Update `selectedFilters.stores` to reflect the current state
645
- this.selectedFilters.stores = this.filteredStores.map(store => ({
646
- storeId: store.storeId,
647
- storeName: store.storeName,
648
- checked: store.checked
649
- }));
650
- // this.selectedFilters.country = country;
651
-
652
- // Save updated filters to localStorage
653
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
654
-
655
- // Trigger UI change detection
656
- this.cd.detectChanges();
657
- } else {
658
- // Handle empty or error response
659
- this.clearStoresState();
660
- }
661
- },
662
- error: (err) => {
663
- console.error("Failed to fetch stores", err);
664
- this.clearStoresState();
665
- }
666
- });
667
- }
668
-
669
- // Clear stores state and reset filters
670
- private clearStoresState(): void {
671
- this.stores = [];
672
- this.filteredStores = [];
673
- this.selectedFilters.stores = [];
674
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
675
- }
676
-
677
- resetSelectedStores(): void {
678
- this.filteredStores.forEach((store) => (store.checked = false));
679
- this.searchStoreText = "";
680
- }
681
-
682
- selectedStoresLabel(): string {
683
- const selectedStores = this.searchStoreText.length ? this.stores.filter((store) => store.checked) : this.filteredStores.filter((store) => store.checked);
684
- return selectedStores.length === 0
685
- ? "0 Stores"
686
- : selectedStores.length === 1
687
- ? selectedStores[0].storeName
688
- : `${selectedStores.length} Stores`;
689
- }
690
-
691
- isAllStoresSelected(): boolean {
692
- return this.filteredStores.length > 0 && this.filteredStores.every(store => store.checked);
693
- }
694
- // Method to handle dropdown item selection
695
- updateSelectedStores(): void {
696
- this.filteredStores.forEach(store => {
697
- const filteredStore = this.stores.findIndex(fStore => fStore.storeId === store.storeId);
698
- if (filteredStore != -1) {
699
- this.stores[filteredStore].checked = store.checked; // Sync the checked state with full store list
700
- }
701
- });
702
- // Update selectedFilters based on the current store selection
703
- this.selectedFilters.stores = this.stores.filter(store => store.checked);
704
-
705
- // Update localStorage with the latest selection
706
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
707
-
708
- // Emit updated filters via service
709
- // this.gs.dataRangeValue.next(this.selectedFilters);
710
-
711
- // Trigger change detection if necessary
712
- this.cd.detectChanges();
713
- }
714
- toggleSelectAllLocations(event: any): void {
715
- const isChecked = event.target.checked;
716
- this.filteredLocations.forEach((location) => (location.checked = isChecked));
717
- this.updateSelectedLocations();
718
- }
719
-
720
- toggleSelectAllStores(event: Event): void {
721
- const checked = (event.target as HTMLInputElement).checked;
722
-
723
- // Apply the selection to both filtered and full list of stores
724
- this.filteredStores.forEach(store => store.checked = checked);
725
- this.stores.forEach(store => {
726
- const filteredStore = this.filteredStores.find(fStore => fStore.storeId === store.storeId);
727
- if (filteredStore) {
728
- store.checked = checked; // Sync the checked state with full store list
729
- }
730
- });
731
-
732
- // Update the selected stores and persist the selection
733
- this.updateSelectedStores();
734
- }
735
-
736
- updateSelectedLocations(): void {
737
- // When locations are selected, fetch the related groups
738
- const selectedCities = this.filteredLocations
739
- .filter((location) => location.checked)
740
- .map((location) => location.city);
741
- this.filteredLocations.forEach((location:any) => {
742
- let findLocationIndex = this.locations.findIndex((loc:any) => loc.city == location.city);
743
- if(findLocationIndex != -1) {
744
- this.locations[findLocationIndex].checked = location.checked;
745
- }
746
- })
747
- if (selectedCities.length > 0 || !selectedCities.length) {
748
- this.selectedFilters.stores =[];
749
- this.groupsData =[]
750
- this.getGroups(); // Fetch groups based on selected cities
751
- // If there are selected groups, fetch the stores based on selected groups
752
- this.getStore();
753
- this.selectedFilters.location = this.locations;
754
-
755
- } else {
756
- this.filteredGroups = []; // Clear groups if no locations are selected
757
- this.selectedFilters.location = [];
758
- }
759
-
760
- this.selectedFilters.group = [];
761
- this.filteredStores = []; // Reset stores as well
762
- this.searchGroupText = '';
763
- this.searchStoreText = '';
764
- // this.Opendropdown = false;
765
- }
766
-
767
- toggleSelectAllGroups(event: any): void {
768
- const isChecked = event.target.checked;
769
- this.filteredGroups.forEach((group) => (group.checked = isChecked));
770
- this.updateSelectedGroups();
771
- }
772
-
773
- updateSelectedGroups(): void {
774
- // Fetch the relevant stores after groups are selected
775
- const selectedGroups = this.filteredGroups
776
- .filter((group) => group.checked)
777
- .map((group) => group.groupName);
778
-
779
- this.filteredGroups.forEach((group:any) => {
780
- let findGroupIndex = this.groupsData.findIndex((item:any) => item.groupName == group.groupName);
781
- if(findGroupIndex != -1) {
782
- this.groupsData[findGroupIndex].checked = group.checked;
783
- }
784
- })
785
- if (selectedGroups.length > 0 || !selectedGroups.length) {
786
- this.selectedFilters.stores =[];
787
- // If there are selected groups, fetch the stores based on selected groups
788
- this.getStore();
789
- this.selectedFilters.group = this.groupsData;
790
- } else {
791
- // If no groups are selected, clear the stores list
792
- this.filteredStores = [];
793
-
794
- // Also, update localStorage to reflect the cleared store selection
795
- this.selectedFilters.stores = [];
796
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
797
-
798
- // Emit data via service
799
- // this.gs.dataRangeValue.next(this.selectedFilters);
800
- }
801
-
802
- // Clear the search store text when groups are updated
803
- this.searchStoreText = '';
804
- }
805
-
806
-
807
- Reset(): void {
808
- setTimeout(()=>{
809
- // Clear selected groups, stores, and locations
810
- this.filteredCountries = []
811
- this.filteredGroups = [];
812
- this.filteredStores = [];
813
- this.filteredLocations = []; // Reset locations as well
814
- this.locations =[];this.groupsData =[]; this.stores =[];
815
- // Clear search input fields
816
- this.searchLocationText = "";
817
- this.searchGroupText = "";
818
- this.searchStoreText = "";
819
- this.selectedFilters.stores =[];
820
- this.selectedFilters.group =[];
821
- this.selectedFilters.location =[];
822
- this.selectedFilters.country =[];
823
-
824
-
825
- // Fetch locations, groups, and stores again
826
- this.getCountry();
827
- this.getLocations();
828
- this.getStore();
829
- this.getGroups();
830
- // Reset the filters in selectedFilters
831
-
832
-
833
- // // Once stores are fetched, mark all as checked
834
- // setTimeout(() => {
835
- // this.filteredStores = this.stores.map(store => ({
836
- // ...store,
837
- // checked: true // Mark all stores as checked
838
- // }));
839
-
840
- // // Sync selectedFilters with the updated store state
841
- // this.selectedFilters.stores = this.filteredStores.map(store => ({
842
- // ...store,
843
- // checked: true
844
- // }));
845
-
846
- // Update localStorage with the latest selectedFilters
847
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
848
- window.location.reload()
849
- // Emit the reset filters to update other components if needed
850
- // this.gs.dataRangeValue.next(this.selectedFilters);
851
- // Trigger change detection
852
- this.cd.detectChanges();
853
- // Adding a slight delay to ensure stores are fetched first
854
-
855
-
856
- // Close dropdown after reset if necessary
857
- this.Opendropdown = false;
858
- },100)
859
- }
860
-
861
-
862
-
863
-
864
- filterLocations(): void {
865
- const searchText = this.searchLocationText.toLowerCase();
866
-
867
- if (searchText) {
868
- // Preserve the checked state during filtering
869
- this.filteredLocations = this.locations
870
- .map(location => ({
871
- ...location,
872
- checked: this.filteredLocations.find(l => l.city === location.city)?.checked || false
873
- }))
874
- .filter(location =>
875
- location?.city?.toLowerCase().includes(searchText)
876
- );
877
- } else {
878
- // Restore the original checked state when search text is cleared
879
- this.filteredLocations = this.locations.map(location => ({
880
- ...location,
881
- checked: this.selectedFilters.location.find((l:any) => l.city === location.city)?.checked || false
882
- }));
883
- }
884
- }
885
-
886
-
887
- filterGroups(): void {
888
- const searchText = this.searchGroupText.toLowerCase();
889
-
890
- if (searchText) {
891
- // Preserve the checked state during filtering
892
- this.filteredGroups = this.groupsData
893
- .map(group => ({
894
- ...group,
895
- checked: this.filteredGroups.find(g => g.groupName === group.groupName)?.checked || false
896
- }))
897
- .filter(group =>
898
- group?.groupName?.toLowerCase().includes(searchText)
899
- );
900
- } else {
901
- // Restore the original checked state when search text is cleared
902
- this.filteredGroups = this.groupsData.map(group => ({
903
- ...group,
904
- checked: this.selectedFilters.group.find((g:any) => g.groupName === group.groupName)?.checked || false
905
- }));
906
- }
907
- }
908
-
909
-
910
- filterStores(): void {
911
- const searchText = this.searchStoreText.toLowerCase();
912
- // Preserve checked states during filtering
913
- if (searchText) {
914
- // Filter based on search text while preserving checked state
915
- this.filteredStores = this.stores
916
- .map(store => ({
917
- ...store,
918
- // Check if the store is already checked in filteredStores, fallback to original stores' checked state
919
- checked: this.selectedFilters.stores.find((s: any) => s.storeId === store.storeId)?.checked || store.checked || false
920
- }))
921
- .filter(store => store.storeName.toLowerCase().includes(searchText));
922
- } else {
923
- // When the search text is cleared, restore the original list with preserved checked states
924
- this.filteredStores = this.stores.map(store => ({
925
- ...store,
926
- // Preserve the checked state based on the selected filters
927
- checked: this.selectedFilters.stores.find((s: any) => s.storeId === store.storeId)?.checked || store.checked || false
928
- }));
929
- }
930
- }
931
-
932
- closeDropdown(): void {
933
- this.dropdownOpen = null;
934
- }
935
-
936
- @HostListener("document:click", ["$event"])
937
- clickOutside(event: MouseEvent): void {
938
- const clickedInside = (event.target as HTMLElement).closest(
939
- ".dropdown-container"
940
- );
941
- const clickedoutSide = (event.target as HTMLElement).closest(
942
- ".dropdown2"
943
- );
944
- if (!clickedInside) {
945
- this.closeDropdown();
946
- }
947
- if(!clickedoutSide) {
948
- this.closeDropdown1();
949
- }
950
-
951
- }
952
-
953
- // getCountry(): void {
954
- // // const headerFilters: any = JSON.parse(localStorage.getItem("header-filters") || "{}");
955
- // let obj ={
956
- // clientId: this.selectedFilters.client ? this.selectedFilters.client :this.users.clientId,
957
- // }
958
- // this.auth.getCountry(obj).subscribe({
959
- // next: (res: any) => {
960
- // let countryList = this.selectedFilters?.country?.filter((country:any) => country.checked).map((loc:any) => loc.allCountry);
961
- // // Map the fetched countries with default unchecked state
962
- // this.countires = res?.data?.countryData.map((allCountry: any) => ({
963
- // allCountry: allCountry.allCountry,
964
- // checked: countryList?.includes(allCountry.allCountry) ? true : false,
965
- // }));
966
-
967
- // // Sync the fetched countries with any stored checked values in localStorage
968
- // if (this.selectedFilters.country && Array.isArray(this.selectedFilters.country)) {
969
- // this.filteredCountries = this.countries.map(country => {
970
- // const matchedLocation = this.selectedFilters.country.find((loc: any) => loc.allCountry === country.allCountry);
971
- // return matchedLocation ? { ...country, checked: matchedLocation.checked } : country;
972
- // });
973
- // } else {
974
- // this.filteredCountries = this.countries;
975
- // }
976
-
977
- // if(this.searchLocationText) {
978
- // this.filteredCountries = this.countries.filter((country:any) => country.city.toLowerCase().includes(this.searchLocationText.toLowerCase()))
979
- // }
980
- // const selectedCountries = this.countries.filter((country) => country.checked).map((country) => country.allCountry);
981
- // if (selectedCountries.length > 0) {
982
- // setTimeout(()=>{
983
- // this.getStore(); // Fetch stores based on selected groups
984
- // },1000)
985
- // }
986
- // },
987
- // error: (err) => {
988
- // console.error("Failed to fetch countries", err);
989
- // },
990
- // });
991
- // }
992
-
993
- // selectedCountriesLabel(): string {
994
- // const selectedCountries = this.countryLabel = this.searchLocationText.length ? this.countries
995
- // .filter(country => country.checked).map(country => country.allCountry) : this.filteredCountries
996
- // .filter(country => country.checked).map(country => country.allCountry);
997
- // return selectedCountries.length === 0
998
- // ? ''
999
- // : selectedCountries.length === 1
1000
- // ? selectedCountries[0]
1001
- // : `${selectedCountries.length} countries`;
1002
- // }
1003
-
1004
- // isAllCountriesSelected(): boolean {
1005
- // return this.filteredCountries.every(country => country.checked);
1006
-
1007
- // }
1008
- // filterCountries(): void {
1009
- // const searchText = this.searchCountryText.toLowerCase();
1010
-
1011
- // if (searchText) {
1012
- // // Preserve the checked state during filtering
1013
- // this.filteredCountries = this.countires
1014
- // .map(country => ({
1015
- // ...country,
1016
- // checked: this.filteredCountries.find(l => l.allCountry === country.allCountry)?.checked || false
1017
- // }))
1018
- // .filter(location =>
1019
- // location?.allCountry?.toLowerCase().includes(searchText)
1020
- // );
1021
- // } else {
1022
- // // Restore the original checked state when search text is cleared
1023
- // this.filteredCountries = this.countires.map(country => ({
1024
- // ...country,
1025
- // checked: this.selectedFilters.country.find((l:any) => l.allCountry === country.allCountry)?.checked || false
1026
- // }));
1027
- // }
1028
- // }
1029
-
1030
-
1031
- getCountry(): void {
1032
- let obj = {
1033
- clientId: this.selectedFilters.client ? this.selectedFilters.client : this.users.clientId,
1034
- };
1035
-
1036
- this.auth.getCountry(obj).subscribe({
1037
- next: (res: any) => {
1038
- // Extract selected countries from existing filters (if any)
1039
- let countryList = this.selectedFilters?.country?.filter((country: any) => country.checked).map((loc: any) => loc.country);
1040
-
1041
- // Map API response to frontend model
1042
- this.countries = res?.data?.countryData.map((item: any) => ({
1043
- country: item.country,
1044
- // checked: countryList?.length ? countryList.includes(item.country) : true,
1045
- // checked: cityList?.length ? cityList.includes(city.city) : true,
1046
- checked: countryList?.includes(item.country) ? true : false,
1047
-
1048
- }));
1049
- if (this.selectedFilters.country && Array.isArray(this.selectedFilters.country)) {
1050
- this.filteredCountries = this.countries.map(location => {
1051
- const matchedLocation = this.selectedFilters.country.find((loc: any) => loc.country === location.country);
1052
- return matchedLocation ? { ...location, checked: matchedLocation.checked } : location;
1053
- });
1054
- } else {
1055
- this.filteredCountries = this.countries;
1056
- }
1057
-
1058
-
1059
- // Initially, all countries are visible
1060
- this.filteredCountries = [...this.countries];
1061
-
1062
-
1063
- // If a search text already exists, filter immediately
1064
- if (this.searchCountryText) {
1065
- this.filterCountries();
1066
- }
1067
-
1068
- // Fetch stores if at least one country is selected
1069
- let selectedCountries = this.countries.filter((country) => country.checked);
1070
- if (selectedCountries.length > 0) {
1071
- setTimeout(() => {
1072
- this.getLocations();
1073
- this.getStore(); // fetch stores
1074
- }, 1000);
1075
- }
1076
- },
1077
- error: (err) => {
1078
- console.error("Failed to fetch countries", err);
1079
- },
1080
- });
1081
- }
1082
-
1083
- selectedCountriesLabel(): string {
1084
- const selectedCountries = this.searchCountryText.length
1085
- ? this.filteredCountries.filter(country => country.checked).map(country => country.country)
1086
- : this.countries.filter(country => country.checked).map(country => country.country);
1087
-
1088
- return selectedCountries.length === 0
1089
- ? ''
1090
- : selectedCountries.length === 1
1091
- ? selectedCountries[0]
1092
- : `${selectedCountries.length} countries`;
1093
- }
1094
-
1095
- filterCountries(): void {
1096
- const searchText = this.searchCountryText.toLowerCase();
1097
-
1098
- if (searchText) {
1099
- // Filter and preserve checked state
1100
- this.filteredCountries = this.countries
1101
- .map(country => ({
1102
- ...country,
1103
- checked: this.filteredCountries.find(c => c.country === country.country)?.checked || false
1104
- }))
1105
- .filter(country => country.country.toLowerCase().includes(searchText));
1106
- } else {
1107
- // Reset to full list
1108
- this.filteredCountries = this.countries.map((country: Country) => ({
1109
- ...country,
1110
- checked: this.selectedFilters.country?.find((c: any) => c.country === country.country)?.checked || false
1111
- }));
1112
- }
1113
- }
1114
-
1115
- isAllCountriesSelected(): boolean {
1116
- return this.filteredCountries.length > 0 && this.filteredCountries.every(country => country.checked);
1117
- }
1118
- toggleSelectAllCountries(event: any): void {
1119
- const isChecked = event.target.checked;
1120
- this.filteredCountries.forEach((country) => (country.checked = isChecked));
1121
- this.updateSelectedCountries();
1122
-
1123
- }
1124
-
1125
- updateSelectedCountries(): void {
1126
- // When locations are selected, fetch the related groups
1127
- const selectedCountries = this.filteredCountries
1128
- .filter((country) => country.checked)
1129
- .map((country) => country.country);
1130
- this.filteredCountries.forEach((country:any) => {
1131
- let findCountryIndex = this.countries.findIndex((loc:any) => loc.country == country.country);
1132
- if(findCountryIndex != -1) {
1133
- this.countries[findCountryIndex].checked = country.checked;
1134
- }
1135
- })
1136
- if (selectedCountries.length > 0 || !selectedCountries.length) {
1137
- this.selectedFilters.stores =[];
1138
- this.groupsData =[]
1139
- this.locations =[];
1140
- this.getLocations();
1141
- this.getGroups(); // Fetch groups based on selected cities
1142
- // If there are selected groups, fetch the stores based on selected groups
1143
- this.getStore();
1144
- this.selectedFilters.country = this.filteredCountries;
1145
-
1146
- } else {
1147
- this.filteredGroups = []; // Clear groups if no locations are selected
1148
- this.selectedFilters.country = [];
1149
- }
1150
-
1151
- this.selectedFilters.group = [];
1152
- this.filteredStores = []; // Reset stores as well
1153
- this.searchGroupText = '';
1154
- this.searchStoreText = '';
1155
- // this.Opendropdown = false;
1156
- }
1157
-
1158
- removeCountry(): void {
1159
- this.Reset();
1160
- }
1161
-
1162
- Apply(): void {
1163
- // Close the dropdown
1164
- this.Opendropdown = false;
1165
-
1166
- // Fetch existing filters from localStorage
1167
- const headerFilters: any = JSON.parse(localStorage.getItem("header-filters") || "{}");
1168
- this.selectedFilters.store = null
1169
-
1170
- // Ensure current selections are reflected
1171
- this.selectedFilters.country = this.filteredCountries;
1172
- this.selectedFilters.location = this.locations;
1173
- this.selectedFilters.group = this.groupsData;
1174
- this.selectedFilters.stores = headerFilters.stores ? headerFilters.stores : this.stores;
1175
- // Store updated filters back in localStorage
1176
- localStorage.setItem("header-filters", JSON.stringify(this.selectedFilters));
1177
- // this.gs.dataRangeValue.next(this.selectedFilters);
1178
- window.location.reload()
1179
- // Emit the updated filters via the service
1180
- // this.gs.dataRangeValue.next(this.selectedFilters);
1181
- // Trigger refresh if necessary
1182
- // this.gs.manageRefreshTrigger.next(true);
1183
- this.cd.detectChanges();
1184
- }
1185
-
1186
-
1187
-
1188
- }
1189
- interface City {
1190
- city: string;
1191
- }
1192
-
1193
- interface Location {
1194
- city: City;
1195
- checked: boolean;
1196
- }
1197
- interface Country {
1198
- country: string;
1199
- checked: boolean;
1200
- }