diff --git a/src/Components/SideMenu/index.js b/src/Components/SideMenu/index.js index 7dfcdf5..63e9955 100644 --- a/src/Components/SideMenu/index.js +++ b/src/Components/SideMenu/index.js @@ -239,12 +239,14 @@ export default function SideMenu({ useEffect(() => { console.log("useeffect side menu 2"); - setSelectedKeys(location.pathname); + const pathname = location.pathname; - lastSubscribedTopic.current = location.pathname; + setSelectedKeys(pathname); + + lastSubscribedTopic.current = pathname; webSocketContext.SendSocketMessage(SentMessagesCommands.SubscribeToTopic, { - topic: location.pathname, + topic: pathname, }); }, [location.pathname]); diff --git a/src/Handlers/WebSocketMessageHandler.js b/src/Handlers/WebSocketMessageHandler.js index 198207f..a3bff9b 100644 --- a/src/Handlers/WebSocketMessageHandler.js +++ b/src/Handlers/WebSocketMessageHandler.js @@ -1,7 +1,4 @@ -import { - Constants, - GroupTasksStepsLockedAndUserUpdateInputValueRememberId, -} from "../utils"; +import { Constants, GetUuid } from "../utils"; // commands received from the backend server export const ReceivedMessagesCommands = { @@ -73,6 +70,12 @@ export const SentMessagesCommands = { SubscribeToTopic: 23, }; +/* +This ID is needed because the message is sent to all clients connected to the backend server when a task is locked and unlocked. +With this ID the client checks if the respective browser tab of the user is the initiator of the lock. +*/ +export const GroupTasksStepsLockedAndUserUpdateInputValueRememberId = GetUuid(); + export function handleWebSocketMessage( event, navigate, @@ -100,7 +103,9 @@ export function handleWebSocketMessage( body.RememberId === groupTasksContext.startGroupTasksOpenModalRememberIdRef.current ) { - navigate(`${Constants.ROUTE_PATHS.GROUP_TASKS}/${body.Id}`); + navigate( + `${Constants.ROUTE_PATHS.GROUP_TASKS}${body.Category}/view/${body.Id}` + ); } break; case ReceivedMessagesCommands.NewGroupTaskStep: @@ -144,7 +149,7 @@ export function handleWebSocketMessage( break; case ReceivedMessagesCommands.GroupTasksReloaded: if (body.RemovedCategory !== undefined) { - groupTasksContext.setCategoryGroups((arr) => + groupTasksContext.setCategoryGroup((arr) => arr.filter((arr1) => arr1.category !== body.RemovedCategory) ); @@ -183,7 +188,7 @@ export function handleWebSocketMessage( break; } - groupTasksContext.setCategoryGroups((arr) => { + groupTasksContext.setCategoryGroup((arr) => { const newArr = [...arr]; const categoryIndex = arr.findIndex( @@ -313,11 +318,11 @@ export function handleWebSocketMessage( const stepIndex = arr.findIndex( (arr1) => - arr1.GroupTasksId === body.GroupTaskId && arr1.Step === body.Step + arr1.GroupTasksId === body.groupTaskId && arr1.Step === body.step ); if (stepIndex !== -1) { - newArr[stepIndex].LockedByUserId = body.LockedByUserId; + newArr[stepIndex].LockedByUserId = body.lockedByUserId; } return newArr; diff --git a/src/Pages/EquipmentDocumentation/ViewEquipmentDocumentation.js b/src/Pages/EquipmentDocumentation/ViewEquipmentDocumentation.js index cdc6d5b..89338e4 100644 --- a/src/Pages/EquipmentDocumentation/ViewEquipmentDocumentation.js +++ b/src/Pages/EquipmentDocumentation/ViewEquipmentDocumentation.js @@ -47,7 +47,7 @@ export default function ViewEquipmentDocumentations({ useState(false); const [paginationPage, setPaginationPage] = useState(1); - const fetchDocumentation = (page) => { + const fetchDocumentation = (page = 1) => { setIsEquipmentDocumentationLoading(true); myFetch( diff --git a/src/Pages/GroupTasks/Overview/GroupTasksViewModal.js b/src/Pages/GroupTasks/Overview/GroupTasksViewModal.js index d7f0170..1d948fa 100644 --- a/src/Pages/GroupTasks/Overview/GroupTasksViewModal.js +++ b/src/Pages/GroupTasks/Overview/GroupTasksViewModal.js @@ -17,7 +17,6 @@ import { FormatDatetime, GetDuration, getUserId, - GroupTasksStepsLockedAndUserUpdateInputValueRememberId, hasXYPermission, myFetch, } from "../../../utils"; @@ -37,7 +36,10 @@ import MyAttachments from "../../../Components/MyAttachments"; import { useWebSocketContext } from "../../../Contexts/WebSocketContext"; import { useGroupTasksContext } from "../../../Contexts/GroupTasksContext"; import { useAppContext } from "../../../Contexts/AppContext"; -import { SentMessagesCommands } from "../../../Handlers/WebSocketMessageHandler"; +import { + GroupTasksStepsLockedAndUserUpdateInputValueRememberId, + SentMessagesCommands, +} from "../../../Handlers/WebSocketMessageHandler"; export default function GroupTasksViewModal({ isOpen }) { const webSocketContext = useWebSocketContext(); diff --git a/src/utils.js b/src/utils.js index 5e795a3..8c5f4d7 100644 --- a/src/utils.js +++ b/src/utils.js @@ -155,12 +155,6 @@ export const AppStyle = { }, }; -/* -This ID is needed because the message is sent to all clients connected to the backend server when a task is locked and unlocked. -With this ID the client checks if the respective browser tab of the user is the initiator of the lock. -*/ -export const GroupTasksStepsLockedAndUserUpdateInputValueRememberId = GetUuid(); - export function GetUuid() { return uuidv4(); }