refactor: filter by adminId

This commit is contained in:
Mauricio Siu
2024-10-03 00:45:46 -06:00
parent 600f4b2106
commit 5c72e5a452
11 changed files with 3938 additions and 49 deletions

View File

@@ -179,13 +179,11 @@ export default function Home({ hasAdmin }: Props) {
)}
<div className="flex flex-row justify-between flex-wrap">
<div className="mt-4 text-center text-sm flex flex-row justify-center gap-2">
Need help?
<Link
className="underline"
href="https://dokploy.com"
target="_blank"
className="hover:underline text-muted-foreground"
href="/register"
>
Contact us
Create an account
</Link>
</div>

View File

@@ -15,7 +15,7 @@ import {
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { isAdminPresent } from "@dokploy/builders";
import { IS_CLOUD, isAdminPresent } from "@dokploy/builders";
// import { IS_CLOUD } from "@/server/constants";
import { api } from "@/utils/api";
import { zodResolver } from "@hookform/resolvers/zod";
@@ -67,9 +67,10 @@ type Register = z.infer<typeof registerSchema>;
interface Props {
hasAdmin: boolean;
isCloud: boolean;
}
const Register = ({ hasAdmin }: Props) => {
const Register = ({ hasAdmin, isCloud }: Props) => {
const router = useRouter();
const { mutateAsync, error, isError } = api.auth.createAdmin.useMutation();
@@ -112,9 +113,12 @@ const Register = ({ hasAdmin }: Props) => {
<span className="font-medium text-sm">Dokploy</span>
</Link>
<CardTitle className="text-2xl font-bold">Setup the server</CardTitle>
<CardTitle className="text-2xl font-bold">
{isCloud ? "Create an account" : "Setup the server"}
</CardTitle>
<CardDescription>
Enter your email and password to setup the server
Enter your email and password to{" "}
{isCloud ? "create an account" : "setup the server"}
</CardDescription>
<Card className="mx-auto w-full max-w-lg bg-transparent">
<div className="p-3" />
@@ -192,24 +196,26 @@ const Register = ({ hasAdmin }: Props) => {
</div>
</form>
</Form>
{hasAdmin && (
<div className="mt-4 text-center text-sm">
Already have account?
<Link className="underline" href="/">
Sign in
<div className="flex flex-row justify-between flex-wrap">
{isCloud && (
<div className="mt-4 text-center text-sm flex gap-2">
Already have account?
<Link className="underline" href="/">
Sign in
</Link>
</div>
)}
<div className="mt-4 text-center text-sm flex flex-row justify-center gap-2">
Need help?
<Link
className="underline"
href="https://dokploy.com"
target="_blank"
>
Contact us
</Link>
</div>
)}
<div className="mt-4 text-center text-sm flex flex-row justify-center gap-2">
Need help?
<Link
className="underline"
href="https://dokploy.com"
target="_blank"
>
Contact us
</Link>
</div>
</CardContent>
</Card>
@@ -221,11 +227,13 @@ const Register = ({ hasAdmin }: Props) => {
export default Register;
export async function getServerSideProps() {
// if (IS_CLOUD) {
// return {
// props: {},
// };
// }
if (IS_CLOUD) {
return {
props: {
isCloud: true,
},
};
}
const hasAdmin = await isAdminPresent();
if (hasAdmin) {
@@ -239,6 +247,7 @@ export async function getServerSideProps() {
return {
props: {
hasAdmin,
isCloud: false,
},
};
}