datastake-daf 0.6.798 → 0.6.800

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 (72) hide show
  1. package/dist/components/index.js +1206 -311
  2. package/dist/context/index.js +6 -6
  3. package/dist/pages/index.js +250 -14
  4. package/dist/services/index.js +187 -84
  5. package/dist/utils/index.js +14 -17
  6. package/package.json +1 -1
  7. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +0 -1
  8. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -1
  9. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -1
  10. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -1
  11. package/src/@daf/core/components/Screens/Admin/AdminModals/AddUser/index.jsx +0 -1
  12. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/columns.js +79 -0
  13. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/helper.js +2 -2
  14. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +18 -8
  15. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +6 -6
  16. package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +1 -1
  17. package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +61 -38
  18. package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +1 -4
  19. package/src/@daf/core/components/Screens/Admin/AdminScreens/AccountsView.jsx +2 -0
  20. package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
  21. package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +10 -8
  22. package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +5 -3
  23. package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +395 -0
  24. package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +1 -0
  25. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +1 -0
  26. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +225 -0
  27. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +65 -0
  28. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +78 -46
  29. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +41 -39
  30. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +53 -24
  31. package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +1 -0
  32. package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/configTransformer.js +137 -0
  33. package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.js +9 -0
  34. package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +196 -0
  35. package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/configTransformer.js +216 -0
  36. package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.js +7 -0
  37. package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +184 -0
  38. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +64 -0
  39. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +13 -0
  40. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/index.jsx +77 -0
  41. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/config.js +51 -0
  42. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/helpers.js +0 -0
  43. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/index.jsx +75 -0
  44. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +7 -1
  45. package/src/@daf/core/components/Screens/Admin/AdminViews/components/SidebarMenu/index.jsx +5 -3
  46. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +13 -8
  47. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +16 -10
  48. package/src/@daf/core/components/Screens/Admin/AdminViews/components/View/index.jsx +2 -1
  49. package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +66 -26
  50. package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +193 -0
  51. package/src/@daf/core/components/Screens/Admin/adminRoutes.js +37 -2
  52. package/src/@daf/layouts/AppLayout/index.jsx +0 -1
  53. package/src/@daf/pages/Edit/hooks/usePrepareForm.js +1 -1
  54. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/columns.js +180 -0
  55. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/config.js +0 -0
  56. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/index.jsx +27 -0
  57. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/columns.js +157 -0
  58. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/config.js +31 -0
  59. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/index.js +77 -0
  60. package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/columns.js +117 -0
  61. package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/index.jsx +54 -0
  62. package/src/@daf/pages/SelfAssesment/index.jsx +0 -0
  63. package/src/@daf/pages/View/hooks/usePrepareForm.js +11 -1
  64. package/src/@daf/pages/View/index.jsx +9 -2
  65. package/src/@daf/services/AdminService.js +112 -7
  66. package/src/@daf/services/AuthenticationService.js +1 -0
  67. package/src/@daf/services/DashboardService.js +2 -1
  68. package/src/@daf/utils/filters.js +15 -13
  69. package/src/constants/locales/en/translation.js +7 -0
  70. package/src/constants/locales/fr/translation.js +1 -1
  71. package/src/constants/locales/sp/translation.js +1 -1
  72. package/src/index.js +1 -0
