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