feat: dashboard v2, esm, upgrades (#211)
* esm * wip * wip * wip * wip * wip * wip * subscription notice * wip * wip * wip * fix envs * fix: update docker build * fix * esm/types * delete dashboard :D * add patches to dockerfiles * update packages + catalogs + ts * wip * remove native libs * ts * improvements * fix redirects and fetching session * try fix favicon * fixes * fix * order and resize reportds within a dashboard * improvements * wip * added userjot to dashboard * fix * add op * wip * different cache key * improve date picker * fix table * event details loading * redo onboarding completely * fix login * fix * fix * extend session, billing and improve bars * fix * reduce price on 10M
This commit is contained in:
committed by
GitHub
parent
436e81ecc9
commit
81a7e5d62e
73
apps/start/src/components/auth/sign-in-email-form.tsx
Normal file
73
apps/start/src/components/auth/sign-in-email-form.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
import { useTRPC } from '@/integrations/trpc/react';
|
||||
import { pushModal } from '@/modals';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { zSignInEmail } from '@openpanel/validation';
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { useNavigate, useRouter } from '@tanstack/react-router';
|
||||
import { type SubmitHandler, useForm } from 'react-hook-form';
|
||||
import { toast } from 'sonner';
|
||||
import type { z } from 'zod';
|
||||
import { InputWithLabel } from '../forms/input-with-label';
|
||||
import { Button } from '../ui/button';
|
||||
|
||||
const validator = zSignInEmail;
|
||||
type IForm = z.infer<typeof validator>;
|
||||
|
||||
export function SignInEmailForm() {
|
||||
const trpc = useTRPC();
|
||||
const mutation = useMutation(
|
||||
trpc.auth.signInEmail.mutationOptions({
|
||||
async onSuccess() {
|
||||
toast.success('Successfully signed in');
|
||||
window.location.href = '/';
|
||||
},
|
||||
onError(error) {
|
||||
toast.error(error.message);
|
||||
},
|
||||
}),
|
||||
);
|
||||
const form = useForm<IForm>({
|
||||
resolver: zodResolver(validator),
|
||||
defaultValues: {
|
||||
email: 'lindesvard+22@gmail.com',
|
||||
password: 'demodemo',
|
||||
},
|
||||
});
|
||||
const onSubmit: SubmitHandler<IForm> = (values) => {
|
||||
mutation.mutate({
|
||||
...values,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="col gap-4">
|
||||
<InputWithLabel
|
||||
{...form.register('email')}
|
||||
error={form.formState.errors.email?.message}
|
||||
label="Email"
|
||||
className="bg-def-100/50 border-def-300 focus:border-highlight focus:ring-highlight/20"
|
||||
/>
|
||||
<InputWithLabel
|
||||
{...form.register('password')}
|
||||
error={form.formState.errors.password?.message}
|
||||
label="Password"
|
||||
type="password"
|
||||
className="bg-def-100/50 border-def-300 focus:border-highlight focus:ring-highlight/20"
|
||||
/>
|
||||
<Button type="submit" size="lg">
|
||||
Sign in
|
||||
</Button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
pushModal('RequestPasswordReset', {
|
||||
email: form.getValues('email'),
|
||||
})
|
||||
}
|
||||
className="text-sm text-muted-foreground hover:text-highlight hover:underline transition-colors duration-200 text-center mt-2"
|
||||
>
|
||||
Forgot password?
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user