@@ -50,7 +50,7 @@ const assignParamsToUrl = (path, params) => {
50
50
  * @returns storage objects
51
51
  * @class StorageManager
52
52
  */
53
- class StorageManager$1 {
53
+ class StorageManager {
54
54
  /**
55
55
  * @description Set or update given value in localStorage
56
56
  * @static
@@ -185,11 +185,11 @@ class StorageManager$1 {
185
185
  const isProxy = () => {
186
186
  const pathname = window.location.pathname;
187
187
  if (pathname.includes('/proxy/pme') || pathname.includes('/proxy/cadd')) {
188
- return window.opener || !!StorageManager$1.get('proxy_token');
188
+ return window.opener || !!StorageManager.get('proxy_token');
189
189
  }
190
190
  return false;
191
191
  };
192
- const getToken = () => isProxy() ? StorageManager$1.get('proxy_token') : StorageManager$1.get('token');
192
+ const getToken = () => isProxy() ? StorageManager.get('proxy_token') : StorageManager.get('token');
193
193
 
194
194
  /**
195
195
  * Custom params serializer to maintain JSON format for nested objects
@@ -626,7 +626,7 @@ class ErrorService {
626
626
  class BaseService extends BaseHTTPService {
627
627
  constructor() {
628
628
  const errorHandler = createErrorHandler({
629
- getStorageManager: () => StorageManager$1,
629
+ getStorageManager: () => StorageManager,
630
630
  handleError: ({
631
631
  status,
632
632
  statusText,
@@ -646,7 +646,7 @@ class BaseService extends BaseHTTPService {
646
646
  onUnauthorized: () => {
647
647
  console.warn('[BaseService] 401 Unauthorized - Token cleared, redirecting to /');
648
648
  console.trace('[BaseService] Unauthorized call stack:');
649
- StorageManager$1.clearOne('token');
649
+ StorageManager.clearOne('token');
650
650
  if (typeof window !== 'undefined') {
651
651
  window.location.href = '/';
652
652
  }
@@ -663,7 +663,7 @@ class BaseService extends BaseHTTPService {
663
663
  getHeaders: () => {
664
664
  const config = getServicesConfig();
665
665
  return {
666
- Language: StorageManager$1.get('datastakeLng') || 'en',
666
+ Language: StorageManager.get('datastakeLng') || 'en',
667
667
  'ngrok-skip-browser-warning': true,
668
668
  Application: config.application
669
669
  };
@@ -683,6 +683,80 @@ class BaseService extends BaseHTTPService {
683
683
  }
684
684
  }
685
685
 
686
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
687
+
688
+ function createCommonjsModule(fn, module) {
689
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
690
+ }
691
+
692
+ var customParseFormat = createCommonjsModule(function (module, exports) {
693
+ !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
694
+ });
695
+
696
+ var utc = createCommonjsModule(function (module, exports) {
697
+ !function(t,i){module.exports=i();}(commonjsGlobal,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t);};var r=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds();}else r.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s,o=this;if(f)return o.$offset=u,o.$u=0===s,o;if(0!==s){var r=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(u+r,t)).$offset=u,o.$x.$localOffset=r;}else o=this.utc();return o};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
698
+ });
699
+
700
+ var localizedFormat = createCommonjsModule(function (module, exports) {
701
+ !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(t,o,n){var r=o.prototype,i=r.format;n.en.formats=e,r.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var o=this.$locale().formats,n=function(t,o){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var i=r&&r.toUpperCase();return n||o[r]||e[r]||o[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,o){return t||o.slice(1)}))}))}(t,void 0===o?{}:o);return i.call(this,n)};}}));
702
+ });
703
+
704
+ createCommonjsModule(function (module, exports) {
705
+ !function(e,n){module.exports=n(dayjs__default["default"]);}(commonjsGlobal,(function(e){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(e),i={name:"fr",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return ""+e+(1===e?"er":"")}};return t.default.locale(i,null,!0),i}));
706
+ });
707
+
708
+ createCommonjsModule(function (module, exports) {
709
+ !function(e,o){module.exports=o(dayjs__default["default"]);}(commonjsGlobal,(function(e){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(e),d={name:"es",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return s.default.locale(d,null,!0),d}));
710
+ });
711
+
712
+ createCommonjsModule(function (module, exports) {
713
+ !function(e,n){module.exports=n();}(commonjsGlobal,(function(){return {name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var n=["th","st","nd","rd"],t=e%100;return "["+e+(n[(t-20)%10]||n[t]||n[0])+"]"}}}));
714
+ });
715
+
716
+ /* eslint-disable no-case-declarations */
717
+ dayjs__default["default"].extend(customParseFormat);
718
+ dayjs__default["default"].extend(utc);
719
+ dayjs__default["default"].extend(utc);
720
+ dayjs__default["default"].extend(localizedFormat);
721
+ const isObjectEmpty = obj => {
722
+ if (obj === null || typeof obj !== "object") {
723
+ return false;
724
+ }
725
+ if (Object.keys(obj).length === 0) {
726
+ return true;
727
+ }
728
+ return Object.values(obj).every(value => isObjectEmpty(value));
729
+ };
730
+
731
+ /**
732
+ * Filters and processes the input data by extracting specific properties.
733
+ * It checks if the 'meta' property is empty and sets it to undefined if so,
734
+ * then returns the rest of the data merged with the processed 'meta'. Used to clear data
735
+ * when they are sent to backend.
736
+ *
737
+ * @param {Object} data - The input data object containing various properties.
738
+ * @returns {Object} - The processed data object with filtered properties.
739
+ */
740
+
741
+ const filterCreateData = data => {
742
+ // eslint-disable-next-line no-unused-vars
743
+ const {
744
+ view,
745
+ module,
746
+ scope,
747
+ form,
748
+ meta,
749
+ createdAt,
750
+ updatedAt,
751
+ ...rest
752
+ } = data;
753
+ const _meta = isObjectEmpty(meta) ? undefined : meta;
754
+ return {
755
+ ...rest,
756
+ meta: _meta
757
+ };
758
+ };
759
+
686
760
  class AdminService extends BaseService {
687
761
  updateCompany(id, data) {
688
762
  return this.apiPut({
@@ -697,6 +771,15 @@ class AdminService extends BaseService {
697
771
  url: `/accounts/${id}`
698
772
  });
699
773
  }
774
+ inviteCompanyAccount({
775
+ companyId,
776
+ data
777
+ }) {
778
+ return this.apiPost({
779
+ url: `/accounts/${companyId}/invite`,
780
+ data
781
+ });
782
+ }
700
783
  inviteAccount(data) {
701
784
  return this.apiPost({
702
785
  url: `/accounts/inviteAccount`,
@@ -765,17 +848,111 @@ class AdminService extends BaseService {
765
848
  params
766
849
  }) {
767
850
  return this.apiGet({
768
- url: `${subject}`,
851
+ url: `/management/subjects/${subject}`,
769
852
  params
770
853
  });
771
854
  }
855
+ mergeLocations({
856
+ ids,
857
+ data
858
+ }) {
859
+ const [id1, id2, ...remainingIds] = ids || [];
860
+ if (!id1 || !id2) {
861
+ throw new Error('At least two IDs are required for merging');
862
+ }
863
+ const url = `/management/merge/location/${id1}/${id2}`;
864
+ const payload = {
865
+ ...data
866
+ };
867
+ if (remainingIds.length > 0) {
868
+ payload.additionalIds = remainingIds;
869
+ }
870
+ return this.apiPost({
871
+ url,
872
+ data: payload
873
+ });
874
+ }
772
875
  mergeSubjects({
773
876
  subject,
774
- ...data
877
+ ids,
878
+ data
775
879
  }) {
880
+ const [id1, id2, ...remainingIds] = ids || [];
881
+ if (!id1 || !id2) {
882
+ throw new Error('At least two IDs are required for merging');
883
+ }
884
+ const url = `/management/merge/${subject}/${id1}/${id2}`;
885
+ const payload = {
886
+ ...data
887
+ };
888
+ if (remainingIds.length > 0) {
889
+ payload.additionalIds = remainingIds;
890
+ }
776
891
  return this.apiPost({
777
- url: `/merge/${subject}`,
778
- data
892
+ url,
893
+ data: payload
894
+ });
895
+ }
896
+ getSubjectForm({
897
+ subject,
898
+ scope = 'global'
899
+ }) {
900
+ return this.apiGet({
901
+ url: `/forms/${subject}`,
902
+ params: {
903
+ scope
904
+ }
905
+ });
906
+ }
907
+ getSubjectData({
908
+ subject,
909
+ id
910
+ }) {
911
+ return this.apiGet({
912
+ url: `/management/subject/${subject}/${id}`
913
+ });
914
+ }
915
+ viewLocation({
916
+ id
917
+ }) {
918
+ return this.apiGet({
919
+ url: `/management/subject/location/${id}`
920
+ });
921
+ }
922
+ viewStakeholder({
923
+ id
924
+ }) {
925
+ return this.apiGet({
926
+ url: `/management/subject/stakeholder/${id}`
927
+ });
928
+ }
929
+ updateSubject({
930
+ subject,
931
+ id,
932
+ data
933
+ }) {
934
+ const type = subject === 'location' ? 'location' : 'stakeholder';
935
+ return this.apiPut({
936
+ url: `/management/subject/${type}/${id}`,
937
+ data: filterCreateData(data)
938
+ });
939
+ }
940
+ deleteSubject({
941
+ subject,
942
+ id
943
+ }) {
944
+ const type = subject === 'location' ? 'location' : 'stakeholder';
945
+ return this.apiDelete({
946
+ url: `/management/subject/${type}/${id}`
947
+ });
948
+ }
949
+ getUserGrowth(activeFilter) {
950
+ return this.apiGet({
951
+ url: `/accounts/dashboard/user-growth`,
952
+ isUserManager: true,
953
+ params: {
954
+ activeFilter
955
+ }
779
956
  });
780
957
  }
781
958
  }
@@ -1246,80 +1423,6 @@ class DashboardService extends BaseService {
1246
1423
  }
1247
1424
  var DashboardService$1 = createLazyService(DashboardService);
1248
1425
 
1249
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1250
-
1251
- function createCommonjsModule(fn, module) {
1252
- return module = { exports: {} }, fn(module, module.exports), module.exports;
1253
- }
1254
-
1255
- var customParseFormat = createCommonjsModule(function (module, exports) {
1256
- !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
1257
- });
1258
-
1259
- var utc = createCommonjsModule(function (module, exports) {
1260
- !function(t,i){module.exports=i();}(commonjsGlobal,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t);};var r=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds();}else r.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s,o=this;if(f)return o.$offset=u,o.$u=0===s,o;if(0!==s){var r=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(u+r,t)).$offset=u,o.$x.$localOffset=r;}else o=this.utc();return o};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
1261
- });
1262
-
1263
- var localizedFormat = createCommonjsModule(function (module, exports) {
1264
- !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(t,o,n){var r=o.prototype,i=r.format;n.en.formats=e,r.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var o=this.$locale().formats,n=function(t,o){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var i=r&&r.toUpperCase();return n||o[r]||e[r]||o[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,o){return t||o.slice(1)}))}))}(t,void 0===o?{}:o);return i.call(this,n)};}}));
1265
- });
1266
-
1267
- createCommonjsModule(function (module, exports) {
1268
- !function(e,n){module.exports=n(dayjs__default["default"]);}(commonjsGlobal,(function(e){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(e),i={name:"fr",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return ""+e+(1===e?"er":"")}};return t.default.locale(i,null,!0),i}));
1269
- });
1270
-
1271
- createCommonjsModule(function (module, exports) {
1272
- !function(e,o){module.exports=o(dayjs__default["default"]);}(commonjsGlobal,(function(e){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(e),d={name:"es",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return s.default.locale(d,null,!0),d}));
1273
- });
1274
-
1275
- createCommonjsModule(function (module, exports) {
1276
- !function(e,n){module.exports=n();}(commonjsGlobal,(function(){return {name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var n=["th","st","nd","rd"],t=e%100;return "["+e+(n[(t-20)%10]||n[t]||n[0])+"]"}}}));
1277
- });
1278
-
1279
- /* eslint-disable no-case-declarations */
1280
- dayjs__default["default"].extend(customParseFormat);
1281
- dayjs__default["default"].extend(utc);
1282
- dayjs__default["default"].extend(utc);
1283
- dayjs__default["default"].extend(localizedFormat);
1284
- const isObjectEmpty = obj => {
1285
- if (obj === null || typeof obj !== "object") {
1286
- return false;
1287
- }
1288
- if (Object.keys(obj).length === 0) {
1289
- return true;
1290
- }
1291
- return Object.values(obj).every(value => isObjectEmpty(value));
1292
- };
1293
-
1294
- /**
1295
- * Filters and processes the input data by extracting specific properties.
1296
- * It checks if the 'meta' property is empty and sets it to undefined if so,
1297
- * then returns the rest of the data merged with the processed 'meta'. Used to clear data
1298
- * when they are sent to backend.
1299
- *
1300
- * @param {Object} data - The input data object containing various properties.
1301
- * @returns {Object} - The processed data object with filtered properties.
1302
- */
1303
-
1304
- const filterCreateData = data => {
1305
- // eslint-disable-next-line no-unused-vars
1306
- const {
1307
- view,
1308
- module,
1309
- scope,
1310
- form,
1311
- meta,
1312
- createdAt,
1313
- updatedAt,
1314
- ...rest
1315
- } = data;
1316
- const _meta = isObjectEmpty(meta) ? undefined : meta;
1317
- return {
1318
- ...rest,
1319
- meta: _meta
1320
- };
1321
- };
1322
-
1323
1426
  dayjs__default["default"].extend(utc);
