tango-app-ui-shared 3.7.3-dev6-demo6 → 3.7.3-dev6-demo7

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