refactor(client): use generated API client and hooks
Signed-off-by: Noa Virellia <noa@requiem.garden>
This commit is contained in:
@@ -9,7 +9,6 @@ import {
|
||||
DialogTrigger,
|
||||
} from '@/components/ui/dialog';
|
||||
import { QRCode } from '@/components/ui/shadcn-io/qr-code';
|
||||
import { useCheckinCode } from '@/hooks/data/useGetCheckInCode';
|
||||
import { Button } from '../ui/button';
|
||||
|
||||
export function QrDialog(
|
||||
@@ -35,23 +34,24 @@ export function QrDialog(
|
||||
}
|
||||
|
||||
function QrSection({ eventId, enabled }: { eventId: string; enabled: boolean }) {
|
||||
const { data } = useCheckinCode(eventId, enabled);
|
||||
// const { data } = useCheckinCode(eventId, enabled);
|
||||
const data = { data: { checkin_code: `dummy${eventId}${enabled}` } };
|
||||
return data
|
||||
? (
|
||||
<>
|
||||
<div className="border-2 px-4 py-8 border-muted rounded-xl flex flex-col items-center justify-center p-4">
|
||||
<QRCode data={data.data.checkin_code} className="size-60" />
|
||||
<>
|
||||
<div className="border-2 px-4 py-8 border-muted rounded-xl flex flex-col items-center justify-center p-4">
|
||||
<QRCode data={data.data.checkin_code} className="size-60" />
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<div className="flex flex-1 items-center ml-2 font-mono text-3xl tracking-widest text-primary/80 justify-center">
|
||||
{data.data.checkin_code}
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<div className="flex flex-1 items-center ml-2 font-mono text-3xl tracking-widest text-primary/80 justify-center">
|
||||
{data.data.checkin_code}
|
||||
</div>
|
||||
</DialogFooter>
|
||||
</>
|
||||
)
|
||||
</DialogFooter>
|
||||
</>
|
||||
)
|
||||
: (
|
||||
<QrSectionSkeleton />
|
||||
);
|
||||
<QrSectionSkeleton />
|
||||
);
|
||||
}
|
||||
|
||||
function QrSectionSkeleton() {
|
||||
|
||||
@@ -32,7 +32,7 @@ export function LoginForm({
|
||||
event.preventDefault();
|
||||
const formData = new FormData(formRef.current!);
|
||||
const email = formData.get('email')! as string;
|
||||
mutateAsync({ email, turnstile_token: token!, ...oauthParams }).then(() => {
|
||||
mutateAsync({ body: { email, turnstile_token: token!, ...oauthParams } }).then(() => {
|
||||
void navigate({ to: '/magicLinkSent', search: { email } });
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
|
||||
@@ -29,7 +29,8 @@ const formSchema = z.object({
|
||||
avatar: z.url().min(1),
|
||||
});
|
||||
export function EditProfileDialog() {
|
||||
const { data: user } = useUserInfo();
|
||||
const { data } = useUserInfo();
|
||||
const user = data.data!;
|
||||
const { mutateAsync } = useUpdateUser();
|
||||
|
||||
const form = useForm({
|
||||
@@ -46,7 +47,7 @@ export function EditProfileDialog() {
|
||||
value,
|
||||
}) => {
|
||||
try {
|
||||
await mutateAsync(value);
|
||||
await mutateAsync({ body: value });
|
||||
toast.success('个人资料更新成功');
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@@ -12,8 +12,9 @@ import { Button } from '../ui/button';
|
||||
import { EditProfileDialog } from './edit-profile-dialog';
|
||||
|
||||
export function MainProfile() {
|
||||
const { data: user } = useUserInfo();
|
||||
const [bio, setBio] = useState<string | undefined>(() => base64ToUtf8(user.bio));
|
||||
const { data } = useUserInfo();
|
||||
const user = data.data!;
|
||||
const [bio, setBio] = useState<string | undefined>(() => base64ToUtf8(user.bio ?? ''));
|
||||
const [enableBioEdit, setEnableBioEdit] = useState(false);
|
||||
const { mutateAsync } = useUpdateUser();
|
||||
|
||||
@@ -61,7 +62,7 @@ export function MainProfile() {
|
||||
else {
|
||||
if (!isNil(bio)) {
|
||||
try {
|
||||
await mutateAsync({ bio: utf8ToBase64(bio) });
|
||||
await mutateAsync({ body: { bio: utf8ToBase64(bio) } });
|
||||
setEnableBioEdit(false);
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@@ -29,7 +29,8 @@ import { Skeleton } from '../ui/skeleton';
|
||||
|
||||
function NavUser_() {
|
||||
const { isMobile } = useSidebar();
|
||||
const { data: user } = useUserInfo();
|
||||
const { data } = useUserInfo();
|
||||
const user = data.data!;
|
||||
const { logout } = useLogout();
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user