diff --git a/dashboard/src/scenes/report/view.js b/dashboard/src/scenes/report/view.js index 4c2ba2f3f..d9f2d023d 100644 --- a/dashboard/src/scenes/report/view.js +++ b/dashboard/src/scenes/report/view.js @@ -54,7 +54,6 @@ import SelectTeamMultiple from '../../components/SelectTeamMultiple'; import TagTeam from '../../components/TagTeam'; import ReceptionService from '../../components/ReceptionService'; import { useLocalStorage } from '../../services/useLocalStorage'; -import useSearchParamState from '../../services/useSearchParamState'; import { arrayOfitemsGroupedByActionSelector, arrayOfitemsGroupedByConsultationSelector, personsObjectSelector } from '../../recoil/selectors'; import { treatmentsState } from '../../recoil/treatments'; import { medicalFileState } from '../../recoil/medicalFiles'; @@ -145,7 +144,13 @@ const View = () => { const history = useHistory(); const location = useLocation(); const searchParams = new URLSearchParams(location.search); - const [activeTab, setActiveTab] = useSearchParamState('tab', ['restricted-access'].includes(user.role) ? 'reception' : 'resume'); + const [activeTab, setActiveTab] = useState(['restricted-access'].includes(user.role) ? 'reception' : 'resume'); + const searchParamTab = searchParams.get('tab'); + useEffect(() => { + if (searchParamTab) { + setActiveTab(searchParamTab); + } + }, [searchParamTab]); const { refresh } = useDataLoader(); diff --git a/e2e/actions_comments_urgents.spec.ts b/e2e/actions_comments_urgents.spec.ts index dd3324f3a..c0816aebb 100644 --- a/e2e/actions_comments_urgents.spec.ts +++ b/e2e/actions_comments_urgents.spec.ts @@ -134,7 +134,7 @@ test("Create action with comments", async ({ page }) => { await page.getByRole("button", { name: "Actions et commentaires urgents et vigilance" }).click(); await page.locator('[data-test-id="action avec commentaire"]').getByRole("cell", { name: "action avec commentaire" }).click(); - await expect(page).toHaveURL(/http:\/\/localhost:8090\/report\/.*\?reportsTeam=%5B%22.*%22%5D&tab=comment-created&actionId=.*/); + await expect(page).toHaveURL(/http:\/\/localhost:8090\/report\/.*\?reportsTeam=%5B%22.*%22%5D&actionId=.*/); await page.getByRole("button", { name: "Commentaires (1)" }).click(); await expect(page.getByRole("heading", { name: "Action: action avec commentaire (créée par User Admin Test - 7)" })).toBeVisible(); await page.getByRole("button", { name: "Fermer" }).first().click(); diff --git a/e2e/consultations_test-navigate-to-consultation.spec.ts b/e2e/consultations_test-navigate-to-consultation.spec.ts index 9b7d1e302..2e5782f39 100644 --- a/e2e/consultations_test-navigate-to-consultation.spec.ts +++ b/e2e/consultations_test-navigate-to-consultation.spec.ts @@ -134,7 +134,7 @@ test("test", async ({ page }) => { await page.locator('[data-test-id="faite"]').getByText("faite").click(); await expect(page).toHaveURL( - /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&tab=consultations-created&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ + /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ ); await page.getByRole("button", { name: "Fermer" }).first().click(); @@ -150,7 +150,7 @@ test("test", async ({ page }) => { await page.locator('[data-test-id="consult abc"]').getByText("consult abc").click(); await expect(page).toHaveURL( - /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&tab=consultations-created&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ + /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ ); await page.getByRole("button", { name: "Fermer" }).first().click(); @@ -161,11 +161,11 @@ test("test", async ({ page }) => { await page.locator('[data-test-id="faite"]').getByText("faite").click(); await expect(page).toHaveURL( - /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&tab=consultations&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ + /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&consultationId=[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/ ); await page.getByRole("button", { name: "Fermer" }).first().click(); await expect(page).toHaveURL( - /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D&tab=consultations/ + /http:\/\/localhost:8090\/report\/[0-9]{4}-[0-9]{2}-[0-9]{2}\?reportsTeam=%5B%22[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}%22%5D/ ); });