refactor: add license

This commit is contained in:
Mauricio Siu
2024-08-25 20:16:52 -06:00
parent e0a9eb0366
commit 5ea7a31c6d
5 changed files with 40 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import type { GetServerSidePropsContext } from "next";
import type { ReactElement } from "react";
import * as React from "react";
import { ShowRequests } from "@/components/dashboard/requests/show-requests";
import { isValidLicense } from "@/server/api/services/license";
export default function Requests() {
return <ShowRequests />;
@@ -24,6 +25,17 @@ export async function getServerSideProps(
};
}
const isValid = await isValidLicense();
if (!isValid) {
return {
redirect: {
permanent: true,
destination: "/dashboard/projects",
},
};
}
return {
props: {},
};

View File

@@ -28,9 +28,7 @@ import { toast } from "sonner";
import { z } from "zod";
const schema = z.object({
licenseKey: z.string().min(1, {
message: "License key is required",
}),
licenseKey: z.string(),
});
type Schema = z.infer<typeof schema>;