fix crash error

This commit is contained in:
oiov
2024-08-01 11:35:57 +08:00
parent 3184e22a12
commit f04a1b6875
10 changed files with 100 additions and 109 deletions
@@ -6,8 +6,8 @@ import { User } from "@prisma/client";
import { PenLine, RefreshCwIcon } from "lucide-react";
import useSWR, { useSWRConfig } from "swr";
import { TTL_ENUMS } from "@/lib/cloudflare";
import { UserRecordFormData } from "@/lib/dto/cloudflare-dns-record";
import { TTL_ENUMS } from "@/lib/enums";
import { fetcher } from "@/lib/utils";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
+1 -1
View File
@@ -7,7 +7,7 @@ import { PenLine, RefreshCwIcon } from "lucide-react";
import useSWR, { useSWRConfig } from "swr";
import { siteConfig } from "@/config/site";
import { EXPIRATION_ENUMS, ShortUrlFormData } from "@/lib/dto/short-urls";
import { ShortUrlFormData } from "@/lib/dto/short-urls";
import { cn, expirationTime, fetcher, timeAgo } from "@/lib/utils";
import { useMediaQuery } from "@/hooks/use-media-query";
import { Button } from "@/components/ui/button";
-5
View File
@@ -5,11 +5,6 @@ import Resend from "next-auth/providers/resend";
import { env } from "@/env.mjs";
// import { siteConfig } from "@/config/site"
// import { getUserByEmail } from "@/lib/user";
// import MagicLinkEmail from "@/emails/magic-link-email"
// import { prisma } from "@/lib/db"
export default {
providers: [
Google({
+3 -7
View File
@@ -6,13 +6,9 @@ import { User } from "@prisma/client";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import {
CreateDNSRecord,
RECORD_TYPE_ENUMS,
RecordType,
TTL_ENUMS,
} from "@/lib/cloudflare";
import { CreateDNSRecord, RecordType } from "@/lib/cloudflare";
import { UserRecordFormData } from "@/lib/dto/cloudflare-dns-record";
import { RECORD_TYPE_ENUMS, TTL_ENUMS } from "@/lib/enums";
import { createRecordSchema } from "@/lib/validations/record";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -260,7 +256,7 @@ export function RecordForm({
setValue("ttl", Number(value));
}}
name="ttl"
defaultValue={`${initData?.ttl}` || "1"}
defaultValue={String(initData?.ttl || 1)}
>
<SelectTrigger className="w-full shadow-inner">
<SelectValue placeholder="Select a time" />
+2 -1
View File
@@ -7,7 +7,8 @@ import { Sparkles } from "lucide-react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { EXPIRATION_ENUMS, ShortUrlFormData } from "@/lib/dto/short-urls";
import { ShortUrlFormData } from "@/lib/dto/short-urls";
import { EXPIRATION_ENUMS } from "@/lib/enums";
import { generateUrlSuffix } from "@/lib/utils";
import { createUrlSchema } from "@/lib/validations/url";
import { Button } from "@/components/ui/button";
+1 -1
View File
@@ -6,7 +6,7 @@ import { User, UserRole } from "@prisma/client";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { ROLE_ENUM } from "@/lib/dto/user";
import { ROLE_ENUM } from "@/lib/enums";
import { updateUserSchema } from "@/lib/validations/auth";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
-43
View File
@@ -54,49 +54,6 @@ export interface ResultMeta {
export type RecordType = "A" | "CNAME";
export const RECORD_TYPE_ENUMS = [
{
value: "CNAME",
label: "CNAME",
},
{
value: "A",
label: "A",
},
];
export const TTL_ENUMS = [
{
value: "1",
label: "Auto",
},
{
value: "300",
label: "5min",
},
{
value: "3600",
label: "1h",
},
{
value: "18000",
label: "5h",
},
{
value: "86400",
label: "1d",
},
];
export const STATUS_ENUMS = [
{
value: 1,
label: "Active",
},
{
value: 0,
label: "Inactive",
},
];
export const createDNSRecord = async (
zoneId: string,
apiKey: string,
-39
View File
@@ -21,45 +21,6 @@ export interface UserShortUrlInfo extends ShortUrlFormData {
meta?: UrlMeta;
}
export const EXPIRATION_ENUMS = [
{
value: "-1",
label: "Never",
},
{
value: "600", // 10 min
label: "10min",
},
{
value: "3600", // 1h
label: "1h",
},
{
value: "43200", // 12h
label: "12h",
},
{
value: "86400", // 1d
label: "1d",
},
{
value: "604800", // 7d
label: "7d",
},
{
value: "2592000", // 30d
label: "30d",
},
{
value: "7776000", // 90d
label: "90d",
},
{
value: "31536000", // 365d
label: "365d",
},
];
export async function getUserShortUrls(
userId: string,
active: number = 1,
-11
View File
@@ -4,17 +4,6 @@ import { prisma } from "@/lib/db";
export interface UpdateUserForm extends Omit<User, "id" | "createdAt"> {}
export const ROLE_ENUM = [
{
label: "User",
value: "USER",
},
{
label: "Admin",
value: "ADMIN",
},
];
export const getUserByEmail = async (email: string) => {
try {
const user = await prisma.user.findUnique({
+92
View File
@@ -0,0 +1,92 @@
export const EXPIRATION_ENUMS = [
{
value: "-1",
label: "Never",
},
{
value: "600", // 10 min
label: "10min",
},
{
value: "3600", // 1h
label: "1h",
},
{
value: "43200", // 12h
label: "12h",
},
{
value: "86400", // 1d
label: "1d",
},
{
value: "604800", // 7d
label: "7d",
},
{
value: "2592000", // 30d
label: "30d",
},
{
value: "7776000", // 90d
label: "90d",
},
{
value: "31536000", // 365d
label: "365d",
},
];
export const ROLE_ENUM = [
{
label: "User",
value: "USER",
},
{
label: "Admin",
value: "ADMIN",
},
];
export const RECORD_TYPE_ENUMS = [
{
value: "CNAME",
label: "CNAME",
},
{
value: "A",
label: "A",
},
];
export const TTL_ENUMS = [
{
value: "1",
label: "Auto",
},
{
value: "300",
label: "5min",
},
{
value: "3600",
label: "1h",
},
{
value: "18000",
label: "5h",
},
{
value: "86400",
label: "1d",
},
];
export const STATUS_ENUMS = [
{
value: 1,
label: "Active",
},
{
value: 0,
label: "Inactive",
},
];