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

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