feat: converting space app to use nextjs app dir (#4451)

* feat: changemod space

* fix: space app dir fixes

* fix: build errors
This commit is contained in:
sriram veeraghanta 2024-05-14 14:26:54 +05:30 committed by GitHub
parent 087d54a261
commit febf19ccc0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
98 changed files with 1038 additions and 1551 deletions

43
space/app/page.tsx Normal file
View file

@ -0,0 +1,43 @@
// components
import { UserLoggedIn } from "@/components/accounts";
import { InstanceNotReady, InstanceFailureView } from "@/components/instance";
import { AuthView } from "@/components/views";
// helpers
// import { EPageTypes } from "@/helpers/authentication.helper";
// import { useInstance, useUser } from "@/hooks/store";
// wrapper
// import { AuthWrapper } from "@/lib/wrappers";
// lib
import { AppProvider } from "@/lib/app-providers";
// services
import { InstanceService } from "@/services/instance.service";
import { UserService } from "@/services/user.service";
const userServices = new UserService();
const instanceService = new InstanceService();
export default async function HomePage() {
const instanceDetails = await instanceService.getInstanceInfo().catch(() => undefined);
const user = await userServices
.currentUser()
.then((user) => ({ ...user, isAuthenticated: true }))
.catch(() => ({ isAuthenticated: false }));
if (!instanceDetails) {
return <InstanceFailureView />;
}
if (!instanceDetails?.instance?.is_setup_done) {
<InstanceNotReady />;
}
if (user.isAuthenticated) {
return <UserLoggedIn />;
}
return (
<AppProvider initialState={{ instance: instanceDetails.instance }}>
<AuthView />
</AppProvider>
);
}