add log for sign in, sign out, change password, remove upload file

This commit is contained in:
2026-01-09 19:38:54 +07:00
parent 427a1040cf
commit ae39cc111f
32 changed files with 1991 additions and 212 deletions

View File

@@ -73,17 +73,6 @@ export default function Header() {
)}
</div>
</header>
{/* <Link
to="/demo/start/ssr"
onClick={() => setIsOpen(false)}
className="flex-1 flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800 transition-colors mb-2"
activeProps={{
className:
'flex-1 flex items-center gap-3 p-3 rounded-lg bg-cyan-600 hover:bg-cyan-700 transition-colors mb-2',
}}
>
<span className="font-medium">Start - SSR Demos</span>
</Link> */}
</>
);
}

View File

@@ -2,7 +2,6 @@ import { authClient } from '@/lib/auth-client';
import { m } from '@/paraglide/messages';
import { KeyIcon } from '@phosphor-icons/react';
import { useForm } from '@tanstack/react-form';
import i18next from 'i18next';
import { toast } from 'sonner';
import z from 'zod';
import { Button } from '../ui/button';
@@ -72,9 +71,14 @@ const ChangePasswordForm = () => {
},
onError: (ctx) => {
console.log(ctx.error.code);
toast.error(i18next.t(`backend_${ctx.error.code}` as any), {
richColors: true,
});
toast.error(
(
m[`backend_${ctx.error.code}` as keyof typeof m] as () => string
)(),
{
richColors: true,
},
);
},
},
);

View File

@@ -1,11 +1,9 @@
import { authClient } from '@/lib/auth-client';
import { m } from '@/paraglide/messages';
import { uploadProfileImage } from '@/service/profile.api';
import { ProfileInput, profileUpdateSchema } from '@/service/profile.schema';
import { UserCircleIcon } from '@phosphor-icons/react';
import { useForm } from '@tanstack/react-form';
import { useQueryClient } from '@tanstack/react-query';
import i18next from 'i18next';
import { useRef } from 'react';
import { toast } from 'sonner';
import { useAuth } from '../auth/auth-provider';
@@ -37,21 +35,9 @@ const ProfileForm = () => {
},
onSubmit: async ({ value }) => {
try {
let imageKey;
if (value.image) {
// upload image
const formData = new FormData();
formData.set('file', value.image);
const { imageKey: uploadedKey } = await uploadProfileImage({
data: formData,
});
imageKey = uploadedKey;
}
await authClient.updateUser(
{
name: value.name,
image: imageKey,
},
{
onSuccess: () => {
@@ -67,9 +53,16 @@ const ProfileForm = () => {
});
},
onError: (ctx) => {
toast.error(i18next.t(`backend.${ctx.error.code}` as any), {
richColors: true,
});
toast.error(
(
m[
`backend_${ctx.error.code}` as keyof typeof m
] as () => string
)(),
{
richColors: true,
},
);
},
},
);

View File

@@ -27,10 +27,7 @@ const SettingsForm = () => {
const updateMutation = useMutation({
mutationFn: updateAdminSettings,
onSuccess: () => {
// setLocale(variables.data.site_language as Locale);
queryClient.invalidateQueries({
queryKey: [...settingQueries.all, 'list'],
});
queryClient.invalidateQueries(settingQueries.listAdmin());
toast.success(m.settings_messages_update_success(), {
richColors: true,
});

View File

@@ -3,7 +3,6 @@ import { m } from '@/paraglide/messages';
import { useForm } from '@tanstack/react-form';
import { useQueryClient } from '@tanstack/react-query';
import { createLink, useNavigate } from '@tanstack/react-router';
import i18next from 'i18next';
import { toast } from 'sonner';
import z from 'zod';
import { Button } from '../ui/button';
@@ -14,7 +13,7 @@ import { Input } from '../ui/input';
const SignInFormSchema = z.object({
email: z
.string()
.nonempty(m.common_is_required({ field: m.login_page_form_email }))
.nonempty(m.common_is_required({ field: m.login_page_form_email() }))
.email(m.login_page_messages_email_invalid()),
password: z.string().nonempty(
m.common_is_required({
@@ -52,9 +51,14 @@ const SignInForm = () => {
});
},
onError: (ctx) => {
toast.error(i18next.t(`backend.${ctx.error.code}` as any), {
richColors: true,
});
toast.error(
(
m[`backend_${ctx.error.code}` as keyof typeof m] as () => string
)(),
{
richColors: true,
},
);
},
},
);

View File

@@ -9,7 +9,6 @@ import {
} from '@phosphor-icons/react';
import { useQueryClient } from '@tanstack/react-query';
import { createLink, Link, useNavigate } from '@tanstack/react-router';
import i18next from 'i18next';
import { toast } from 'sonner';
import { useAuth } from '../auth/auth-provider';
import AvatarUser from '../avatar/AvatarUser';
@@ -49,9 +48,14 @@ const NavUser = () => {
});
},
onError: (ctx) => {
toast.error(i18next.t(`backend_${ctx.error.code}` as any), {
richColors: true,
});
toast.error(
(
m[`backend_${ctx.error.code}` as keyof typeof m] as () => string
)(),
{
richColors: true,
},
);
},
},
});