= ({
{editRecipientsModal && accountId && transactionId && <>
-
-
+
+ {/*
*/}
+
= ({
>}
{messageModal && accountId && transactionId && <>
-
-
+
+ {/*
*/}
+
+ ) => {
+ const { transactionKey, items } = action.payload;
+ state.items[transactionKey] = items;
+ state.isLoading[transactionKey] = false;
+ },
+
+ /**
+ * Set all dropped items (replaces existing)
+ * Used when user adds/modifies tags in current session
+ */
+ setDroppedItems: (
+ state,
+ action: PayloadAction<{
+ transactionKey: string;
+ items: DroppedItemsObj;
+ }>
+ ) => {
+ const { transactionKey, items } = action.payload;
+ state.items[transactionKey] = items;
+ },
+
+ /**
+ * Add a dropped item to specific page
+ */
+ addDroppedItem: (
+ state,
+ action: PayloadAction<{
+ transactionKey: string;
+ pageKey: string;
+ item: DroppedItem;
+ }>
+ ) => {
+ const { transactionKey, pageKey, item } = action.payload;
+ if (!state.items[transactionKey]) {
+ state.items[transactionKey] = {};
+ }
+ if (!state.items[transactionKey][pageKey]) {
+ state.items[transactionKey][pageKey] = [];
+ }
+ state.items[transactionKey][pageKey].push(item);
+ state.counter[transactionKey] = (state.counter[transactionKey] || 0) + 1;
+ },
+
+ /**
+ * Update dropped items for a specific page
+ */
+ updatePageItems: (
+ state,
+ action: PayloadAction<{
+ transactionKey: string;
+ pageKey: string;
+ items: DroppedItem[];
+ }>
+ ) => {
+ const { transactionKey, pageKey, items } = action.payload;
+ if (!state.items[transactionKey]) {
+ state.items[transactionKey] = {};
+ }
+ state.items[transactionKey][pageKey] = items;
+ },
+
+ /**
+ * Remove an item by index from a page
+ */
+ removeDroppedItem: (
+ state,
+ action: PayloadAction<{
+ transactionKey: string;
+ pageKey: string;
+ index: number;
+ }>
+ ) => {
+ const { transactionKey, pageKey, index } = action.payload;
+ if (state.items[transactionKey]?.[pageKey]) {
+ state.items[transactionKey][pageKey].splice(index, 1);
+ }
+ },
+
+ /**
+ * Update a specific item by index
+ */
+ updateDroppedItem: (
+ state,
+ action: PayloadAction<{
+ transactionKey: string;
+ pageKey: string;
+ index: number;
+ updates: Partial;
+ }>
+ ) => {
+ const { transactionKey, pageKey, index, updates } = action.payload;
+ if (state.items[transactionKey]?.[pageKey]?.[index]) {
+ state.items[transactionKey][pageKey][index] = {
+ ...state.items[transactionKey][pageKey][index],
+ ...updates,
+ };
+ }
+ },
+
+ /**
+ * Clear all tags for a specific transaction
+ */
+ clearTransactionTags: (state, action: PayloadAction) => {
+ const transactionKey = action.payload;
+ delete state.items[transactionKey];
+ delete state.counter[transactionKey];
+ delete state.isLoading[transactionKey];
+ },
+
+ /**
+ * Increment counter for a transaction
+ */
+ incrementCounter: (state, action: PayloadAction) => {
+ const transactionKey = action.payload;
+ state.counter[transactionKey] = (state.counter[transactionKey] || 0) + 1;
+ },
+
+ /**
+ * Set loading state
+ */
+ setLoading: (
+ state,
+ action: PayloadAction<{
+ transactionKey: string;
+ isLoading: boolean;
+ }>
+ ) => {
+ const { transactionKey, isLoading } = action.payload;
+ state.isLoading[transactionKey] = isLoading;
+ },
+ },
+});
+
+export const {
+ initializeDroppedItems,
+ setDroppedItems,
+ addDroppedItem,
+ updatePageItems,
+ removeDroppedItem,
+ updateDroppedItem,
+ clearTransactionTags,
+ incrementCounter,
+ setLoading,
+} = documentTagsSlice.actions;
+
+export default documentTagsSlice.reducer;
diff --git a/src/store/slices/localTagSlice.ts b/src/store/slices/localTagSlice.ts
index c3eba60..55c9ff3 100644
--- a/src/store/slices/localTagSlice.ts
+++ b/src/store/slices/localTagSlice.ts
@@ -2,7 +2,6 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
/* TYPES */
-
export interface Position {
top: number;
left: number;
@@ -43,8 +42,6 @@ export interface Tag {
/* PAYLOAD TYPES */
-
-
interface AddTagPayload {
recipientId: string;
tag: Tag;
@@ -99,7 +96,6 @@ const localTagsSlice = createSlice({
reducers: {
/* ------------------------------ ADD TAG ----------------------------- */
-
addTag: (state, action: PayloadAction) => {
const { recipientId, tag } = action.payload;
@@ -111,7 +107,6 @@ const localTagsSlice = createSlice({
},
/* ---------------------------- UPDATE TAG ---------------------------- */
-
updateTag: (state, action: PayloadAction) => {
const { recipientId, tagId, updatedData } = action.payload;
@@ -125,7 +120,6 @@ const localTagsSlice = createSlice({
},
/* ---------------------------- REMOVE TAG ---------------------------- */
-
removeTag: (state, action: PayloadAction) => {
const { recipientId, tagId } = action.payload;
@@ -140,7 +134,6 @@ const localTagsSlice = createSlice({
},
/* ------------------------- REPLACE ALL TAGS ------------------------- */
-
replaceRecipientTags: (
state,
action: PayloadAction
@@ -155,7 +148,6 @@ const localTagsSlice = createSlice({
},
/* -------------------------- CLEAR RECIPIENT ------------------------- */
-
clearRecipientTags: (
state,
action: PayloadAction
@@ -164,7 +156,6 @@ const localTagsSlice = createSlice({
},
/* ----------------------------- CLEAR ALL ---------------------------- */
-
clearTags: () => {
return initialState;
},
diff --git a/src/store/store.ts b/src/store/store.ts
index 2672f4c..3ab69c5 100644
--- a/src/store/store.ts
+++ b/src/store/store.ts
@@ -72,6 +72,7 @@ import documentReducer from "./slices/documentSlice";
import tagsReducer from "./slices/tagsSlice";
import transactionReducer from "./slices/transactionSlice";
import signatureReducer from "./slices/signatureSlice";
+import documentTagsReducer from "./slices/documentTagsSlice";
const rootReducer = combineReducers({
user: userReducer,
@@ -83,6 +84,7 @@ const rootReducer = combineReducers({
tags: tagsReducer,
transaction: transactionReducer,
signature: signatureReducer,
+ documentTags: documentTagsReducer,
});
export const store = configureStore({