mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-10-14 02:09:04 +03:00
refactor amnet-web to use shared lib
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import {z} from "zod";
|
||||
import React, {useEffect} from "react";
|
||||
import {Check, Plus, X} from "lucide-react";
|
||||
import {useLocation} from "react-router-dom";
|
||||
import {useLiveQuery} from "dexie-react-hooks";
|
||||
import {FormProvider, useForm} from "react-hook-form";
|
||||
import {validateCardId, generateCardNumber} from "amnet-shared/src/card";
|
||||
|
||||
import {useMediaQuery} from "@/hooks/use-media-query";
|
||||
import {cn} from "@/lib/utils";
|
||||
import {zodResolver} from "@hookform/resolvers/zod";
|
||||
|
||||
import {useMediaQuery} from "@/hooks/use-media-query";
|
||||
import {AimeCard, CARD_LIMIT, db} from "@/lib/database";
|
||||
import {generateAimeCardId, validateAimeCardId} from "@/lib/aime-card";
|
||||
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
@@ -36,15 +38,12 @@ import {
|
||||
DrawerTitle,
|
||||
DrawerTrigger
|
||||
} from "@/components/ui/drawer";
|
||||
import {useLiveQuery} from "dexie-react-hooks";
|
||||
import {cn} from "@/lib/utils.ts";
|
||||
import {useLocation} from "react-router-dom";
|
||||
|
||||
const schema = z.object({
|
||||
name: z.string().min(1, {
|
||||
message: "A name/description must be provided"
|
||||
}),
|
||||
id: z.string().refine(validateAimeCardId, {
|
||||
id: z.string().refine(validateCardId, {
|
||||
message: "Card id must be 20 digits and not start with the number 3"
|
||||
})
|
||||
});
|
||||
@@ -102,7 +101,7 @@ function AimeCardCreationForm(props: { callback?: () => void }) {
|
||||
<FormDescription>
|
||||
If you've got a card, enter the matrix code here. If not, you can
|
||||
<span className="font-bold hover:cursor-pointer ml-1"
|
||||
onClick={() => form.setValue("id", generateAimeCardId())}>
|
||||
onClick={() => form.setValue("id", generateCardNumber())}>
|
||||
generate a new one.
|
||||
</span>
|
||||
</FormDescription>
|
||||
|
||||
Reference in New Issue
Block a user