From f0a929044d4efde680190a3c1c01e94cca0bfe02 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Fri, 4 Nov 2022 08:44:56 +0100 Subject: [PATCH] Change request API draft to open (#2320) Draft to open --- .../ChangeRequestSidebar/ChangeRequestSidebar.tsx | 4 ++-- .../src/component/changeRequest/DraftBanner/DraftBanner.tsx | 4 ++-- .../useChangeRequestOpen.ts} | 4 ++-- frontend/src/hooks/useChangeRequestToggle.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) rename frontend/src/hooks/api/getters/{useChangeRequestDraft/useChangeRequestDraft.ts => useChangeRequestOpen/useChangeRequestOpen.ts} (91%) diff --git a/frontend/src/component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar.tsx b/frontend/src/component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar.tsx index b1ce5eb73c..0560e8e1a5 100644 --- a/frontend/src/component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar.tsx +++ b/frontend/src/component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar.tsx @@ -14,7 +14,7 @@ import { PageHeader } from 'component/common/PageHeader/PageHeader'; import { HelpOutline } from '@mui/icons-material'; import EnvironmentIcon from 'component/common/EnvironmentIcon/EnvironmentIcon'; import { ChangeRequest } from '../ChangeRequest/ChangeRequest'; -import { useChangeRequestDraft } from 'hooks/api/getters/useChangeRequestDraft/useChangeRequestDraft'; +import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen'; import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi'; import { ChangeRequestStatusBadge } from '../ChangeRequestStatusBadge/ChangeRequestStatusBadge'; @@ -65,7 +65,7 @@ export const ChangeRequestSidebar: VFC = ({ draft, loading, refetch: refetchChangeRequest, - } = useChangeRequestDraft(project); + } = useChangeRequestOpen(project); const { changeState } = useChangeRequestApi(); const onReview = async (draftId: number) => { diff --git a/frontend/src/component/changeRequest/DraftBanner/DraftBanner.tsx b/frontend/src/component/changeRequest/DraftBanner/DraftBanner.tsx index 2e878af25c..a207543506 100644 --- a/frontend/src/component/changeRequest/DraftBanner/DraftBanner.tsx +++ b/frontend/src/component/changeRequest/DraftBanner/DraftBanner.tsx @@ -4,7 +4,7 @@ import { useStyles as useAppStyles } from 'component/App.styles'; import WarningAmberIcon from '@mui/icons-material/WarningAmber'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { ChangeRequestSidebar } from '../ChangeRequestSidebar/ChangeRequestSidebar'; -import { useChangeRequestDraft } from 'hooks/api/getters/useChangeRequestDraft/useChangeRequestDraft'; +import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen'; interface IDraftBannerProps { project: string; @@ -13,7 +13,7 @@ interface IDraftBannerProps { export const DraftBanner: VFC = ({ project }) => { const { classes } = useAppStyles(); const [isSidebarOpen, setIsSidebarOpen] = useState(false); - const { draft, loading } = useChangeRequestDraft(project); + const { draft, loading } = useChangeRequestOpen(project); const environment = ''; if ((!loading && !draft) || draft?.length === 0) { diff --git a/frontend/src/hooks/api/getters/useChangeRequestDraft/useChangeRequestDraft.ts b/frontend/src/hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen.ts similarity index 91% rename from frontend/src/hooks/api/getters/useChangeRequestDraft/useChangeRequestDraft.ts rename to frontend/src/hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen.ts index 65c95e88c3..89698eea68 100644 --- a/frontend/src/hooks/api/getters/useChangeRequestDraft/useChangeRequestDraft.ts +++ b/frontend/src/hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen.ts @@ -13,9 +13,9 @@ const fetcher = (path: string) => { .then(res => res.json()); }; -export const useChangeRequestDraft = (project: string) => { +export const useChangeRequestOpen = (project: string) => { const { data, error, mutate } = useSWR( - formatApiPath(`api/admin/projects/${project}/change-requests/draft`), + formatApiPath(`api/admin/projects/${project}/change-requests/open`), fetcher ); diff --git a/frontend/src/hooks/useChangeRequestToggle.ts b/frontend/src/hooks/useChangeRequestToggle.ts index d949b083c5..d7beb9b2c0 100644 --- a/frontend/src/hooks/useChangeRequestToggle.ts +++ b/frontend/src/hooks/useChangeRequestToggle.ts @@ -2,12 +2,12 @@ import { useCallback, useState } from 'react'; import useToast from 'hooks/useToast'; import { formatUnknownError } from 'utils/formatUnknownError'; import { useChangeRequestApi } from './api/actions/useChangeRequestApi/useChangeRequestApi'; -import { useChangeRequestDraft } from './api/getters/useChangeRequestDraft/useChangeRequestDraft'; +import { useChangeRequestOpen } from './api/getters/useChangeRequestOpen/useChangeRequestOpen'; export const useChangeRequestToggle = (project: string) => { const { setToastData, setToastApiError } = useToast(); const { addChangeRequest } = useChangeRequestApi(); - const { refetch: refetchChangeRequests } = useChangeRequestDraft(project); + const { refetch: refetchChangeRequests } = useChangeRequestOpen(project); const [changeRequestDialogDetails, setChangeRequestDialogDetails] = useState<{