mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(console): only check demo app existence on get-started page
This commit is contained in:
parent
2ba11215ed
commit
e8ef4b650c
3 changed files with 19 additions and 12 deletions
|
@ -17,7 +17,7 @@ const GetStartedProgress = () => {
|
||||||
} = useUserPreferences();
|
} = useUserPreferences();
|
||||||
const anchorRef = useRef<HTMLDivElement>(null);
|
const anchorRef = useRef<HTMLDivElement>(null);
|
||||||
const [showDropDown, setShowDropdown] = useState(false);
|
const [showDropDown, setShowDropdown] = useState(false);
|
||||||
const { data, completedCount, totalCount } = useGetStartedMetadata();
|
const { data, completedCount, totalCount } = useGetStartedMetadata({ checkDemoAppExists: false });
|
||||||
|
|
||||||
if (hideGetStarted) {
|
if (hideGetStarted) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -23,17 +23,24 @@ type GetStartedMetadata = {
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useGetStartedMetadata = () => {
|
type Props = {
|
||||||
const { settings, updateSettings } = useSettings();
|
checkDemoAppExists: boolean;
|
||||||
const { data: demoApp, error } = useSWR<Application, RequestError>('/api/applications/demo_app', {
|
};
|
||||||
shouldRetryOnError: (error: unknown) => {
|
|
||||||
if (error instanceof RequestError) {
|
|
||||||
return error.status !== 404;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
const useGetStartedMetadata = ({ checkDemoAppExists }: Props) => {
|
||||||
},
|
const { settings, updateSettings } = useSettings();
|
||||||
});
|
const { data: demoApp, error } = useSWR<Application, RequestError>(
|
||||||
|
checkDemoAppExists && '/api/applications/demo_app',
|
||||||
|
{
|
||||||
|
shouldRetryOnError: (error: unknown) => {
|
||||||
|
if (error instanceof RequestError) {
|
||||||
|
return error.status !== 404;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const isLoadingDemoApp = !demoApp && !error;
|
const isLoadingDemoApp = !demoApp && !error;
|
||||||
const hideDemo = error?.status === 404;
|
const hideDemo = error?.status === 404;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import * as styles from './index.module.scss';
|
||||||
const GetStarted = () => {
|
const GetStarted = () => {
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { data, isLoading } = useGetStartedMetadata();
|
const { data, isLoading } = useGetStartedMetadata({ checkDemoAppExists: true });
|
||||||
const { update } = useUserPreferences();
|
const { update } = useUserPreferences();
|
||||||
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue