|
1 | 1 | (() => { |
2 | 2 | const markdownConverter = new showdown.Converter(); |
3 | | - const apiEndpoint = sessionStorage.getItem("apiEndpoint"); |
4 | | - const taskStore = JSON.parse(sessionStorage.getItem("task")); |
| 3 | + const apiEndpoint = getStoredData("apiEndpoint"); |
| 4 | + const taskStore = JSON.parse(getStoredData("task")); |
5 | 5 | const taskName = document.getElementById("taskName"); |
6 | 6 | const taskStatusTag = document.getElementById("taskStatusTag"); |
7 | 7 | const taskStagesMenu = document.getElementById("taskStagesMenu"); |
|
92 | 92 | agentIcon = "manager"; |
93 | 93 | break; |
94 | 94 | case "HumanAgent": |
95 | | - let userNumber = sessionStorage.getItem("userNumber"); |
| 95 | + let userNumber = getStoredData("userNumber"); |
96 | 96 | if (userNumber == null) { |
97 | 97 | // Generate a random number between 0 and 6 |
98 | 98 | userNumber = Math.floor(Math.random() * 6); |
99 | 99 | // Create the icon name by concatenating 'user' with the random number |
100 | | - sessionStorage.setItem("userNumber", userNumber); |
| 100 | + setStoredData("userNumber", userNumber); |
101 | 101 | } |
102 | 102 | let iconName = "user" + userNumber; |
103 | 103 | agentIcon = iconName; |
|
161 | 161 |
|
162 | 162 | if (taskCancelButton) { |
163 | 163 | taskCancelButton.addEventListener("click", (event) => { |
164 | | - const apiTaskStore = JSON.parse(sessionStorage.getItem("apiTask")); |
| 164 | + const apiTaskStore = JSON.parse(getStoredData("apiTask")); |
165 | 165 | handleDisableOfActions("completed") |
166 | 166 |
|
167 | 167 | // Explicitly disable chatbox and message button |
|
232 | 232 | updateTaskProgress(data[0]); |
233 | 233 | fetchTaskStages(data[0]); |
234 | 234 |
|
235 | | - sessionStorage.setItem("apiTask", JSON.stringify(data[0])); |
| 235 | + setStoredData("apiTask", JSON.stringify(data[0])); |
236 | 236 | //const isHumanClarificationRequestNull = data?.[0]?.human_clarification_request === null |
237 | 237 | const isHumanClarificationResponseNotNull = data?.[0]?.human_clarification_response !== null; |
238 | 238 | const taskMessageTextareaElement =document.getElementById("taskMessageTextarea"); |
|
375 | 375 |
|
376 | 376 | updateTaskDetailsAgents([...new Set(taskAgents)]); |
377 | 377 |
|
378 | | - sessionStorage.setItem("showApproveAll", false); |
| 378 | + setStoredData("showApproveAll", false); |
379 | 379 |
|
380 | 380 | // Feature approve all removed for this version |
381 | 381 | // if (isHumanFeedbackPending()) { |
382 | | - // sessionStorage.setItem('showApproveAll', false); |
| 382 | + // setStoredData('showApproveAll', false); |
383 | 383 | // console.log('showApproveAll status', "showApproveAll is false"); |
384 | 384 |
|
385 | 385 | // } else { |
386 | | - // sessionStorage.setItem('showApproveAll', taskStageApprovalStatus === taskStageCount); |
| 386 | + // setStoredData('showApproveAll', taskStageApprovalStatus === taskStageCount); |
387 | 387 | // console.log('showApproveAll status', taskStageApprovalStatus === taskStageCount); |
388 | 388 |
|
389 | 389 | // } |
|
450 | 450 | // console.log(groupByStepId(data)); |
451 | 451 |
|
452 | 452 | if ( |
453 | | - sessionStorage.getItem("context") && |
454 | | - sessionStorage.getItem("context") === "customer" |
| 453 | + getStoredData("context") && |
| 454 | + getStoredData("context") === "customer" |
455 | 455 | ) { |
456 | 456 | data = contextFilter(data); |
457 | 457 | } |
|
477 | 477 | messages.forEach((message) => { |
478 | 478 | const messageItem = document.createElement("div"); |
479 | 479 | const showApproveAll = |
480 | | - sessionStorage.getItem("showApproveAll") === "true" && |
| 480 | + getStoredData("showApproveAll") === "true" && |
481 | 481 | data.length === messageCount; |
482 | 482 |
|
483 | 483 | let approveAllStagesButton = ""; |
|
491 | 491 | : "has-status-active"; |
492 | 492 |
|
493 | 493 | if ( |
494 | | - sessionStorage.getItem("context") && |
495 | | - sessionStorage.getItem("context") !== "customer" |
| 494 | + getStoredData("context") && |
| 495 | + getStoredData("context") !== "customer" |
496 | 496 | ) { |
497 | 497 | if (showApproveAll) { |
498 | 498 | console.log("Creating approveAllStagesButton"); |
|
550 | 550 | taskMessages.appendChild(messageItem); |
551 | 551 |
|
552 | 552 | if ( |
553 | | - sessionStorage.getItem("context") && |
554 | | - sessionStorage.getItem("context") !== "customer" |
| 553 | + getStoredData("context") && |
| 554 | + getStoredData("context") !== "customer" |
555 | 555 | ) { |
556 | 556 | if (showApproveAll) { |
557 | 557 | document |
|
576 | 576 | } |
577 | 577 |
|
578 | 578 | if ( |
579 | | - sessionStorage.getItem("context") && |
580 | | - sessionStorage.getItem("context") === "customer" && |
581 | | - !sessionStorage |
582 | | - .getItem("actionStagesRun") |
| 579 | + getStoredData("context") && |
| 580 | + getStoredData("context") === "customer" && |
| 581 | + !getStoredData("actionStagesRun") |
583 | 582 | .includes(task.session_id) |
584 | 583 | ) { |
585 | 584 | actionStages(task, true); |
586 | 585 |
|
587 | 586 | let actionStagesRun = JSON.parse( |
588 | | - sessionStorage.getItem("actionStagesRun") || "[]" |
| 587 | + getStoredData("actionStagesRun") || "[]" |
589 | 588 | ); |
590 | 589 |
|
591 | 590 | actionStagesRun.push(task.session_id); |
592 | | - sessionStorage.setItem( |
| 591 | + setStoredData( |
593 | 592 | "actionStagesRun", |
594 | 593 | JSON.stringify(actionStagesRun) |
595 | 594 | ); |
|
645 | 644 | }; |
646 | 645 |
|
647 | 646 | const isHumanFeedbackPending = () => { |
648 | | - const storedData = sessionStorage.getItem("apiTask"); |
| 647 | + const storedData = getStoredData("apiTask"); |
649 | 648 | const planDetails = JSON.parse(storedData); |
650 | 649 | return ( |
651 | 650 | planDetails.human_clarification_request !== null && |
|
0 commit comments