From 36c69af0452d9fd17b355548861a736ab0ef94f9 Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Thu, 2 May 2024 09:24:11 -0700 Subject: [PATCH 1/2] fix missing new source view --- src/views/NewRecordView/index.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/views/NewRecordView/index.tsx b/src/views/NewRecordView/index.tsx index 696cf06b..e083a888 100644 --- a/src/views/NewRecordView/index.tsx +++ b/src/views/NewRecordView/index.tsx @@ -3,6 +3,7 @@ import './index.scss'; import React, { ReactNode, useCallback, + useEffect, } from 'react'; import { useLocation, useNavigate, useParams, useSearchParams, @@ -44,10 +45,13 @@ const NewRecordView = () => { let innerComponent: ReactNode = null; - if (!modelName) { - navigate('/', { replace: true }); - return null; - } + useEffect(() => { + if (!modelName) { + navigate('/query', { replace: true }); + } + }, [modelName, navigate]); + + if (!modelName) return null; if ( VARIANT_CLASSES.includes(modelName.toLowerCase()) From 291efd581db566c62e1950b1b27a2850e5d6a6de Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Thu, 2 May 2024 10:10:42 -0700 Subject: [PATCH 2/2] further bugfix --- src/views/NewRecordView/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/views/NewRecordView/index.tsx b/src/views/NewRecordView/index.tsx index e083a888..0a25a6a1 100644 --- a/src/views/NewRecordView/index.tsx +++ b/src/views/NewRecordView/index.tsx @@ -18,11 +18,13 @@ import util from '@/services/util'; const VARIANT_CLASSES = ['variant', 'positionalvariant', 'categoryvariant']; -const NewRecordView = () => { +const NewRecordView = ({ modelName: propsModelName }) => { const navigate = useNavigate(); const { pathname } = useLocation(); const [searchParams] = useSearchParams(); - const { modelName } = useParams<{ modelName: string }>(); + const { modelName: paramsModelName } = useParams<{ modelName: string }>(); + const modelName = propsModelName || paramsModelName; + /** * After the form is submitted/completed. Handle the corresponding redirect */