@overmap-ai/core 1.0.50-bulk-form-submission.3 → 1.0.50-document-attachments.0

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.
@@ -622,15 +622,15 @@ var __publicField = (obj, key, value) => {
622
622
  };
623
623
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
624
624
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
625
- const initialState$p = {
625
+ const initialState$n = {
626
626
  accessToken: "",
627
627
  refreshToken: "",
628
628
  isLoggedIn: false
629
629
  };
630
630
  const authSlice = toolkit.createSlice({
631
631
  name: "auth",
632
- initialState: initialState$p,
633
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
632
+ initialState: initialState$n,
633
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
634
634
  reducers: {
635
635
  setTokens: (state, action) => {
636
636
  state.accessToken = action.payload.accessToken;
@@ -795,19 +795,6 @@ var __publicField = (obj, key, value) => {
795
795
  element.click();
796
796
  document.body.removeChild(element);
797
797
  }
798
- const constructUploadedFilePayloads = async (files) => {
799
- const filePayloads = {};
800
- for (const file of files) {
801
- const sha1 = await hashFile(file);
802
- filePayloads[sha1] = {
803
- sha1,
804
- extension: file.name.split(".").pop() || "",
805
- file_type: file.type,
806
- size: file.size
807
- };
808
- }
809
- return Object.values(filePayloads);
810
- };
811
798
  const fileToBlob = async (dataUrl) => {
812
799
  return (await fetch(dataUrl)).blob();
813
800
  };
@@ -1374,7 +1361,7 @@ var __publicField = (obj, key, value) => {
1374
1361
  return getLocalDateString(date);
1375
1362
  return relative.format(days, "days");
1376
1363
  });
1377
- const initialState$o = {
1364
+ const initialState$m = {
1378
1365
  categories: {},
1379
1366
  usedCategoryColors: [],
1380
1367
  categoryVisibility: {
@@ -1384,8 +1371,8 @@ var __publicField = (obj, key, value) => {
1384
1371
  };
1385
1372
  const categorySlice = toolkit.createSlice({
1386
1373
  name: "categories",
1387
- initialState: initialState$o,
1388
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1374
+ initialState: initialState$m,
1375
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1389
1376
  reducers: {
1390
1377
  setCategories: (state, action) => {
1391
1378
  if (!Array.isArray(action.payload))
@@ -1554,14 +1541,14 @@ var __publicField = (obj, key, value) => {
1554
1541
  delete state.attachments[attachmentId];
1555
1542
  }
1556
1543
  }
1557
- const initialState$n = {
1544
+ const initialState$l = {
1558
1545
  components: {},
1559
1546
  attachments: {}
1560
1547
  };
1561
1548
  const componentSlice = toolkit.createSlice({
1562
1549
  name: "components",
1563
- initialState: initialState$n,
1564
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1550
+ initialState: initialState$l,
1551
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1565
1552
  reducers: {
1566
1553
  addComponent: (state, action) => {
1567
1554
  state.components[action.payload.offline_id] = action.payload;
@@ -1674,9 +1661,6 @@ var __publicField = (obj, key, value) => {
1674
1661
  [selectComponentAttachmentMapping],
1675
1662
  (mapping) => Object.values(mapping)
1676
1663
  );
1677
- const selectComponentAttachment = (attachmentId) => (state) => {
1678
- return state.componentReducer.attachments[attachmentId];
1679
- };
1680
1664
  const selectAttachmentsOfComponent = restructureCreateSelectorWithArgs(
1681
1665
  toolkit.createSelector(
1682
1666
  [selectAllComponentAttachments, (_state, componentId) => componentId],
@@ -1717,13 +1701,13 @@ var __publicField = (obj, key, value) => {
1717
1701
  removeAllComponentsOfType
1718
1702
  } = componentSlice.actions;
1719
1703
  const componentReducer = componentSlice.reducer;
1720
- const initialState$m = {
1704
+ const initialState$k = {
1721
1705
  completionsByComponentId: {}
1722
1706
  };
1723
1707
  const componentStageCompletionSlice = toolkit.createSlice({
1724
1708
  name: "componentStageCompletions",
1725
- initialState: initialState$m,
1726
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1709
+ initialState: initialState$k,
1710
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1727
1711
  reducers: {
1728
1712
  addStageCompletion: (state, action) => {
1729
1713
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1774,13 +1758,13 @@ var __publicField = (obj, key, value) => {
1774
1758
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1775
1759
  };
1776
1760
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1777
- const initialState$l = {
1761
+ const initialState$j = {
1778
1762
  stages: {}
1779
1763
  };
1780
1764
  const componentStageSlice = toolkit.createSlice({
1781
1765
  name: "componentStages",
1782
- initialState: initialState$l,
1783
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1766
+ initialState: initialState$j,
1767
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1784
1768
  reducers: {
1785
1769
  addStages: (state, action) => {
1786
1770
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1890,15 +1874,15 @@ var __publicField = (obj, key, value) => {
1890
1874
  );
1891
1875
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1892
1876
  const componentStageReducer = componentStageSlice.reducer;
1893
- const initialState$k = {
1877
+ const initialState$i = {
1894
1878
  componentTypes: {},
1895
1879
  hiddenComponentTypeIds: {},
1896
1880
  attachments: {}
1897
1881
  };
1898
1882
  const componentTypeSlice = toolkit.createSlice({
1899
1883
  name: "componentTypes",
1900
- initialState: initialState$k,
1901
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1884
+ initialState: initialState$i,
1885
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1902
1886
  reducers: {
1903
1887
  addComponentType: (state, action) => {
1904
1888
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -1966,9 +1950,6 @@ var __publicField = (obj, key, value) => {
1966
1950
  [selectComponentTypeAttachmentMapping],
1967
1951
  (mapping) => Object.values(mapping)
1968
1952
  );
1969
- const selectComponentTypeAttachment = (attachmentId) => (state) => {
1970
- return state.componentTypeReducer.attachments[attachmentId];
1971
- };
1972
1953
  const selectAttachmentsOfComponentType = restructureCreateSelectorWithArgs(
1973
1954
  toolkit.createSelector(
1974
1955
  [selectAllComponentTypeAttachments, (_state, componentTypeId) => componentTypeId],
@@ -2009,13 +1990,13 @@ var __publicField = (obj, key, value) => {
2009
1990
  deleteComponentType
2010
1991
  } = componentTypeSlice.actions;
2011
1992
  const componentTypeReducer = componentTypeSlice.reducer;
2012
- const initialState$j = {
1993
+ const initialState$h = {
2013
1994
  workspaces: {},
2014
1995
  activeWorkspaceId: null
2015
1996
  };
2016
1997
  const workspaceSlice = toolkit.createSlice({
2017
1998
  name: "workspace",
2018
- initialState: initialState$j,
1999
+ initialState: initialState$h,
2019
2000
  // The `reducers` field lets us define reducers and generate associated actions
2020
2001
  reducers: {
2021
2002
  setWorkspaces: (state, action) => {
@@ -2072,7 +2053,7 @@ var __publicField = (obj, key, value) => {
2072
2053
  );
2073
2054
  const workspaceReducer = workspaceSlice.reducer;
2074
2055
  const maxRecentIssues = 10;
2075
- const initialState$i = {
2056
+ const initialState$g = {
2076
2057
  issues: {},
2077
2058
  attachments: {},
2078
2059
  comments: {},
@@ -2084,9 +2065,9 @@ var __publicField = (obj, key, value) => {
2084
2065
  };
2085
2066
  const issueSlice = toolkit.createSlice({
2086
2067
  name: "issues",
2087
- initialState: initialState$i,
2068
+ initialState: initialState$g,
2088
2069
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2089
- Object.assign(state, initialState$i);
2070
+ Object.assign(state, initialState$g);
2090
2071
  }),
2091
2072
  reducers: {
2092
2073
  setIssues: (state, action) => {
@@ -2363,9 +2344,6 @@ var __publicField = (obj, key, value) => {
2363
2344
  }
2364
2345
  )
2365
2346
  );
2366
- const selectIssueAttachment = (attachmentId) => (root) => {
2367
- return root.issueReducer.attachments[attachmentId];
2368
- };
2369
2347
  const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
2370
2348
  toolkit.createSelector(
2371
2349
  [selectIssueAttachments, (_state, issueId) => issueId],
@@ -2494,15 +2472,15 @@ var __publicField = (obj, key, value) => {
2494
2472
  }
2495
2473
  );
2496
2474
  const issueReducer = issueSlice.reducer;
2497
- const initialState$h = {
2475
+ const initialState$f = {
2498
2476
  s3Urls: {}
2499
2477
  };
2500
2478
  const msPerHour = 1e3 * 60 * 60;
2501
2479
  const msPerWeek = msPerHour * 24 * 7;
2502
2480
  const fileSlice = toolkit.createSlice({
2503
2481
  name: "file",
2504
- initialState: initialState$h,
2505
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2482
+ initialState: initialState$f,
2483
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2506
2484
  reducers: {
2507
2485
  setUploadUrl: (state, action) => {
2508
2486
  const { url, fields, sha1 } = action.payload;
@@ -2529,7 +2507,7 @@ var __publicField = (obj, key, value) => {
2529
2507
  return url;
2530
2508
  };
2531
2509
  const fileReducer = fileSlice.reducer;
2532
- const initialState$g = {
2510
+ const initialState$e = {
2533
2511
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2534
2512
  mapStyle: MapStyle.SATELLITE,
2535
2513
  showTooltips: false,
@@ -2537,8 +2515,8 @@ var __publicField = (obj, key, value) => {
2537
2515
  };
2538
2516
  const mapSlice = toolkit.createSlice({
2539
2517
  name: "map",
2540
- initialState: initialState$g,
2541
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2518
+ initialState: initialState$e,
2519
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2542
2520
  reducers: {
2543
2521
  setMapStyle: (state, action) => {
2544
2522
  state.mapStyle = action.payload;
@@ -2607,7 +2585,7 @@ var __publicField = (obj, key, value) => {
2607
2585
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
2608
2586
  return LicenseStatus2;
2609
2587
  })(LicenseStatus || {});
2610
- const initialState$f = {
2588
+ const initialState$d = {
2611
2589
  users: {},
2612
2590
  currentUser: {
2613
2591
  id: 0,
@@ -2618,8 +2596,8 @@ var __publicField = (obj, key, value) => {
2618
2596
  };
2619
2597
  const userSlice = toolkit.createSlice({
2620
2598
  name: "users",
2621
- initialState: initialState$f,
2622
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2599
+ initialState: initialState$d,
2600
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2623
2601
  reducers: {
2624
2602
  setUsers: (state, action) => {
2625
2603
  const usersMapping = {};
@@ -2681,13 +2659,13 @@ var __publicField = (obj, key, value) => {
2681
2659
  const selectUsersAsMapping = (state) => state.userReducer.users;
2682
2660
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2683
2661
  const userReducer = userSlice.reducer;
2684
- const initialState$e = {
2662
+ const initialState$c = {
2685
2663
  organizationAccesses: {}
2686
2664
  };
2687
2665
  const organizationAccessSlice = toolkit.createSlice({
2688
2666
  name: "organizationAccess",
2689
- initialState: initialState$e,
2690
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2667
+ initialState: initialState$c,
2668
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2691
2669
  reducers: {
2692
2670
  setOrganizationAccesses: (state, action) => {
2693
2671
  if (!Array.isArray(action.payload))
@@ -2750,13 +2728,13 @@ var __publicField = (obj, key, value) => {
2750
2728
  return organizationAccesses;
2751
2729
  };
2752
2730
  const organizationAccessReducer = organizationAccessSlice.reducer;
2753
- const initialState$d = {
2731
+ const initialState$b = {
2754
2732
  licenses: {}
2755
2733
  };
2756
2734
  const licenseSlice = toolkit.createSlice({
2757
2735
  name: "license",
2758
- initialState: initialState$d,
2759
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2736
+ initialState: initialState$b,
2737
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2760
2738
  reducers: {
2761
2739
  setLicenses: (state, action) => {
2762
2740
  if (!Array.isArray(action.payload))
@@ -2801,13 +2779,13 @@ var __publicField = (obj, key, value) => {
2801
2779
  (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2802
2780
  );
2803
2781
  const licenseReducer = licenseSlice.reducer;
2804
- const initialState$c = {
2782
+ const initialState$a = {
2805
2783
  projectAccesses: {}
2806
2784
  };
2807
2785
  const projectAccessSlice = toolkit.createSlice({
2808
2786
  name: "projectAccess",
2809
- initialState: initialState$c,
2810
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2787
+ initialState: initialState$a,
2788
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2811
2789
  reducers: {
2812
2790
  setProjectAccesses: (state, action) => {
2813
2791
  if (!Array.isArray(action.payload))
@@ -2875,7 +2853,7 @@ var __publicField = (obj, key, value) => {
2875
2853
  return projectAccesses;
2876
2854
  };
2877
2855
  const projectAccessReducer = projectAccessSlice.reducer;
2878
- const initialState$b = {
2856
+ const initialState$9 = {
2879
2857
  projects: {},
2880
2858
  activeProjectId: null,
2881
2859
  recentProjectIds: [],
@@ -2885,7 +2863,7 @@ var __publicField = (obj, key, value) => {
2885
2863
  };
2886
2864
  const projectSlice = toolkit.createSlice({
2887
2865
  name: "projects",
2888
- initialState: initialState$b,
2866
+ initialState: initialState$9,
2889
2867
  reducers: {
2890
2868
  setProjects: (state, action) => {
2891
2869
  const projectsMap = {};
@@ -3072,14 +3050,14 @@ var __publicField = (obj, key, value) => {
3072
3050
  }
3073
3051
  )
3074
3052
  );
3075
- const initialState$a = {
3053
+ const initialState$8 = {
3076
3054
  organizations: {},
3077
3055
  activeOrganizationId: null
3078
3056
  };
3079
3057
  const organizationSlice = toolkit.createSlice({
3080
3058
  name: "organizations",
3081
- initialState: initialState$a,
3082
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
3059
+ initialState: initialState$8,
3060
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3083
3061
  reducers: {
3084
3062
  setOrganizations: (state, action) => {
3085
3063
  for (const org of action.payload) {
@@ -3198,14 +3176,14 @@ var __publicField = (obj, key, value) => {
3198
3176
  }
3199
3177
  };
3200
3178
  };
3201
- const initialState$9 = {
3179
+ const initialState$7 = {
3202
3180
  deletedRequests: [],
3203
3181
  latestRetryTime: 0
3204
3182
  };
3205
3183
  const outboxSlice = toolkit.createSlice({
3206
3184
  name: "outbox",
3207
- initialState: initialState$9,
3208
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
3185
+ initialState: initialState$7,
3186
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3209
3187
  reducers: {
3210
3188
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
3211
3189
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -3237,7 +3215,7 @@ var __publicField = (obj, key, value) => {
3237
3215
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
3238
3216
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
3239
3217
  const outboxReducer = outboxSlice.reducer;
3240
- const initialState$8 = {
3218
+ const initialState$6 = {
3241
3219
  projectFiles: {},
3242
3220
  activeProjectFileId: null,
3243
3221
  isImportingProjectFile: false,
@@ -3245,8 +3223,8 @@ var __publicField = (obj, key, value) => {
3245
3223
  };
3246
3224
  const projectFileSlice = toolkit.createSlice({
3247
3225
  name: "projectFiles",
3248
- initialState: initialState$8,
3249
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3226
+ initialState: initialState$6,
3227
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3250
3228
  reducers: {
3251
3229
  addOrReplaceProjectFiles: (state, action) => {
3252
3230
  for (let fileObj of action.payload) {
@@ -3347,12 +3325,12 @@ var __publicField = (obj, key, value) => {
3347
3325
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
3348
3326
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
3349
3327
  const projectFileReducer = projectFileSlice.reducer;
3350
- const initialState$7 = {
3328
+ const initialState$5 = {
3351
3329
  isRehydrated: false
3352
3330
  };
3353
3331
  const rehydratedSlice = toolkit.createSlice({
3354
3332
  name: "rehydrated",
3355
- initialState: initialState$7,
3333
+ initialState: initialState$5,
3356
3334
  // The `reducers` field lets us define reducers and generate associated actions
3357
3335
  reducers: {
3358
3336
  setRehydrated: (state, action) => {
@@ -3362,7 +3340,7 @@ var __publicField = (obj, key, value) => {
3362
3340
  });
3363
3341
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3364
3342
  const rehydratedReducer = rehydratedSlice.reducer;
3365
- const initialState$6 = {
3343
+ const initialState$4 = {
3366
3344
  useIssueTemplate: false,
3367
3345
  placementMode: false,
3368
3346
  enableClustering: false,
@@ -3379,8 +3357,8 @@ var __publicField = (obj, key, value) => {
3379
3357
  };
3380
3358
  const settingSlice = toolkit.createSlice({
3381
3359
  name: "settings",
3382
- initialState: initialState$6,
3383
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3360
+ initialState: initialState$4,
3361
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3384
3362
  reducers: {
3385
3363
  setEnableDuplicateIssues: (state, action) => {
3386
3364
  state.useIssueTemplate = action.payload;
@@ -3426,248 +3404,146 @@ var __publicField = (obj, key, value) => {
3426
3404
  const settingReducer = settingSlice.reducer;
3427
3405
  const selectIsFetchingInitialData = (state) => state.settingReducer.isFetchingInitialData;
3428
3406
  const selectIsLoading = (state) => state.settingReducer.isLoading;
3429
- const LATEST_FORM_REVISION_CACHE = {};
3430
- function considerCachingFormRevision(formRevision, formId2, preferPending = false) {
3407
+ const LATEST_REVISION_CACHE = {};
3408
+ function considerCachingRevision(revision, formId2, preferPending = false) {
3431
3409
  var _a2;
3432
- if (!formRevision) {
3410
+ if (!revision) {
3433
3411
  if (!formId2) {
3434
- throw new Error("If form revision is null, formId is required.");
3412
+ throw new Error("If revision is null, formId is required.");
3435
3413
  }
3436
- const currentLatestFormRevision = getLatestFormRevisionFromCache(formId2);
3437
- if (currentLatestFormRevision)
3414
+ const currentLatestRevision = getLatestRevisionFromCache(formId2);
3415
+ if (currentLatestRevision)
3438
3416
  return;
3439
- LATEST_FORM_REVISION_CACHE[formId2] = null;
3417
+ LATEST_REVISION_CACHE[formId2] = null;
3440
3418
  return;
3441
3419
  }
3442
- if (formRevision.revision === "Pending") {
3420
+ if (revision.revision === "Pending") {
3443
3421
  if (preferPending) {
3444
- LATEST_FORM_REVISION_CACHE[formRevision.form] = formRevision;
3422
+ LATEST_REVISION_CACHE[revision.form] = revision;
3445
3423
  }
3446
3424
  return;
3447
3425
  }
3448
- const cachedFormRevision = (_a2 = LATEST_FORM_REVISION_CACHE[formRevision.form]) == null ? void 0 : _a2.revision;
3449
- if (formRevision.revision > (typeof cachedFormRevision === "number" ? cachedFormRevision : -1)) {
3450
- LATEST_FORM_REVISION_CACHE[formRevision.form] = formRevision;
3426
+ const cachedRevision = (_a2 = LATEST_REVISION_CACHE[revision.form]) == null ? void 0 : _a2.revision;
3427
+ if (revision.revision > (typeof cachedRevision === "number" ? cachedRevision : -1)) {
3428
+ LATEST_REVISION_CACHE[revision.form] = revision;
3451
3429
  }
3452
3430
  }
3453
- function getLatestFormRevisionFromCache(formId2) {
3454
- return LATEST_FORM_REVISION_CACHE[formId2];
3431
+ function getLatestRevisionFromCache(formId2) {
3432
+ return LATEST_REVISION_CACHE[formId2];
3455
3433
  }
3456
- const initialState$5 = {
3457
- formRevisions: {},
3458
- attachments: {}
3459
- };
3460
- const formRevisionsSlice = toolkit.createSlice({
3461
- name: "formRevisions",
3462
- initialState: initialState$5,
3463
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3434
+ const initialState$3 = {
3435
+ userForms: {},
3436
+ revisions: {},
3437
+ submissions: {},
3438
+ submissionAttachments: {},
3439
+ revisionAttachments: {}
3440
+ };
3441
+ const userFormSlice = toolkit.createSlice({
3442
+ name: "userForms",
3443
+ initialState: initialState$3,
3444
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3464
3445
  reducers: {
3465
- // revision related actions
3466
- setFormRevision: (state, action) => {
3467
- state.formRevisions[action.payload.offline_id] = action.payload;
3468
- considerCachingFormRevision(action.payload);
3446
+ setUserForms: (state, action) => {
3447
+ state.userForms = {};
3448
+ action.payload.forEach((userForm) => {
3449
+ state.userForms[userForm.offline_id] = userForm;
3450
+ });
3469
3451
  },
3470
- setFormRevisions: (state, action) => {
3471
- state.formRevisions = {};
3472
- for (const revision of action.payload) {
3473
- state.formRevisions[revision.offline_id] = revision;
3474
- considerCachingFormRevision(revision);
3475
- }
3452
+ addUserForm: (state, action) => {
3453
+ state.userForms[action.payload.offline_id] = action.payload;
3476
3454
  },
3477
- addFormRevision: (state, action) => {
3478
- if (state.formRevisions[action.payload.offline_id] !== void 0) {
3479
- throw new Error(`Revision with offline_id ${action.payload.offline_id} already exists`);
3480
- }
3481
- state.formRevisions[action.payload.offline_id] = action.payload;
3482
- considerCachingFormRevision(action.payload);
3455
+ addUserForms: (state, action) => {
3456
+ action.payload.forEach((userForm) => {
3457
+ state.userForms[userForm.offline_id] = userForm;
3458
+ });
3483
3459
  },
3484
- // TODO: @Audiopolis / Magnus - do we want to standardize using PayloadAction?
3485
- addFormRevisions: (state, action) => {
3486
- for (const userFormRevision of action.payload) {
3487
- if (state.formRevisions[userFormRevision.offline_id] !== void 0) {
3488
- throw new Error(`Revision with offline_id ${userFormRevision.offline_id} already exists`);
3489
- }
3490
- }
3491
- for (const userFormRevision of action.payload) {
3492
- state.formRevisions[userFormRevision.offline_id] = userFormRevision;
3493
- considerCachingFormRevision(userFormRevision);
3494
- }
3460
+ addUserFormRevisions: (state, action) => {
3461
+ action.payload.forEach((userFormRevision) => {
3462
+ state.revisions[userFormRevision.offline_id] = userFormRevision;
3463
+ considerCachingRevision(userFormRevision);
3464
+ });
3495
3465
  },
3496
- // UserFormRevisions do not get updated
3497
- deleteFormRevision: (state, action) => {
3498
- if (state.formRevisions[action.payload] === void 0) {
3499
- throw new Error(`Revision with offline_id ${action.payload} does not exist`);
3500
- }
3501
- delete state.formRevisions[action.payload];
3502
- delete LATEST_FORM_REVISION_CACHE[action.payload];
3466
+ addUserFormRevision: (state, action) => {
3467
+ state.revisions[action.payload.offline_id] = action.payload;
3468
+ considerCachingRevision(action.payload);
3503
3469
  },
3504
- deleteFormRevisions: (state, action) => {
3505
- for (const offlineId of action.payload) {
3506
- if (state.formRevisions[offlineId] === void 0) {
3507
- throw new Error(`Revision with offline_id ${offlineId} does not exist`);
3508
- }
3509
- }
3510
- for (const offlineId of action.payload) {
3511
- delete state.formRevisions[offlineId];
3512
- delete LATEST_FORM_REVISION_CACHE[offlineId];
3470
+ deleteUserFormRevision: (state, action) => {
3471
+ delete state.revisions[action.payload];
3472
+ delete LATEST_REVISION_CACHE[action.payload];
3473
+ },
3474
+ deleteUserFormRevisions: (state, action) => {
3475
+ for (const userFormRevision of action.payload) {
3476
+ delete state.revisions[userFormRevision.offline_id];
3477
+ delete LATEST_REVISION_CACHE[userFormRevision.offline_id];
3513
3478
  }
3514
3479
  },
3515
- // attachment related actions
3516
- setFormRevisionAttachments: (state, action) => {
3517
- state.attachments = {};
3518
- for (const attachment of action.payload) {
3519
- state.attachments[attachment.offline_id] = attachment;
3480
+ updateOrCreateUserFormSubmission: (state, action) => {
3481
+ state.submissions[action.payload.offline_id] = action.payload;
3482
+ },
3483
+ addUserFormSubmissionAttachment: (state, action) => {
3484
+ const submissionId = action.payload.submission;
3485
+ const submissionAttachments = state.submissionAttachments[submissionId];
3486
+ if (submissionAttachments) {
3487
+ submissionAttachments.push(action.payload);
3488
+ } else {
3489
+ state.submissionAttachments[submissionId] = [action.payload];
3520
3490
  }
3521
3491
  },
3522
- addFormRevisionAttachment: (state, action) => {
3523
- if (state.attachments[action.payload.offline_id] !== void 0) {
3524
- throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3492
+ addUserFormRevisionAttachment: (state, action) => {
3493
+ const revisionId = action.payload.revision;
3494
+ const revisionAttachments = state.revisionAttachments[revisionId];
3495
+ if (revisionAttachments) {
3496
+ revisionAttachments.push(action.payload);
3497
+ } else {
3498
+ state.revisionAttachments[revisionId] = [action.payload];
3525
3499
  }
3526
- state.attachments[action.payload.offline_id] = action.payload;
3527
3500
  },
3528
- addFormRevisionAttachments: (state, action) => {
3501
+ setUserFormSubmissionAttachments: (state, action) => {
3502
+ state.submissionAttachments = {};
3529
3503
  for (const attachment of action.payload) {
3530
- if (state.attachments[attachment.offline_id] !== void 0) {
3531
- throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3504
+ const submissionId = attachment.submission;
3505
+ const submissionAttachments = state.submissionAttachments[submissionId];
3506
+ if (submissionAttachments) {
3507
+ submissionAttachments.push(attachment);
3508
+ } else {
3509
+ state.submissionAttachments[submissionId] = [attachment];
3532
3510
  }
3533
3511
  }
3512
+ },
3513
+ setUserFormRevisionAttachments: (state, action) => {
3514
+ state.revisionAttachments = {};
3534
3515
  for (const attachment of action.payload) {
3535
- state.attachments[attachment.offline_id] = attachment;
3516
+ const revisionId = attachment.revision;
3517
+ const revisionAttachments = state.revisionAttachments[revisionId];
3518
+ if (revisionAttachments) {
3519
+ revisionAttachments.push(attachment);
3520
+ } else {
3521
+ state.revisionAttachments[revisionId] = [attachment];
3522
+ }
3536
3523
  }
3537
3524
  },
3538
- deleteFormRevisionAttachment: (state, action) => {
3539
- if (state.attachments[action.payload] === void 0) {
3540
- throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3541
- }
3542
- delete state.attachments[action.payload];
3525
+ deleteUserFormSubmission: (state, action) => {
3526
+ delete state.submissions[action.payload];
3543
3527
  },
3544
- deleteFormRevisionAttachments: (state, action) => {
3545
- for (const offlineId of action.payload) {
3546
- if (state.attachments[offlineId] === void 0) {
3547
- throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3548
- }
3549
- }
3550
- for (const offlineId of action.payload) {
3551
- delete state.attachments[offlineId];
3552
- }
3553
- }
3554
- }
3555
- });
3556
- const {
3557
- setFormRevision,
3558
- setFormRevisions,
3559
- addFormRevision,
3560
- addFormRevisions,
3561
- deleteFormRevision,
3562
- deleteFormRevisions,
3563
- setFormRevisionAttachments,
3564
- addFormRevisionAttachment,
3565
- addFormRevisionAttachments,
3566
- deleteFormRevisionAttachment,
3567
- deleteFormRevisionAttachments
3568
- } = formRevisionsSlice.actions;
3569
- const selectFormRevisionMapping = (state) => state.formRevisionReducer.formRevisions;
3570
- const selectFormRevisions = toolkit.createSelector(
3571
- [selectFormRevisionMapping],
3572
- (formRevisions) => Object.values(formRevisions)
3573
- );
3574
- const selectFormRevision = (formRevisionId) => (state) => {
3575
- return state.formRevisionReducer.formRevisions[formRevisionId];
3576
- };
3577
- const _selectLatestFormRevision = (formRevisions, formId2) => {
3578
- let ret = null;
3579
- for (const candidate of Object.values(formRevisions)) {
3580
- if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3581
- ret = candidate;
3582
- }
3583
- }
3584
- if (!ret) {
3585
- throw new Error("No form revision found for form " + formId2);
3586
- }
3587
- return ret;
3588
- };
3589
- const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
3590
- toolkit.createSelector([selectFormRevisionMapping, (_state, formId2) => formId2], (revisions, formId2) => {
3591
- if (!formId2) {
3592
- throw new Error("formId is required");
3593
- }
3594
- return _selectLatestFormRevision(revisions, formId2);
3595
- })
3596
- );
3597
- const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
3598
- toolkit.createSelector([selectFormRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3599
- return revisions.filter((revision) => {
3600
- return revision.form === formId2;
3601
- });
3602
- })
3603
- );
3604
- const selectLatestFormRevisionsOfComponentTypes = restructureCreateSelectorWithArgs(
3605
- toolkit.createSelector(
3606
- [
3607
- (state) => state.formReducer.forms,
3608
- selectFormRevisionMapping,
3609
- (_state, componentTypeIds) => componentTypeIds
3610
- ],
3611
- (userForms, revisions, componentTypeIds) => {
3612
- const componentTypeIdsSet = new Set(componentTypeIds);
3613
- const ret = {};
3614
- for (const form of Object.values(userForms)) {
3615
- if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3616
- ret[form.component_type] = _selectLatestFormRevision(revisions, form.offline_id);
3617
- }
3528
+ deleteUserFormSubmissions: (state, action) => {
3529
+ for (const userFormSubmission of action.payload) {
3530
+ delete state.submissions[userFormSubmission.offline_id];
3618
3531
  }
3619
- return ret;
3620
- }
3621
- )
3622
- );
3623
- const selectLatestFormRevisionByForm = toolkit.createSelector([selectFormRevisionMapping], (revisions) => {
3624
- const latestRevisions = {};
3625
- for (const revision of Object.values(revisions)) {
3626
- const formId2 = revision.form;
3627
- const currentLatestRevision = latestRevisions[formId2];
3628
- if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3629
- latestRevisions[formId2] = revision;
3630
- }
3631
- }
3632
- return latestRevisions;
3633
- });
3634
- const selectUserFormRevisionAttachmentsMapping = (state) => {
3635
- return state.formRevisionReducer.attachments;
3636
- };
3637
- const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
3638
- toolkit.createSelector(
3639
- [selectUserFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
3640
- (attachments, revisionId) => {
3641
- return Object.values(attachments).filter((attachment) => attachment.revision === revisionId);
3642
- }
3643
- )
3644
- );
3645
- const formRevisionReducer = formRevisionsSlice.reducer;
3646
- const initialState$4 = {
3647
- forms: {}
3648
- };
3649
- const formSlice = toolkit.createSlice({
3650
- name: "forms",
3651
- initialState: initialState$4,
3652
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3653
- reducers: {
3654
- setForms: (state, action) => {
3655
- state.forms = {};
3656
- action.payload.forEach((userForm) => {
3657
- state.forms[userForm.offline_id] = userForm;
3658
- });
3659
3532
  },
3660
- addForm: (state, action) => {
3661
- state.forms[action.payload.offline_id] = action.payload;
3533
+ addUserFormSubmissions: (state, action) => {
3534
+ for (const submission of action.payload) {
3535
+ state.submissions[submission.offline_id] = submission;
3536
+ }
3662
3537
  },
3663
- addForms: (state, action) => {
3664
- action.payload.forEach((userForm) => {
3665
- state.forms[userForm.offline_id] = userForm;
3538
+ setUserFormSubmissions: (state, action) => {
3539
+ state.submissions = {};
3540
+ action.payload.forEach((submission) => {
3541
+ state.submissions[submission.offline_id] = submission;
3666
3542
  });
3667
3543
  },
3668
3544
  favoriteForm: (state, action) => {
3669
3545
  const { formId: formId2 } = action.payload;
3670
- const form = state.forms[formId2];
3546
+ const form = state.userForms[formId2];
3671
3547
  if (!form) {
3672
3548
  throw new Error("No form exists with the id " + formId2);
3673
3549
  }
@@ -3675,23 +3551,48 @@ var __publicField = (obj, key, value) => {
3675
3551
  },
3676
3552
  unfavoriteForm: (state, action) => {
3677
3553
  const { formId: formId2 } = action.payload;
3678
- const form = state.forms[formId2];
3554
+ const form = state.userForms[formId2];
3679
3555
  if (!form) {
3680
3556
  throw new Error("No form exists with the id " + formId2);
3681
3557
  }
3682
3558
  form.favorite = false;
3683
3559
  },
3684
- deleteForm: (state, action) => {
3685
- delete state.forms[action.payload];
3560
+ deleteUserForm: (state, action) => {
3561
+ delete state.userForms[action.payload];
3686
3562
  }
3687
3563
  }
3688
3564
  });
3689
- const { setForms, addForm, addForms, favoriteForm, unfavoriteForm, deleteForm } = formSlice.actions;
3690
- const selectFilteredForms = restructureCreateSelectorWithArgs(
3565
+ const {
3566
+ addUserForm,
3567
+ addUserForms,
3568
+ addUserFormRevisions,
3569
+ updateOrCreateUserFormSubmission,
3570
+ addUserFormSubmissions,
3571
+ deleteUserFormSubmission,
3572
+ deleteUserFormSubmissions,
3573
+ favoriteForm,
3574
+ unfavoriteForm,
3575
+ deleteUserForm,
3576
+ deleteUserFormRevision,
3577
+ deleteUserFormRevisions,
3578
+ setUserFormSubmissions,
3579
+ addUserFormRevision,
3580
+ addUserFormSubmissionAttachment,
3581
+ addUserFormRevisionAttachment,
3582
+ setUserFormSubmissionAttachments,
3583
+ setUserFormRevisionAttachments
3584
+ } = userFormSlice.actions;
3585
+ const selectSubmissionAttachments = (submissionId) => (state) => {
3586
+ return state.userFormReducer.submissionAttachments[submissionId] || [];
3587
+ };
3588
+ const selectRevisionAttachments = (revisionId) => (state) => {
3589
+ return state.userFormReducer.revisionAttachments[revisionId] || [];
3590
+ };
3591
+ const selectFilteredUserForms = restructureCreateSelectorWithArgs(
3691
3592
  toolkit.createSelector(
3692
3593
  [
3693
- (state) => state.formReducer.forms,
3694
- (state) => state.formRevisionReducer.formRevisions,
3594
+ (state) => state.userFormReducer.userForms,
3595
+ (state) => state.userFormReducer.revisions,
3695
3596
  (_state, search) => search
3696
3597
  ],
3697
3598
  (userForms, revisions, search) => {
@@ -3725,188 +3626,63 @@ var __publicField = (obj, key, value) => {
3725
3626
  { memoizeOptions: { equalityCheck: reactRedux.shallowEqual } }
3726
3627
  )
3727
3628
  );
3728
- const selectForm = (formId2) => (state) => {
3729
- return state.formReducer.forms[formId2];
3629
+ const selectFormRevision = (revisionId) => (state) => {
3630
+ return state.userFormReducer.revisions[revisionId];
3730
3631
  };
3731
- const selectFormMapping = (state) => {
3732
- return state.formReducer.forms;
3632
+ const _selectLatestFormRevision = (revisions, formId2) => {
3633
+ let ret = null;
3634
+ for (const candidate of Object.values(revisions)) {
3635
+ if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3636
+ ret = candidate;
3637
+ }
3638
+ }
3639
+ if (!ret) {
3640
+ throw new Error("No revision found for form " + formId2);
3641
+ }
3642
+ return ret;
3733
3643
  };
3734
- const selectFormOfComponentType = restructureCreateSelectorWithArgs(
3644
+ const selectLatestFormRevision = restructureCreateSelectorWithArgs(
3735
3645
  toolkit.createSelector(
3736
- [selectFormMapping, (_state, componentTypeId) => componentTypeId],
3737
- (userForms, componentTypeId) => {
3738
- return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3646
+ [(state) => state.userFormReducer.revisions, (_state, formId2) => formId2],
3647
+ (revisions, formId2) => {
3648
+ if (!formId2) {
3649
+ throw new Error("formId is required");
3650
+ }
3651
+ return _selectLatestFormRevision(revisions, formId2);
3739
3652
  }
3740
3653
  )
3741
3654
  );
3742
- const selectFormsCount = toolkit.createSelector([selectFormMapping], (userForms) => {
3743
- return Object.keys(userForms).length;
3744
- });
3745
- const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (userForms) => {
3746
- return Object.values(userForms).filter((form) => !form.component_type).length;
3747
- });
3748
- const formReducer = formSlice.reducer;
3749
- const initialState$3 = {
3750
- formSubmissions: {},
3751
- attachments: {}
3752
- };
3753
- const formSubmissionSlice = toolkit.createSlice({
3754
- name: "formSubmissions",
3755
- initialState: initialState$3,
3756
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3757
- reducers: {
3758
- setFormSubmission: (state, action) => {
3759
- state.formSubmissions[action.payload.offline_id] = action.payload;
3760
- },
3761
- setFormSubmissions: (state, action) => {
3762
- state.formSubmissions = {};
3763
- for (const submission of action.payload) {
3764
- state.formSubmissions[submission.offline_id] = submission;
3765
- }
3766
- },
3767
- addFormSubmission: (state, action) => {
3768
- if (state.formSubmissions[action.payload.offline_id] !== void 0) {
3769
- throw new Error(`Submission with offline_id ${action.payload.offline_id} already exists`);
3770
- }
3771
- state.formSubmissions[action.payload.offline_id] = action.payload;
3772
- },
3773
- addFormSubmissions: (state, action) => {
3774
- for (const submission of action.payload) {
3775
- if (state.formSubmissions[submission.offline_id] !== void 0) {
3776
- throw new Error(`Submission with offline_id ${submission.offline_id} already exists`);
3777
- }
3778
- }
3779
- for (const submission of action.payload) {
3780
- state.formSubmissions[submission.offline_id] = submission;
3781
- }
3782
- },
3783
- updateFormSubmission: (state, action) => {
3784
- if (state.formSubmissions[action.payload.offline_id] === void 0) {
3785
- throw new Error(`Submission with offline_id ${action.payload.offline_id} does not exist`);
3786
- }
3787
- state.formSubmissions[action.payload.offline_id] = action.payload;
3788
- },
3789
- updateFormSubmissions: (state, action) => {
3790
- for (const submission of action.payload) {
3791
- if (state.formSubmissions[submission.offline_id] === void 0) {
3792
- throw new Error(`Submission with offline_id ${submission.offline_id} does not exist`);
3793
- }
3794
- }
3795
- for (const submission of action.payload) {
3796
- state.formSubmissions[submission.offline_id] = submission;
3797
- }
3798
- },
3799
- deleteFormSubmission: (state, action) => {
3800
- if (state.formSubmissions[action.payload] === void 0) {
3801
- throw new Error(`Submission with offline_id ${action.payload} does not exist`);
3802
- }
3803
- delete state.formSubmissions[action.payload];
3804
- },
3805
- deleteFormSubmissions: (state, action) => {
3806
- for (const offlineId of action.payload) {
3807
- if (state.formSubmissions[offlineId] === void 0) {
3808
- throw new Error(`Submission with offline_id ${offlineId} does not exist`);
3809
- }
3810
- delete state.formSubmissions[offlineId];
3811
- }
3812
- for (const offlineId of action.payload) {
3813
- delete state.formSubmissions[offlineId];
3814
- }
3815
- },
3816
- // Attachments
3817
- addFormSubmissionAttachment: (state, action) => {
3818
- if (state.attachments[action.payload.offline_id] !== void 0) {
3819
- throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3820
- }
3821
- state.attachments[action.payload.offline_id] = action.payload;
3822
- },
3823
- addFormSubmissionAttachments: (state, action) => {
3824
- for (const attachment of action.payload) {
3825
- if (state.attachments[attachment.offline_id] !== void 0) {
3826
- throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3827
- }
3828
- }
3829
- for (const attachment of action.payload) {
3830
- state.attachments[attachment.offline_id] = attachment;
3831
- }
3832
- },
3833
- // We only need a multi set for attachments because they are not updated, only added and deleted
3834
- setFormSubmissionAttachments: (state, action) => {
3835
- state.attachments = {};
3836
- for (const attachment of action.payload) {
3837
- state.attachments[attachment.offline_id] = attachment;
3838
- }
3839
- },
3840
- updateFormSubmissionAttachments: (state, action) => {
3841
- for (const attachment of action.payload) {
3842
- if (state.attachments[attachment.offline_id] === void 0) {
3843
- throw new Error(`Attachment with offline_id ${attachment.offline_id} does not exist`);
3844
- }
3845
- }
3846
- for (const attachment of action.payload) {
3847
- state.attachments[attachment.offline_id] = attachment;
3848
- }
3849
- },
3850
- // The delete actions for UserFormSubmissionAttachments are not used in the app, but are included for completeness
3851
- // Could be used if editing a submission is ever supported, will be applicable for supporting tip tap content in submissions
3852
- deleteFormSubmissionAttachment: (state, action) => {
3853
- if (state.attachments[action.payload] === void 0) {
3854
- throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3855
- }
3856
- delete state.attachments[action.payload];
3857
- },
3858
- deleteFormSubmissionAttachments: (state, action) => {
3859
- for (const offlineId of action.payload) {
3860
- if (state.attachments[offlineId] === void 0) {
3861
- throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3862
- }
3863
- delete state.attachments[offlineId];
3864
- }
3865
- }
3866
- }
3867
- });
3868
- const {
3869
- setFormSubmission,
3870
- setFormSubmissions,
3871
- addFormSubmission,
3872
- addFormSubmissions,
3873
- updateFormSubmission,
3874
- updateFormSubmissions,
3875
- deleteFormSubmission,
3876
- deleteFormSubmissions,
3877
- addFormSubmissionAttachment,
3878
- addFormSubmissionAttachments,
3879
- setFormSubmissionAttachments,
3880
- updateFormSubmissionAttachments,
3881
- deleteFormSubmissionAttachment,
3882
- deleteFormSubmissionAttachments
3883
- } = formSubmissionSlice.actions;
3884
- const selectFormSubmissionsMapping = (state) => {
3885
- return state.formSubmissionReducer.formSubmissions;
3886
- };
3887
- const selectFormSubmissions = toolkit.createSelector(
3888
- [selectFormSubmissionsMapping],
3889
- (submissions) => {
3890
- return Object.values(submissions);
3891
- }
3655
+ const selectUserForm = (formId2) => (state) => {
3656
+ return state.userFormReducer.userForms[formId2];
3657
+ };
3658
+ const selectSubmissionMapping = (state) => state.userFormReducer.submissions;
3659
+ const selectUserFormSubmission = (submissionId) => (state) => {
3660
+ return state.userFormReducer.submissions[submissionId];
3661
+ };
3662
+ const selectSubmissions = toolkit.createSelector([selectSubmissionMapping], (submissions) => Object.values(submissions));
3663
+ const selectRevisionMapping = (state) => state.userFormReducer.revisions;
3664
+ const selectRevisions = toolkit.createSelector([selectRevisionMapping], (revisions) => Object.values(revisions));
3665
+ const selectRevisionsForForm = restructureCreateSelectorWithArgs(
3666
+ toolkit.createSelector([selectRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3667
+ return revisions.filter((revision) => {
3668
+ return revision.form === formId2;
3669
+ });
3670
+ })
3892
3671
  );
3893
- const selectFormSubmission = (submissionId) => (state) => {
3894
- return state.formSubmissionReducer.formSubmissions[submissionId];
3895
- };
3896
- const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
3672
+ const selectSubmissionsForForm = restructureCreateSelectorWithArgs(
3897
3673
  toolkit.createSelector(
3898
- [selectFormSubmissions, selectFormRevisionMapping, (_state, formId2) => formId2],
3674
+ [selectSubmissions, selectRevisionMapping, (_state, formId2) => formId2],
3899
3675
  (submissions, revisionMapping, formId2) => {
3900
- return submissions.filter((submission) => {
3676
+ return Object.values(submissions).filter((submission) => {
3901
3677
  const revision = revisionMapping[submission.form_revision];
3902
3678
  return (revision == null ? void 0 : revision.form) === formId2;
3903
3679
  });
3904
3680
  }
3905
3681
  )
3906
3682
  );
3907
- const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
3683
+ const selectSubmissionsForIssue = restructureCreateSelectorWithArgs(
3908
3684
  toolkit.createSelector(
3909
- [selectFormSubmissions, (_state, issueId) => issueId],
3685
+ [(state) => state.userFormReducer.submissions, (_state, issueId) => issueId],
3910
3686
  (submissions, issueId) => {
3911
3687
  return Object.values(submissions).filter((submission) => {
3912
3688
  return submission.issue === issueId;
@@ -3914,9 +3690,9 @@ var __publicField = (obj, key, value) => {
3914
3690
  }
3915
3691
  )
3916
3692
  );
3917
- const selectFormSubmissionsOfComponent = restructureCreateSelectorWithArgs(
3693
+ const selectSubmissionsForComponent = restructureCreateSelectorWithArgs(
3918
3694
  toolkit.createSelector(
3919
- [selectFormSubmissions, (_state, componentId) => componentId],
3695
+ [selectSubmissions, (_state, componentId) => componentId],
3920
3696
  (submissions, componentId) => {
3921
3697
  return submissions.filter((submission) => {
3922
3698
  return submission.component === componentId;
@@ -3924,8 +3700,8 @@ var __publicField = (obj, key, value) => {
3924
3700
  }
3925
3701
  )
3926
3702
  );
3927
- const selectFormSubmissionsByComponents = toolkit.createSelector(
3928
- [selectFormSubmissionsMapping, selectComponentsMapping],
3703
+ const selectComponentSubmissionMapping = toolkit.createSelector(
3704
+ [selectSubmissionMapping, selectComponentsMapping],
3929
3705
  (submissions, components) => {
3930
3706
  var _a2;
3931
3707
  const componentSubmissionMapping = {};
@@ -3941,18 +3717,54 @@ var __publicField = (obj, key, value) => {
3941
3717
  return componentSubmissionMapping;
3942
3718
  }
3943
3719
  );
3944
- const selectFormSubmissionAttachmentsMapping = (state) => {
3945
- return state.formSubmissionReducer.attachments;
3720
+ const selectUserFormMapping = (state) => {
3721
+ return state.userFormReducer.userForms;
3946
3722
  };
3947
- const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
3723
+ const selectComponentTypeForm = restructureCreateSelectorWithArgs(
3948
3724
  toolkit.createSelector(
3949
- [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
3950
- (attachmentsMapping, submissionId) => {
3951
- return Object.values(attachmentsMapping).filter((attachment) => attachment.submission === submissionId);
3725
+ [selectUserFormMapping, (_state, componentTypeId) => componentTypeId],
3726
+ (userForms, componentTypeId) => {
3727
+ return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3728
+ }
3729
+ )
3730
+ );
3731
+ const selectLatestRevisionsFromComponentTypeIds = restructureCreateSelectorWithArgs(
3732
+ toolkit.createSelector(
3733
+ [
3734
+ selectUserFormMapping,
3735
+ selectRevisionMapping,
3736
+ (_state, componentTypeIds) => componentTypeIds
3737
+ ],
3738
+ (userForms, revisions, componentTypeIds) => {
3739
+ const componentTypeIdsSet = new Set(componentTypeIds);
3740
+ const ret = {};
3741
+ for (const form of Object.values(userForms)) {
3742
+ if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3743
+ ret[form.component_type] = _selectLatestFormRevision(revisions, form.offline_id);
3744
+ }
3745
+ }
3746
+ return ret;
3952
3747
  }
3953
3748
  )
3954
3749
  );
3955
- const formSubmissionReducer = formSubmissionSlice.reducer;
3750
+ const selectLatestRevisionByFormId = toolkit.createSelector([selectRevisionMapping], (revisions) => {
3751
+ const latestRevisions = {};
3752
+ for (const revision of Object.values(revisions)) {
3753
+ const formId2 = revision.form;
3754
+ const currentLatestRevision = latestRevisions[formId2];
3755
+ if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3756
+ latestRevisions[formId2] = revision;
3757
+ }
3758
+ }
3759
+ return latestRevisions;
3760
+ });
3761
+ const selectNumberOfUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3762
+ return Object.keys(userForms).length;
3763
+ });
3764
+ const selectNumberOfGeneralUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3765
+ return Object.values(userForms).filter((form) => !form.component_type).length;
3766
+ });
3767
+ const userFormReducer = userFormSlice.reducer;
3956
3768
  const initialState$2 = {
3957
3769
  emailDomains: {}
3958
3770
  };
@@ -4180,9 +3992,6 @@ var __publicField = (obj, key, value) => {
4180
3992
  [selectDocumentAttachmentMapping],
4181
3993
  (mapping) => Object.values(mapping)
4182
3994
  );
4183
- const selectDocumentAttachment = (attachmentId) => (state) => {
4184
- return state.documentsReducer.attachments[attachmentId];
4185
- };
4186
3995
  const selectAttachmentsOfDocument = restructureCreateSelectorWithArgs(
4187
3996
  toolkit.createSelector(
4188
3997
  [selectAllDocumentAttachments, (_state, documentId) => documentId],
@@ -4250,9 +4059,7 @@ var __publicField = (obj, key, value) => {
4250
4059
  projectFileReducer,
4251
4060
  rehydratedReducer,
4252
4061
  settingReducer,
4253
- formReducer,
4254
- formRevisionReducer,
4255
- formSubmissionReducer,
4062
+ userFormReducer,
4256
4063
  userReducer,
4257
4064
  workspaceReducer,
4258
4065
  emailDomainsReducer,
@@ -4305,7 +4112,9 @@ var __publicField = (obj, key, value) => {
4305
4112
  throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
4306
4113
  }
4307
4114
  }
4308
- const indexedForms = Object.values(draft.formReducer.forms).filter((form) => form.index_workspace === workspaceId);
4115
+ const indexedForms = Object.values(draft.userFormReducer.userForms).filter(
4116
+ (form) => form.index_workspace === workspaceId
4117
+ );
4309
4118
  for (const form of indexedForms) {
4310
4119
  form.index_workspace = mainWorkspace.offline_id;
4311
4120
  }
@@ -6942,7 +6751,7 @@ var __publicField = (obj, key, value) => {
6942
6751
  ...revisionAttachmentPayload,
6943
6752
  file: URL.createObjectURL(image)
6944
6753
  };
6945
- store.dispatch(addFormRevisionAttachment(offlinePayload));
6754
+ store.dispatch(addUserFormRevisionAttachment(offlinePayload));
6946
6755
  return attach;
6947
6756
  });
6948
6757
  });
@@ -6976,8 +6785,8 @@ var __publicField = (obj, key, value) => {
6976
6785
  revision: 0
6977
6786
  };
6978
6787
  const { store } = this.client;
6979
- store.dispatch(addForm(retForm));
6980
- store.dispatch(addFormRevision(retRevision));
6788
+ store.dispatch(addUserForm(retForm));
6789
+ store.dispatch(addUserFormRevision(retRevision));
6981
6790
  const formPromise = this.enqueueRequest({
6982
6791
  description: "Create form",
6983
6792
  method: HttpMethod.POST,
@@ -6995,8 +6804,8 @@ var __publicField = (obj, key, value) => {
6995
6804
  });
6996
6805
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
6997
6806
  void formPromise.catch((e) => {
6998
- store.dispatch(deleteForm(retForm.offline_id));
6999
- store.dispatch(deleteFormRevision(retRevision.offline_id));
6807
+ store.dispatch(deleteUserForm(retForm.offline_id));
6808
+ store.dispatch(deleteUserFormRevision(retRevision.offline_id));
7000
6809
  throw e;
7001
6810
  });
7002
6811
  const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
@@ -7038,7 +6847,7 @@ var __publicField = (obj, key, value) => {
7038
6847
  revision: "Pending",
7039
6848
  form: formId2
7040
6849
  };
7041
- store.dispatch(addFormRevision(fullRevision));
6850
+ store.dispatch(addUserFormRevision(fullRevision));
7042
6851
  const promise = this.enqueueRequest({
7043
6852
  description: "Create form revision",
7044
6853
  method: HttpMethod.PATCH,
@@ -7052,9 +6861,9 @@ var __publicField = (obj, key, value) => {
7052
6861
  });
7053
6862
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevision.offline_id);
7054
6863
  void promise.then((result) => {
7055
- store.dispatch(setFormRevision(result));
6864
+ store.dispatch(addUserFormRevision(result));
7056
6865
  }).catch(() => {
7057
- store.dispatch(deleteFormRevision(fullRevision.offline_id));
6866
+ store.dispatch(deleteUserFormRevision(fullRevision.offline_id));
7058
6867
  });
7059
6868
  const settledPromise = Promise.all([promise, ...attachImagesPromises]).then(() => promise);
7060
6869
  return [fullRevision, settledPromise];
@@ -7096,19 +6905,19 @@ var __publicField = (obj, key, value) => {
7096
6905
  async delete(formId2) {
7097
6906
  const { store } = this.client;
7098
6907
  const state = store.getState();
7099
- const userForm = selectForm(formId2)(state);
6908
+ const userForm = selectUserForm(formId2)(state);
7100
6909
  if (!userForm) {
7101
6910
  throw new Error("Expected userForm to exist");
7102
6911
  }
7103
- const userFormSubmissions = selectFormSubmissionsOfForm(formId2)(state);
6912
+ const userFormSubmissions = selectSubmissionsForForm(formId2)(state);
7104
6913
  if (userFormSubmissions && userFormSubmissions.length > 0) {
7105
- store.dispatch(deleteFormSubmissions(userFormSubmissions.map(({ offline_id }) => offline_id)));
6914
+ store.dispatch(deleteUserFormSubmissions(userFormSubmissions));
7106
6915
  }
7107
- const userFormRevisions = selectFormRevisionsOfForm(formId2)(state);
6916
+ const userFormRevisions = selectRevisionsForForm(formId2)(state);
7108
6917
  if (userFormRevisions && userFormRevisions.length > 0) {
7109
- store.dispatch(deleteFormRevisions(userFormRevisions.map(({ offline_id }) => offline_id)));
6918
+ store.dispatch(deleteUserFormRevisions(userFormRevisions));
7110
6919
  }
7111
- store.dispatch(deleteForm(formId2));
6920
+ store.dispatch(deleteUserForm(formId2));
7112
6921
  try {
7113
6922
  return await this.enqueueRequest({
7114
6923
  description: "Delete form",
@@ -7118,12 +6927,12 @@ var __publicField = (obj, key, value) => {
7118
6927
  blocks: []
7119
6928
  });
7120
6929
  } catch (e) {
7121
- store.dispatch(addForm(userForm));
6930
+ store.dispatch(addUserForm(userForm));
7122
6931
  if (userFormRevisions && userFormRevisions.length > 0) {
7123
- store.dispatch(addFormRevisions(userFormRevisions));
6932
+ store.dispatch(addUserFormRevisions(userFormRevisions));
7124
6933
  }
7125
6934
  if (userFormSubmissions && userFormSubmissions.length > 0) {
7126
- store.dispatch(addFormSubmissions(userFormSubmissions));
6935
+ store.dispatch(addUserFormSubmissions(userFormSubmissions));
7127
6936
  }
7128
6937
  throw e;
7129
6938
  }
@@ -7137,15 +6946,16 @@ var __publicField = (obj, key, value) => {
7137
6946
  blockers: [],
7138
6947
  blocks: []
7139
6948
  });
7140
- store.dispatch(setForms(Object.values(result.forms)));
7141
- store.dispatch(setFormRevisions(Object.values(result.revisions)));
7142
- store.dispatch(setFormRevisionAttachments(Object.values(result.attachments)));
6949
+ store.dispatch(addUserForms(Object.values(result.forms)));
6950
+ store.dispatch(addUserFormRevisions(Object.values(result.revisions)));
6951
+ store.dispatch(setUserFormRevisionAttachments(Object.values(result.attachments)));
7143
6952
  }
7144
6953
  }
7145
6954
  const isArrayOfFiles = (value) => {
7146
6955
  return Array.isArray(value) && value[0] instanceof File;
7147
6956
  };
7148
- const separateFilesFromValues = (values) => {
6957
+ const separateFilesFromValues = (payload) => {
6958
+ const { values } = payload;
7149
6959
  const files = {};
7150
6960
  const newValues = {};
7151
6961
  for (const key in values) {
@@ -7160,13 +6970,17 @@ var __publicField = (obj, key, value) => {
7160
6970
  newValues[key] = value;
7161
6971
  }
7162
6972
  }
7163
- return { values: newValues, files };
6973
+ const payloadWithoutFiles = {
6974
+ ...payload,
6975
+ values: newValues
6976
+ };
6977
+ return { payloadWithoutFiles, files };
7164
6978
  };
7165
6979
  class UserFormSubmissionService extends BaseApiService {
7166
6980
  constructor() {
7167
6981
  super(...arguments);
7168
6982
  // Attach files to submission, after uploading them to S3
7169
- __publicField(this, "getAttachFilesPromises", (files, submission) => {
6983
+ __publicField(this, "getAttachFilesPromises", (files, payload) => {
7170
6984
  const { store } = this.client;
7171
6985
  return Object.entries(files).map(async ([key, fileArray]) => {
7172
6986
  const attachResults = [];
@@ -7176,27 +6990,24 @@ var __publicField = (obj, key, value) => {
7176
6990
  const [fileProps] = await this.client.files.uploadFileToS3(sha1);
7177
6991
  const submissionAttachmentPayload = offline({
7178
6992
  ...fileProps,
7179
- submission: submission.offline_id,
6993
+ submission: payload.offline_id,
7180
6994
  field_identifier: key
7181
6995
  });
7182
6996
  const attach = await this.enqueueRequest({
7183
6997
  description: "Attach file to form submission",
7184
6998
  method: HttpMethod.POST,
7185
- url: `/forms/submission/${submission.offline_id}/attachments/`,
6999
+ url: `/forms/submission/${payload.offline_id}/attachments/`,
7186
7000
  payload: submissionAttachmentPayload,
7187
- blockers: [
7188
- submission.component,
7189
- submission.component_stage,
7190
- submission.issue,
7191
- submission.form_revision
7192
- ].filter((x) => x !== void 0),
7001
+ blockers: [payload.component, payload.component_stage, payload.issue, payload.form_revision].filter(
7002
+ (x) => x !== void 0
7003
+ ),
7193
7004
  blocks: [submissionAttachmentPayload.offline_id]
7194
7005
  });
7195
7006
  const offlinePayload = {
7196
7007
  ...submissionAttachmentPayload,
7197
7008
  file: URL.createObjectURL(file)
7198
7009
  };
7199
- store.dispatch(addFormSubmissionAttachment(offlinePayload));
7010
+ store.dispatch(addUserFormSubmissionAttachment(offlinePayload));
7200
7011
  attachResults.push(attach);
7201
7012
  }
7202
7013
  return attachResults;
@@ -7210,165 +7021,70 @@ var __publicField = (obj, key, value) => {
7210
7021
  if (!activeProjectId) {
7211
7022
  throw new Error("Expected an active project");
7212
7023
  }
7213
- const { values, files } = separateFilesFromValues(payload.values);
7214
- const offlineSubmission = {
7215
- ...payload,
7216
- values,
7217
- created_by: state.userReducer.currentUser.id,
7218
- submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7219
- };
7024
+ const { payloadWithoutFiles, files } = separateFilesFromValues(payload);
7220
7025
  const promise = this.enqueueRequest({
7221
7026
  description: "Respond to form",
7222
7027
  method: HttpMethod.POST,
7223
7028
  url: `/forms/revisions/${payload.form_revision}/respond/`,
7224
- payload: { ...offlineSubmission, project: activeProjectId },
7029
+ payload: { ...payloadWithoutFiles, project: activeProjectId },
7225
7030
  blockers: [payload.issue, payload.component, payload.component_stage, "add-form-entry"].filter(
7226
7031
  (x) => x !== void 0
7227
7032
  ),
7228
7033
  blocks: [payload.offline_id]
7229
7034
  });
7230
- const attachFilesPromises = this.getAttachFilesPromises(files, offlineSubmission);
7231
- store.dispatch(addFormSubmission(offlineSubmission));
7035
+ const attachFilesPromises = this.getAttachFilesPromises(files, payload);
7036
+ const now = (/* @__PURE__ */ new Date()).toISOString();
7037
+ const fullOfflineResult = {
7038
+ ...payload,
7039
+ created_by: state.userReducer.currentUser.id,
7040
+ created_at: now,
7041
+ updated_at: now
7042
+ };
7043
+ const offlineResultWithoutFiles = {
7044
+ ...fullOfflineResult,
7045
+ ...payloadWithoutFiles
7046
+ };
7047
+ store.dispatch(updateOrCreateUserFormSubmission(offlineResultWithoutFiles));
7232
7048
  void promise.then((result) => {
7233
7049
  store.dispatch(addActiveProjectFormSubmissionsCount(1));
7234
- store.dispatch(setFormSubmission(result));
7050
+ store.dispatch(updateOrCreateUserFormSubmission(result));
7235
7051
  return result;
7236
7052
  }).catch(() => {
7237
- store.dispatch(deleteFormSubmission(payload.offline_id));
7053
+ store.dispatch(deleteUserFormSubmission(payload.offline_id));
7238
7054
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7239
7055
  });
7240
7056
  const settledPromise = Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7241
- return [offlineSubmission, settledPromise];
7242
- }
7243
- // Note currently the bulkAdd method is specific to form submissions for components
7244
- // TODO: adapt the support bulk adding to any model type
7245
- async bulkAdd(args) {
7246
- const { form_revision, values: argsValues, componentOfflineIds } = args;
7247
- const { store } = this.client;
7248
- const offlineSubmissions = [];
7249
- const offlineAttachments = [];
7250
- const submissionOfflineIds = [];
7251
- const submissionsPayload = [];
7252
- const attachmentsPayload = [];
7253
- const { values, files } = separateFilesFromValues(argsValues);
7254
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7255
- const createdBy = store.getState().userReducer.currentUser.id;
7256
- for (const component_id of componentOfflineIds) {
7257
- const submission = offline({
7258
- form_revision,
7259
- values,
7260
- created_by: createdBy,
7261
- submitted_at: submittedAt,
7262
- component: component_id
7263
- });
7264
- submissionOfflineIds.push(submission.offline_id);
7265
- submissionsPayload.push({ offline_id: submission.offline_id, component_id });
7266
- offlineSubmissions.push(submission);
7267
- for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
7268
- for (const file of fileArray) {
7269
- const sha1 = await hashFile(file);
7270
- await this.client.files.addCache(file, sha1);
7271
- const offlineAttachment = offline({
7272
- file_name: file.name,
7273
- file_sha1: sha1,
7274
- file: URL.createObjectURL(file),
7275
- submission: submission.offline_id,
7276
- field_identifier: fieldIdentifier
7277
- });
7278
- offlineAttachments.push(offlineAttachment);
7279
- attachmentsPayload.push({
7280
- offline_id: offlineAttachment.offline_id,
7281
- submission_id: submission.offline_id,
7282
- sha1,
7283
- name: file.name,
7284
- field_identifier: fieldIdentifier
7285
- });
7286
- }
7287
- }
7288
- }
7289
- const filesRecord = {};
7290
- for (const file of Object.values(files).flat()) {
7291
- const sha1 = await hashFile(file);
7292
- filesRecord[sha1] = {
7293
- sha1,
7294
- extension: file.name.split(".").pop() || "",
7295
- file_type: file.type,
7296
- size: file.size
7297
- };
7298
- }
7299
- store.dispatch(addFormSubmissions(offlineSubmissions));
7300
- store.dispatch(addFormSubmissionAttachments(offlineAttachments));
7301
- const promise = this.enqueueRequest({
7302
- description: "Bulk add form submissions",
7303
- method: HttpMethod.POST,
7304
- url: `/forms/revisions/${form_revision}/bulk-respond/`,
7305
- payload: {
7306
- form_data: values,
7307
- submitted_at: submittedAt,
7308
- submissions: submissionsPayload,
7309
- attachments: attachmentsPayload,
7310
- files: Object.values(filesRecord)
7311
- },
7312
- blockers: componentOfflineIds,
7313
- blocks: submissionOfflineIds
7314
- });
7315
- promise.then(({ submissions, attachments, presigned_urls }) => {
7316
- store.dispatch(updateFormSubmissions(submissions));
7317
- store.dispatch(updateFormSubmissionAttachments(attachments));
7318
- for (const [sha1, presigned_url] of Object.entries(presigned_urls)) {
7319
- const file = filesRecord[sha1];
7320
- if (!file)
7321
- continue;
7322
- void this.enqueueRequest({
7323
- url: presigned_url.url,
7324
- description: "Upload file",
7325
- method: HttpMethod.POST,
7326
- isExternalUrl: true,
7327
- isAuthNeeded: false,
7328
- attachmentHash: sha1,
7329
- blockers: [`s3-${file.sha1}.${file.extension}`],
7330
- blocks: [sha1],
7331
- s3url: presigned_url
7332
- });
7333
- }
7334
- }).catch(() => {
7335
- store.dispatch(deleteFormSubmissions(submissionOfflineIds));
7336
- store.dispatch(deleteFormSubmissionAttachments(offlineAttachments.map((x) => x.offline_id)));
7337
- });
7338
- return [offlineSubmissions, promise.then(({ submissions }) => submissions)];
7057
+ return [fullOfflineResult, settledPromise];
7339
7058
  }
7340
7059
  update(submission) {
7341
7060
  const { store } = this.client;
7342
- const { values, files } = separateFilesFromValues(submission.values);
7061
+ const { payloadWithoutFiles, files } = separateFilesFromValues(submission);
7062
+ if (!("created_by" in payloadWithoutFiles) || !("created_at" in payloadWithoutFiles)) {
7063
+ throw new Error("Expected payloadWithoutFiles to have created_by and created_at fields.");
7064
+ }
7343
7065
  const attachFilesPromises = this.getAttachFilesPromises(files, submission);
7344
- const offlineSubmission = {
7345
- ...submission,
7346
- values
7066
+ const fullResult = {
7067
+ ...payloadWithoutFiles,
7068
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
7347
7069
  };
7348
- const submissionToBeUpdated = store.getState().formSubmissionReducer.formSubmissions[submission.offline_id];
7349
- store.dispatch(updateFormSubmission(offlineSubmission));
7070
+ store.dispatch(updateOrCreateUserFormSubmission(fullResult));
7350
7071
  const promise = this.enqueueRequest({
7351
7072
  description: "Patch form submission",
7352
7073
  method: HttpMethod.PATCH,
7353
7074
  url: `/forms/submissions/${submission.offline_id}/`,
7354
- payload: offlineSubmission,
7355
- blockers: [offlineSubmission.issue, offlineSubmission.component, offlineSubmission.component_stage].filter(
7075
+ payload: fullResult,
7076
+ blockers: [fullResult.issue, fullResult.component, fullResult.component_stage].filter(
7356
7077
  (x) => x !== void 0
7357
7078
  ),
7358
- blocks: [offlineSubmission.offline_id]
7079
+ blocks: [fullResult.offline_id]
7359
7080
  });
7360
- promise.then((createdSubmission) => {
7361
- store.dispatch(setFormSubmission(createdSubmission));
7362
- }).catch(() => {
7363
- store.dispatch(setFormSubmission(submissionToBeUpdated));
7364
- });
7365
- return [offlineSubmission, Promise.all([promise, ...attachFilesPromises]).then(() => promise)];
7081
+ return Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7366
7082
  }
7367
7083
  async delete(submissionId) {
7368
7084
  const { store } = this.client;
7369
7085
  const state = store.getState();
7370
- const submission = state.formSubmissionReducer.formSubmissions[submissionId];
7371
- store.dispatch(deleteFormSubmission(submissionId));
7086
+ const submission = state.userFormReducer.submissions[submissionId];
7087
+ store.dispatch(deleteUserFormSubmission(submissionId));
7372
7088
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7373
7089
  try {
7374
7090
  return await this.enqueueRequest({
@@ -7379,8 +7095,10 @@ var __publicField = (obj, key, value) => {
7379
7095
  blocks: []
7380
7096
  });
7381
7097
  } catch (e) {
7382
- store.dispatch(addActiveProjectFormSubmissionsCount(1));
7383
- store.dispatch(addFormSubmission(submission));
7098
+ if (submission) {
7099
+ store.dispatch(addActiveProjectFormSubmissionsCount(1));
7100
+ store.dispatch(updateOrCreateUserFormSubmission(submission));
7101
+ }
7384
7102
  throw e;
7385
7103
  }
7386
7104
  }
@@ -7394,7 +7112,7 @@ var __publicField = (obj, key, value) => {
7394
7112
  blockers: [],
7395
7113
  blocks: []
7396
7114
  });
7397
- store.dispatch(setFormSubmissions(submissions));
7115
+ store.dispatch(setUserFormSubmissions(submissions));
7398
7116
  const attachments = await this.enqueueRequest({
7399
7117
  description: "Fetch form attachments",
7400
7118
  method: HttpMethod.GET,
@@ -7402,7 +7120,7 @@ var __publicField = (obj, key, value) => {
7402
7120
  blockers: [],
7403
7121
  blocks: []
7404
7122
  });
7405
- store.dispatch(setFormSubmissionAttachments(attachments));
7123
+ store.dispatch(setUserFormSubmissionAttachments(attachments));
7406
7124
  }
7407
7125
  }
7408
7126
  class WorkspaceService extends BaseApiService {
@@ -14261,7 +13979,7 @@ var __publicField = (obj, key, value) => {
14261
13979
  };
14262
13980
  const useAttachImagesToFormRevisionFields = (revision) => {
14263
13981
  const { sdk } = useSDK();
14264
- const attachments = useAppSelector(selectAttachmentsOfFormRevision((revision == null ? void 0 : revision.offline_id) ?? ""));
13982
+ const attachments = useAppSelector(selectRevisionAttachments((revision == null ? void 0 : revision.offline_id) ?? ""));
14265
13983
  return React.useMemo(() => {
14266
13984
  if (!revision || !attachments)
14267
13985
  return revision;
@@ -14358,7 +14076,7 @@ var __publicField = (obj, key, value) => {
14358
14076
  return formRevisionToSchema(revisionWithImages, { readonly: true });
14359
14077
  }, [revisionWithImages]);
14360
14078
  const submissionValuesWithAttachments = React.useMemo(() => {
14361
- const attachments = selectAttachmentsOfFormSubmission(submission.offline_id)(sdk.store.getState()) ?? [];
14079
+ const attachments = selectSubmissionAttachments(submission.offline_id)(sdk.store.getState()) ?? [];
14362
14080
  const downloadedAttachments = {};
14363
14081
  for (const attachment of attachments) {
14364
14082
  const promise = sdk.files.fetchFileFromUrl(attachment.file, attachment.file_sha1, attachment.file_name);
@@ -14408,8 +14126,8 @@ var __publicField = (obj, key, value) => {
14408
14126
  }
14409
14127
  return ret;
14410
14128
  }, [filter, maxResults, ownerFilter]);
14411
- const userForms = useAppSelector(selectFilteredForms(ownerFilterOptions)) ?? [];
14412
- const userFormMapping = useAppSelector(selectFormMapping);
14129
+ const userForms = useAppSelector(selectFilteredUserForms(ownerFilterOptions)) ?? [];
14130
+ const userFormMapping = useAppSelector(selectUserFormMapping);
14413
14131
  const attachableUserForms = userForms.filter((form) => !form.component_type);
14414
14132
  const attachableUserFormMapping = Object.values(userFormMapping).filter(
14415
14133
  (form) => !form.component_type
@@ -14442,7 +14160,7 @@ var __publicField = (obj, key, value) => {
14442
14160
  const handleChange = React.useCallback((e) => {
14443
14161
  setFilter(e.currentTarget.value);
14444
14162
  }, []);
14445
- const numberOfForms = useAppSelector(selectGeneralFormCount) || 0;
14163
+ const numberOfForms = useAppSelector(selectNumberOfGeneralUserForms) || 0;
14446
14164
  const numberOfHiddenForms = numberOfForms - attachableUserForms.length;
14447
14165
  const overflowMessage = attachableUserForms.length == maxResults && numberOfHiddenForms > 0 ? `Only the first ${maxResults} results are shown (${numberOfHiddenForms} hidden)` : numberOfHiddenForms > 0 && `${numberOfHiddenForms} hidden forms`;
14448
14166
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { ref, direction: "column", gap: "2", children: [
@@ -14536,13 +14254,16 @@ var __publicField = (obj, key, value) => {
14536
14254
  const { submission, onSubmissionClick, compact, labelType, rowDecorator } = props;
14537
14255
  const currentUser = useAppSelector(selectCurrentUser);
14538
14256
  const createdBy = useAppSelector(selectUser("created_by" in submission ? submission.created_by : currentUser.id));
14539
- const dateToUse = submission.submitted_at;
14540
- const formattedDateTime = getLocalDateString(dateToUse);
14257
+ const dateToUse = getCreatedAtOrSubmittedAtDate(submission);
14258
+ const formattedDateTime = isToday(dateToUse) ? dateToUse.toLocaleTimeString([], {
14259
+ hour: "2-digit",
14260
+ minute: "2-digit"
14261
+ }) : getLocalDateString(dateToUse);
14541
14262
  const revision = useAppSelector(selectFormRevision(submission.form_revision));
14542
14263
  if (!revision) {
14543
14264
  throw new Error(`Could not find revision ${submission.form_revision} for submission ${submission.offline_id}.`);
14544
14265
  }
14545
- const latestRevisionNumber = (_a2 = useAppSelector(selectLatestFormRevisionOfForm(revision.form))) == null ? void 0 : _a2.revision;
14266
+ const latestRevisionNumber = (_a2 = useAppSelector(selectLatestFormRevision(revision.form))) == null ? void 0 : _a2.revision;
14546
14267
  const creatorProfileSrc = useFileSrc({
14547
14268
  file: (createdBy == null ? void 0 : createdBy.profile.file) ?? null,
14548
14269
  fileSha1: (createdBy == null ? void 0 : createdBy.profile.file_sha1) ?? null
@@ -14573,6 +14294,10 @@ var __publicField = (obj, key, value) => {
14573
14294
  return row;
14574
14295
  });
14575
14296
  FormSubmissionBrowserEntry.displayName = "FormSubmissionBrowserEntry";
14297
+ const getCreatedAtOrSubmittedAtDate = (submission) => {
14298
+ const date = "created_at" in submission ? submission.created_at : submission.submitted_at;
14299
+ return new Date(date);
14300
+ };
14576
14301
  const FormSubmissionBrowser = React.memo((props) => {
14577
14302
  const {
14578
14303
  formId: formId2,
@@ -14586,10 +14311,10 @@ var __publicField = (obj, key, value) => {
14586
14311
  if (!!formId2 === !!propSubmissions) {
14587
14312
  throw new Error("Either formId or submissions must be provided, but not both.");
14588
14313
  }
14589
- const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectFormSubmissionsOfForm(formId2));
14314
+ const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectSubmissionsForForm(formId2));
14590
14315
  const sortedSubmissions = React.useMemo(
14591
14316
  () => submissions == null ? void 0 : submissions.sort((a, b) => {
14592
- return a.submitted_at.localeCompare(b.submitted_at);
14317
+ return getCreatedAtOrSubmittedAtDate(b).getTime() - getCreatedAtOrSubmittedAtDate(a).getTime();
14593
14318
  }),
14594
14319
  [submissions]
14595
14320
  );
@@ -15906,7 +15631,6 @@ var __publicField = (obj, key, value) => {
15906
15631
  exports2.VerificationCodeType = VerificationCodeType;
15907
15632
  exports2.WorkspaceService = WorkspaceService;
15908
15633
  exports2.YELLOW = YELLOW;
15909
- exports2._selectLatestFormRevision = _selectLatestFormRevision;
15910
15634
  exports2._setLatestRetryTime = _setLatestRetryTime;
15911
15635
  exports2.acceptProjectInvite = acceptProjectInvite;
15912
15636
  exports2.addActiveProjectFormSubmissionsCount = addActiveProjectFormSubmissionsCount;
@@ -15924,16 +15648,6 @@ var __publicField = (obj, key, value) => {
15924
15648
  exports2.addDocuments = addDocuments;
15925
15649
  exports2.addEmailDomain = addEmailDomain;
15926
15650
  exports2.addFavouriteProjectId = addFavouriteProjectId;
15927
- exports2.addForm = addForm;
15928
- exports2.addFormRevision = addFormRevision;
15929
- exports2.addFormRevisionAttachment = addFormRevisionAttachment;
15930
- exports2.addFormRevisionAttachments = addFormRevisionAttachments;
15931
- exports2.addFormRevisions = addFormRevisions;
15932
- exports2.addFormSubmission = addFormSubmission;
15933
- exports2.addFormSubmissionAttachment = addFormSubmissionAttachment;
15934
- exports2.addFormSubmissionAttachments = addFormSubmissionAttachments;
15935
- exports2.addFormSubmissions = addFormSubmissions;
15936
- exports2.addForms = addForms;
15937
15651
  exports2.addIssue = addIssue;
15938
15652
  exports2.addIssueAttachment = addIssueAttachment;
15939
15653
  exports2.addIssueAttachments = addIssueAttachments;
@@ -15954,6 +15668,13 @@ var __publicField = (obj, key, value) => {
15954
15668
  exports2.addStageCompletions = addStageCompletions;
15955
15669
  exports2.addStages = addStages;
15956
15670
  exports2.addToRecentIssues = addToRecentIssues;
15671
+ exports2.addUserForm = addUserForm;
15672
+ exports2.addUserFormRevision = addUserFormRevision;
15673
+ exports2.addUserFormRevisionAttachment = addUserFormRevisionAttachment;
15674
+ exports2.addUserFormRevisions = addUserFormRevisions;
15675
+ exports2.addUserFormSubmissionAttachment = addUserFormSubmissionAttachment;
15676
+ exports2.addUserFormSubmissions = addUserFormSubmissions;
15677
+ exports2.addUserForms = addUserForms;
15957
15678
  exports2.addUsers = addUsers;
15958
15679
  exports2.addWorkspace = addWorkspace;
15959
15680
  exports2.areArraysEqual = areArraysEqual;
@@ -15974,7 +15695,6 @@ var __publicField = (obj, key, value) => {
15974
15695
  exports2.componentStageSlice = componentStageSlice;
15975
15696
  exports2.componentTypeReducer = componentTypeReducer;
15976
15697
  exports2.componentTypeSlice = componentTypeSlice;
15977
- exports2.constructUploadedFilePayloads = constructUploadedFilePayloads;
15978
15698
  exports2.coordinatesAreEqual = coordinatesAreEqual;
15979
15699
  exports2.coordinatesToLiteral = coordinatesToLiteral;
15980
15700
  exports2.coordinatesToPointGeometry = coordinatesToPointGeometry;
@@ -15985,16 +15705,12 @@ var __publicField = (obj, key, value) => {
15985
15705
  exports2.defaultBadgeColor = defaultBadgeColor;
15986
15706
  exports2.defaultStore = defaultStore;
15987
15707
  exports2.deleteComponentType = deleteComponentType;
15988
- exports2.deleteForm = deleteForm;
15989
- exports2.deleteFormRevision = deleteFormRevision;
15990
- exports2.deleteFormRevisionAttachment = deleteFormRevisionAttachment;
15991
- exports2.deleteFormRevisionAttachments = deleteFormRevisionAttachments;
15992
- exports2.deleteFormRevisions = deleteFormRevisions;
15993
- exports2.deleteFormSubmission = deleteFormSubmission;
15994
- exports2.deleteFormSubmissionAttachment = deleteFormSubmissionAttachment;
15995
- exports2.deleteFormSubmissionAttachments = deleteFormSubmissionAttachments;
15996
- exports2.deleteFormSubmissions = deleteFormSubmissions;
15997
15708
  exports2.deleteProject = deleteProject;
15709
+ exports2.deleteUserForm = deleteUserForm;
15710
+ exports2.deleteUserFormRevision = deleteUserFormRevision;
15711
+ exports2.deleteUserFormRevisions = deleteUserFormRevisions;
15712
+ exports2.deleteUserFormSubmission = deleteUserFormSubmission;
15713
+ exports2.deleteUserFormSubmissions = deleteUserFormSubmissions;
15998
15714
  exports2.dequeue = dequeue;
15999
15715
  exports2.deserialize = deserialize;
16000
15716
  exports2.deserializeField = deserializeField;
@@ -16023,13 +15739,7 @@ var __publicField = (obj, key, value) => {
16023
15739
  exports2.fileSlice = fileSlice;
16024
15740
  exports2.fileToBlob = fileToBlob;
16025
15741
  exports2.flipCoordinates = flipCoordinates;
16026
- exports2.formReducer = formReducer;
16027
- exports2.formRevisionReducer = formRevisionReducer;
16028
15742
  exports2.formRevisionToSchema = formRevisionToSchema;
16029
- exports2.formRevisionsSlice = formRevisionsSlice;
16030
- exports2.formSlice = formSlice;
16031
- exports2.formSubmissionReducer = formSubmissionReducer;
16032
- exports2.formSubmissionSlice = formSubmissionSlice;
16033
15743
  exports2.forms = index;
16034
15744
  exports2.fullComponentMarkerSize = fullComponentMarkerSize;
16035
15745
  exports2.generateBadgeColors = generateBadgeColors;
@@ -16157,8 +15867,6 @@ var __publicField = (obj, key, value) => {
16157
15867
  exports2.selectAttachmentsOfComponentTypeByType = selectAttachmentsOfComponentTypeByType;
16158
15868
  exports2.selectAttachmentsOfDocument = selectAttachmentsOfDocument;
16159
15869
  exports2.selectAttachmentsOfDocumentByType = selectAttachmentsOfDocumentByType;
16160
- exports2.selectAttachmentsOfFormRevision = selectAttachmentsOfFormRevision;
16161
- exports2.selectAttachmentsOfFormSubmission = selectAttachmentsOfFormSubmission;
16162
15870
  exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
16163
15871
  exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
16164
15872
  exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
@@ -16174,11 +15882,11 @@ var __publicField = (obj, key, value) => {
16174
15882
  exports2.selectCompletedStageIdsForComponent = selectCompletedStageIdsForComponent;
16175
15883
  exports2.selectCompletedStages = selectCompletedStages;
16176
15884
  exports2.selectComponent = selectComponent;
16177
- exports2.selectComponentAttachment = selectComponentAttachment;
16178
15885
  exports2.selectComponentAttachmentMapping = selectComponentAttachmentMapping;
15886
+ exports2.selectComponentSubmissionMapping = selectComponentSubmissionMapping;
16179
15887
  exports2.selectComponentType = selectComponentType;
16180
- exports2.selectComponentTypeAttachment = selectComponentTypeAttachment;
16181
15888
  exports2.selectComponentTypeAttachmentMapping = selectComponentTypeAttachmentMapping;
15889
+ exports2.selectComponentTypeForm = selectComponentTypeForm;
16182
15890
  exports2.selectComponentTypeFromComponent = selectComponentTypeFromComponent;
16183
15891
  exports2.selectComponentTypeFromComponents = selectComponentTypeFromComponents;
16184
15892
  exports2.selectComponentTypeStagesMapping = selectComponentTypeStagesMapping;
@@ -16194,7 +15902,6 @@ var __publicField = (obj, key, value) => {
16194
15902
  exports2.selectCurrentUser = selectCurrentUser;
16195
15903
  exports2.selectDeletedRequests = selectDeletedRequests;
16196
15904
  exports2.selectDocument = selectDocument;
16197
- exports2.selectDocumentAttachment = selectDocumentAttachment;
16198
15905
  exports2.selectDocumentAttachmentMapping = selectDocumentAttachmentMapping;
16199
15906
  exports2.selectDocuments = selectDocuments;
16200
15907
  exports2.selectDocumentsMapping = selectDocumentsMapping;
@@ -16208,24 +15915,8 @@ var __publicField = (obj, key, value) => {
16208
15915
  exports2.selectExpandedSections = selectExpandedSections;
16209
15916
  exports2.selectFavouriteProjects = selectFavouriteProjects;
16210
15917
  exports2.selectFileAttachmentsOfIssue = selectFileAttachmentsOfIssue;
16211
- exports2.selectFilteredForms = selectFilteredForms;
16212
- exports2.selectForm = selectForm;
16213
- exports2.selectFormMapping = selectFormMapping;
16214
- exports2.selectFormOfComponentType = selectFormOfComponentType;
15918
+ exports2.selectFilteredUserForms = selectFilteredUserForms;
16215
15919
  exports2.selectFormRevision = selectFormRevision;
16216
- exports2.selectFormRevisionMapping = selectFormRevisionMapping;
16217
- exports2.selectFormRevisions = selectFormRevisions;
16218
- exports2.selectFormRevisionsOfForm = selectFormRevisionsOfForm;
16219
- exports2.selectFormSubmission = selectFormSubmission;
16220
- exports2.selectFormSubmissionAttachmentsMapping = selectFormSubmissionAttachmentsMapping;
16221
- exports2.selectFormSubmissions = selectFormSubmissions;
16222
- exports2.selectFormSubmissionsByComponents = selectFormSubmissionsByComponents;
16223
- exports2.selectFormSubmissionsMapping = selectFormSubmissionsMapping;
16224
- exports2.selectFormSubmissionsOfComponent = selectFormSubmissionsOfComponent;
16225
- exports2.selectFormSubmissionsOfForm = selectFormSubmissionsOfForm;
16226
- exports2.selectFormSubmissionsOfIssue = selectFormSubmissionsOfIssue;
16227
- exports2.selectFormsCount = selectFormsCount;
16228
- exports2.selectGeneralFormCount = selectGeneralFormCount;
16229
15920
  exports2.selectHiddenCategoryCount = selectHiddenCategoryCount;
16230
15921
  exports2.selectHiddenComponentTypeIds = selectHiddenComponentTypeIds;
16231
15922
  exports2.selectIsFetchingInitialData = selectIsFetchingInitialData;
@@ -16233,17 +15924,16 @@ var __publicField = (obj, key, value) => {
16233
15924
  exports2.selectIsLoading = selectIsLoading;
16234
15925
  exports2.selectIsLoggedIn = selectIsLoggedIn;
16235
15926
  exports2.selectIssue = selectIssue;
16236
- exports2.selectIssueAttachment = selectIssueAttachment;
16237
15927
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
16238
15928
  exports2.selectIssueAttachments = selectIssueAttachments;
16239
15929
  exports2.selectIssueMapping = selectIssueMapping;
16240
15930
  exports2.selectIssueUpdateMapping = selectIssueUpdateMapping;
16241
15931
  exports2.selectIssueUpdatesOfIssue = selectIssueUpdatesOfIssue;
16242
15932
  exports2.selectIssues = selectIssues;
16243
- exports2.selectLatestFormRevisionByForm = selectLatestFormRevisionByForm;
16244
- exports2.selectLatestFormRevisionOfForm = selectLatestFormRevisionOfForm;
16245
- exports2.selectLatestFormRevisionsOfComponentTypes = selectLatestFormRevisionsOfComponentTypes;
15933
+ exports2.selectLatestFormRevision = selectLatestFormRevision;
16246
15934
  exports2.selectLatestRetryTime = selectLatestRetryTime;
15935
+ exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
15936
+ exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
16247
15937
  exports2.selectLicense = selectLicense;
16248
15938
  exports2.selectLicenseForProject = selectLicenseForProject;
16249
15939
  exports2.selectLicenses = selectLicenses;
@@ -16252,6 +15942,8 @@ var __publicField = (obj, key, value) => {
16252
15942
  exports2.selectMapStyle = selectMapStyle;
16253
15943
  exports2.selectNumberOfComponentTypesMatchingCaseInsensitiveName = selectNumberOfComponentTypesMatchingCaseInsensitiveName;
16254
15944
  exports2.selectNumberOfComponentsOfComponentType = selectNumberOfComponentsOfComponentType;
15945
+ exports2.selectNumberOfGeneralUserForms = selectNumberOfGeneralUserForms;
15946
+ exports2.selectNumberOfUserForms = selectNumberOfUserForms;
16255
15947
  exports2.selectOrganization = selectOrganization;
16256
15948
  exports2.selectOrganizationAccess = selectOrganizationAccess;
16257
15949
  exports2.selectOrganizationAccessForUser = selectOrganizationAccessForUser;
@@ -16279,6 +15971,8 @@ var __publicField = (obj, key, value) => {
16279
15971
  exports2.selectRecentIssuesAsSearchResults = selectRecentIssuesAsSearchResults;
16280
15972
  exports2.selectRecentProjects = selectRecentProjects;
16281
15973
  exports2.selectRehydrated = selectRehydrated;
15974
+ exports2.selectRevisionAttachments = selectRevisionAttachments;
15975
+ exports2.selectRevisionsForForm = selectRevisionsForForm;
16282
15976
  exports2.selectRootDocuments = selectRootDocuments;
16283
15977
  exports2.selectShowTooltips = selectShowTooltips;
16284
15978
  exports2.selectSortedEmailDomains = selectSortedEmailDomains;
@@ -16293,10 +15987,16 @@ var __publicField = (obj, key, value) => {
16293
15987
  exports2.selectStagesFromComponentType = selectStagesFromComponentType;
16294
15988
  exports2.selectStagesFromComponentTypeIds = selectStagesFromComponentTypeIds;
16295
15989
  exports2.selectStagesFromStageIds = selectStagesFromStageIds;
15990
+ exports2.selectSubmissionAttachments = selectSubmissionAttachments;
15991
+ exports2.selectSubmissionsForComponent = selectSubmissionsForComponent;
15992
+ exports2.selectSubmissionsForForm = selectSubmissionsForForm;
15993
+ exports2.selectSubmissionsForIssue = selectSubmissionsForIssue;
16296
15994
  exports2.selectUploadUrl = selectUploadUrl;
16297
15995
  exports2.selectUsedColors = selectUsedColors;
16298
15996
  exports2.selectUser = selectUser;
16299
- exports2.selectUserFormRevisionAttachmentsMapping = selectUserFormRevisionAttachmentsMapping;
15997
+ exports2.selectUserForm = selectUserForm;
15998
+ exports2.selectUserFormMapping = selectUserFormMapping;
15999
+ exports2.selectUserFormSubmission = selectUserFormSubmission;
16300
16000
  exports2.selectUsersAsMapping = selectUsersAsMapping;
16301
16001
  exports2.selectVisibleStatuses = selectVisibleStatuses;
16302
16002
  exports2.selectVisibleUserIds = selectVisibleUserIds;
@@ -16323,13 +16023,6 @@ var __publicField = (obj, key, value) => {
16323
16023
  exports2.setEnableClustering = setEnableClustering;
16324
16024
  exports2.setEnableDuplicateIssues = setEnableDuplicateIssues;
16325
16025
  exports2.setEnablePlacementMode = setEnablePlacementMode;
16326
- exports2.setFormRevision = setFormRevision;
16327
- exports2.setFormRevisionAttachments = setFormRevisionAttachments;
16328
- exports2.setFormRevisions = setFormRevisions;
16329
- exports2.setFormSubmission = setFormSubmission;
16330
- exports2.setFormSubmissionAttachments = setFormSubmissionAttachments;
16331
- exports2.setFormSubmissions = setFormSubmissions;
16332
- exports2.setForms = setForms;
16333
16026
  exports2.setIsFetchingInitialData = setIsFetchingInitialData;
16334
16027
  exports2.setIsImportingProjectFile = setIsImportingProjectFile;
16335
16028
  exports2.setIsLoading = setIsLoading;
@@ -16354,6 +16047,9 @@ var __publicField = (obj, key, value) => {
16354
16047
  exports2.setTokens = setTokens;
16355
16048
  exports2.setTourStep = setTourStep;
16356
16049
  exports2.setUploadUrl = setUploadUrl;
16050
+ exports2.setUserFormRevisionAttachments = setUserFormRevisionAttachments;
16051
+ exports2.setUserFormSubmissionAttachments = setUserFormSubmissionAttachments;
16052
+ exports2.setUserFormSubmissions = setUserFormSubmissions;
16357
16053
  exports2.setUsers = setUsers;
16358
16054
  exports2.setVisibleStatuses = setVisibleStatuses;
16359
16055
  exports2.setVisibleUserIds = setVisibleUserIds;
@@ -16378,13 +16074,11 @@ var __publicField = (obj, key, value) => {
16378
16074
  exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
16379
16075
  exports2.updateDocumentAttachment = updateDocumentAttachment;
16380
16076
  exports2.updateDocuments = updateDocuments;
16381
- exports2.updateFormSubmission = updateFormSubmission;
16382
- exports2.updateFormSubmissionAttachments = updateFormSubmissionAttachments;
16383
- exports2.updateFormSubmissions = updateFormSubmissions;
16384
16077
  exports2.updateIssue = updateIssue;
16385
16078
  exports2.updateIssueAttachment = updateIssueAttachment;
16386
16079
  exports2.updateLicense = updateLicense;
16387
16080
  exports2.updateOrCreateProject = updateOrCreateProject;
16081
+ exports2.updateOrCreateUserFormSubmission = updateOrCreateUserFormSubmission;
16388
16082
  exports2.updateOrganizationAccess = updateOrganizationAccess;
16389
16083
  exports2.updateProjectAccess = updateProjectAccess;
16390
16084
  exports2.updateProjectAttachment = updateProjectAttachment;
@@ -16398,6 +16092,8 @@ var __publicField = (obj, key, value) => {
16398
16092
  exports2.useFormikInput = useFormikInput;
16399
16093
  exports2.useMemoCompare = useMemoCompare;
16400
16094
  exports2.useSDK = useSDK;
16095
+ exports2.userFormReducer = userFormReducer;
16096
+ exports2.userFormSlice = userFormSlice;
16401
16097
  exports2.userReducer = userReducer;
16402
16098
  exports2.userSlice = userSlice;
16403
16099
  exports2.valueIsFile = valueIsFile;