1324
1427
  const removeKeysFromObject = (obj = {}, keys = []) => {
1325
1428
  if (typeof obj !== 'object' || obj === null) return obj;
@@ -7554,15 +7554,14 @@ const getDefaultActiveFilters = (params, selectFiltersConfig, defaultPageSize, d
7554
7554
  });
7555
7555
  return o;
7556
7556
  };
7557
- const NEW_PAGINATION_APPS = ["nashiriki"];
7558
7557
  const filterParams = (value, module) => {
7559
7558
  const {
7560
7559
  activeFilters,
7561
7560
  ...rest
7562
7561
  } = value;
7563
7562
  const {
7564
- page,
7565
- pageSize,
7563
+ page = 1,
7564
+ pageSize = 20,
7566
7565
  sortDir,
7567
7566
  sortBy,
7568
7567
  search,
@@ -7571,9 +7570,10 @@ const filterParams = (value, module) => {
7571
7570
  } = activeFilters || {};
7572
7571
  const params = {};
7573
7572
  params.pagination = JSON.stringify({
7574
- [NEW_PAGINATION_APPS.includes(module) ? "skip" : "page"]: page,
7575
- [NEW_PAGINATION_APPS.includes(module) ? "take" : "pageSize"]: pageSize
7573
+ page,
7574
+ pageSize
7576
7575
  });
7576
+ params.filters = JSON.stringify(filters);
7577
7577
  if (search && searchParams) {
7578
7578
  params.search = JSON.stringify({
7579
7579
  qs: search,
@@ -7586,16 +7586,6 @@ const filterParams = (value, module) => {
7586
7586
  by: sortBy
7587
7587
  });
7588
7588
  }
7589
- if (Object.keys(filters).length) {
7590
- if (value.sourceId && value.sourceId === "overview") {
7591
- params.filters = JSON.stringify(filters);
7592
- } else {
7593
- params.filters = JSON.stringify({
7594
- ...filters,
7595
- authorId: undefined
7596
- });
7597
- }
7598
- }
7599
7589
  return {
7600
7590
  ...rest,
7601
7591
  ...params
@@ -7801,6 +7791,13 @@ function getRedirectPath(user, fallback = '', app, isDatastake) {
7801
7791
 
7802
7792
  const en = {
7803
7793
  "All Data": "All Data",
7794
+ "sbg-admin::remove-user-title": "Remove User Title",
7795
+ "sbg-admin::remove-user-body": "Remove User Body",
7796
+ "Administrative-level-1": "Administrative Level 1",
7797
+ "Administrative-level-2": "Administrative Level 2",
7798
+ "merge-output": "Merge Output",
7799
+ "admin::current_subjects": "Current Subjects",
7800
+ "add-account": "Add Account",
7804
7801
  "Site": "Site",
7805
7802
  "Production Sites": "Production Sites",
7806
7803
  "Type of account": "Type of account",
@@ -9501,7 +9498,7 @@ const fr = {
9501
9498
  Documentation: "Documents",
9502
9499
  "Edit project": "Modifier le projet",
9503
9500
  Name: "Nom",
9504
- Type: "Tapez",
9501
+ Type: "Type",
9505
9502
  type: "Type",
9506
9503
  Province: "Province",
9507
9504
  Territory: "Territoire",
@@ -11313,7 +11310,7 @@ const sp = {
11313
11310
  "Documentation": "Documentos",
11314
11311
  "Edit project": "Modificar proyecto",
11315
11312
  "Name": "Nombre",
11316
- "Type": "Escribe",
11313
+ "Type": "Tipo",
11317
11314
  "type": "Tipo",
11318
11315
  "Province": "Provincia",
11319
11316
  "Territory": "Territorio",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.798",
3
+ "version": "0.6.800",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -10,7 +10,6 @@ const { useToken } = theme;
10
10
  export default function useTopContributors({ container, data = [], t }) {
11
11
  const [mainGraph, setMainGraph] = useState(null);
12
12
  const { token } = useToken();
13
-
14
13
  useEffect(() => {
15
14
  if (container.current) {
16
15
  if (mainGraph) {
@@ -8,7 +8,7 @@ export default function TopContributors({ data, loading, t }) {
8
8
  const container = useRef(null);
9
9
 
10
10
  useTopContributors({ container, data, t });
11
-
11
+ console.log("topcontributorshhhh", data);
12
12
  return (
13
13
  <Widget
14
14
  title={t(`admin::top-contributors`)}
@@ -12,7 +12,7 @@ export default function useUserGrowth({ container, data: mainData = {}, t, trans
12
12
  const [mainGraph, setMainGraph] = useState(null);
13
13
  const [data, setData] = useState([]);
14
14
  const { token } = useToken();
15
-
15
+ console.log("mainData", mainData);
16
16
  const fetchData = () => {
17
17
  const { dates = [] } = mainData;
18
18
  const _data = [];
@@ -9,7 +9,7 @@ export default function UserGrowth({ loading, data = [], t, translationKeys, fet
9
9
  const [selectValue, setSelectValue] = useState(selectOptions[0]?.value);
10
10
 
11
11
  useUserGrowth({ container, data, t, translationKeys });
12
-
12
+ console.log("usergrowthhhhh", data);
13
13
 
14
14
  useEffect(() => {
15
15
  if (typeof fetchUserGrowth === "function") {
@@ -24,7 +24,6 @@ export default function AddUserModal({ isOpen, defaultData = {}, userRoles = [],
24
24
  .catch(() => {});
25
25
  };
26
26
 
27
- console.log("hellooooooooooooooooooooooooo");
28
27
 
29
28
  return (
30
29
  <Modal
@@ -0,0 +1,79 @@
1
+ import { findOptions } from "../../../../../../../helpers/StringHelper.js";
2
+ import { Tooltip } from "antd";
3
+ import { getNameByLevel } from "../../AdminTables/SubjectsTable/helper.js";
4
+
5
+ export const getColumns = ({ t, selectOptions, module, entity }) => {
6
+ return [
7
+ {
8
+ title: t("admin::organisation_id"),
9
+ dataIndex: "datastakeId",
10
+ key: "datastakeId",
11
+ show: true,
12
+ render: (value, all) => {
13
+ return <Tooltip title={value}>{value}</Tooltip>;
14
+ },
15
+ },
16
+ {
17
+ title: t("Name"),
18
+ dataIndex: "name",
19
+ key: "name",
20
+ show: true,
21
+ render: (value, all) => {
22
+ return <Tooltip title={value}>{value}</Tooltip>;
23
+ },
24
+ },
25
+ {
26
+ title: t("Category"),
27
+ dataIndex: "category",
28
+ key: "category",
29
+ show: true,
30
+ render: (value, all) => {
31
+ const label = findOptions(value, selectOptions?.category);
32
+ return <Tooltip title={label}>{label}</Tooltip>;
33
+ },
34
+ },
35
+ {
36
+ title: t("Country"),
37
+ dataIndex: "country",
38
+ key: "country",
39
+ show: true,
40
+ render: (value, all) => {
41
+ const label = findOptions(value, selectOptions?.country);
42
+ return <Tooltip title={label}>{label}</Tooltip>;
43
+ },
44
+ },
45
+ {
46
+ title: t("Province"),
47
+ dataIndex: "administrativeLevel1",
48
+ key: "administrativeLevel1",
49
+ ellipsis: true,
50
+ show: entity.includes("locations"),
51
+ render: (value, all) => {
52
+ let label;
53
+ if(all?.administrativeLevel1 && value === all?.administrativeLevel1) {
54
+ label = all?.linking?.SCL?.[value]?.name
55
+ } else {
56
+ label = getNameByLevel(all?.linking?.SCL, "level_1")?.name
57
+ }
58
+
59
+ return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
60
+ },
61
+ },
62
+ {
63
+ title: t("Territory"),
64
+ dataIndex: "administrativeLevel2",
65
+ key: "administrativeLevel2",
66
+ show: entity.includes("locations"),
67
+ render: (value, all) => {
68
+ let label;
69
+ if(all?.administrativeLevel2 && value === all?.administrativeLevel2) {
70
+ label = all?.linking?.SCL?.[value]?.name
71
+ } else {
72
+ label = getNameByLevel(all?.linking?.SCL, "level_2")?.name
73
+ }
74
+
75
+ return <Tooltip title={label || '-'}>{label || '-'}</Tooltip>;
76
+ },
77
+ },
78
+ ].filter((c) => c?.show);
79
+ };
@@ -47,7 +47,7 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
47
47
  dataIndex: "administrativeLevel1",
48
48
  key: "administrativeLevel1",
49
49
  ellipsis: true,
50
- show: entity.includes("locations"),
50
+ show: entity?.includes("location"),
51
51
  render: (value, all) => {
52
52
  let label;
53
53
  if(all?.administrativeLevel1 && value === all?.administrativeLevel1) {
@@ -63,7 +63,7 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
63
63
  title: t("Territory"),
64
64
  dataIndex: "administrativeLevel2",
65
65
  key: "administrativeLevel2",
66
- show: entity.includes("locations"),
66
+ show: entity?.includes("location"),
67
67
  render: (value, all) => {
68
68
  let label;
69
69
  if(all?.administrativeLevel2 && value === all?.administrativeLevel2) {
@@ -1,11 +1,10 @@
1
1
  import Modal from "../../../../Modal/index.jsx";
2
2
  import { Form, Input, Select, theme } from "antd";
3
3
  import { Container } from "../CombineModalStyle.js";
4
- import { findOptions } from "../../../../../../../helpers/StringHelper.js";
5
4
  import DAFTable from "../../../../Table/index.jsx";
6
5
  import { useMemo, useState } from "react";
7
- import { getColumns } from "./helper.js";
8
6
  import { getNameByLevel } from "../../AdminTables/SubjectsTable/helper.js";
7
+ import { getColumns } from "./helper.js";
9
8
 
10
9
  const { useToken } = theme;
11
10
 
@@ -35,10 +34,22 @@ export default function CombineLocationModal({
35
34
 
36
35
  const onSubmit = () => {
37
36
  MainForm.validateFields().then((data) => {
38
- const ids = selectedLocations.map((location) => location._id);
37
+ const ids = selectedLocations.map((location) => location.id);
38
+ const allowedKeys = [
39
+ "id",
40
+ "name",
41
+ "country",
42
+ "category",
43
+ "administrativeLevel1",
44
+ "administrativeLevel2"
45
+ ];
46
+ const filteredData = Object.fromEntries(
47
+ Object.entries(data).filter(([key]) => allowedKeys.includes(key))
48
+ );
49
+
39
50
  onSuccess({
40
51
  ids,
41
- data,
52
+ data: filteredData,
42
53
  });
43
54
  });
44
55
  };
@@ -57,8 +68,7 @@ export default function CombineLocationModal({
57
68
  setIsDisabled(() => {
58
69
  const values = MainForm.getFieldsValue();
59
70
 
60
- const requiredFields =
61
- entity === "location"
71
+ const requiredFields = entity?.includes("location")
62
72
  ? ["id", "name", "category", "country", "administrativeLevel1", "administrativeLevel2"]
63
73
  : ["id", "name", "category", "country"];
64
74
 
@@ -114,7 +124,7 @@ export default function CombineLocationModal({
114
124
  options={selectedLocations.map((location) => {
115
125
  return {
116
126
  label: location?.datastakeId || "-",
117
- value: location?.datastakeId || "-",
127
+ value: location?.id || "-",
118
128
  };
119
129
  })}
120
130
  placeholder={t("ID")}
@@ -169,7 +179,7 @@ export default function CombineLocationModal({
169
179
  ></Select>
170
180
  </Form.Item>
171
181
 
172
- {entity.includes("locations") && (
182
+ {entity?.includes("location") && (
173
183
  <>
174
184
  <Form.Item className="flex-1" name="administrativeLevel1">
175
185
  <Select