add loading spinner to logout process

This commit is contained in:
Matthias Nannt
2023-04-11 10:52:16 +02:00
parent 357628b0d6
commit 68cd7a9a81
3 changed files with 7 additions and 11 deletions

View File

@@ -55,6 +55,7 @@ interface EnvironmentsNavbarProps {
export default function EnvironmentsNavbar({ environmentId, session }: EnvironmentsNavbarProps) {
const router = useRouter();
const [loading, setLoading] = useState(false);
const { environment, isErrorEnvironment, isLoadingEnvironment } = useEnvironment(environmentId);
const pathname = usePathname();
@@ -180,7 +181,7 @@ export default function EnvironmentsNavbar({ environmentId, session }: Environme
router.push(`/environments/${newEnvironmentId}/`);
};
if (isLoadingEnvironment) {
if (isLoadingEnvironment || loading) {
return <LoadingSpinner />;
}
@@ -328,12 +329,9 @@ export default function EnvironmentsNavbar({ environmentId, session }: Environme
<div className="flex items-center">
<ArrowRightOnRectangleIcon className="mr-2 h-4 w-4" />
<button
onClick={async () => {
try {
await signOut();
} catch (error) {
console.error("Failed to sign out:", error);
}
onClick={() => {
signOut();
setLoading(true);
}}>
Logout
</button>

View File

@@ -19,10 +19,10 @@ const AddEmailAlertModal: React.FC<AddEmailAlertModalProps> = ({ open, setOpen }
];
const onTest = () => {
console.log("Test button clicked!");
throw Error("not implemented");
};
const onSave = () => {
console.log("Save button clicked!");
throw Error("not implemented");
};
return (

View File

@@ -33,7 +33,5 @@ export default function ApiKeyList({
const environmentTypeId = findEnvironmentByType(product?.environments, environmentType);
console.log(environmentTypeId);
return <EditApiKeys environmentTypeId={environmentTypeId} environmentType={environmentType} />;
}