• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 10176725602

31 Jul 2024 08:24AM UTC coverage: 17.664% (-0.03%) from 17.693%
10176725602

Pull #721

github

web-flow
Merge dc771ad06 into f49c8d2a1
Pull Request #721: feat: sql query

1384 of 2812 branches covered (49.22%)

20 of 231 new or added lines in 9 files covered. (8.66%)

4 existing lines in 4 files now uncovered.

14040 of 79483 relevant lines covered (17.66%)

1.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/apps/nextjs-app/src/features/auth/pages/ResetPasswordPage.tsx
1
import { useMutation } from '@tanstack/react-query';
×
2
import { resetPassword } from '@teable/openapi';
×
3
import { passwordSchema } from '@teable/openapi/src/auth/types';
×
4
import { Spin } from '@teable/ui-lib/base';
×
5
import { Button, Input, Label, Separator, useToast } from '@teable/ui-lib/shadcn';
×
6
import { useRouter } from 'next/router';
×
7
import { useTranslation } from 'next-i18next';
×
8
import { useState } from 'react';
×
9
import { fromZodError } from 'zod-validation-error';
×
10
import { Error } from '@/components/Error';
×
11
import { authConfig } from '@/features/i18n/auth.config';
×
12
import { LayoutMain } from '../components/LayoutMain';
×
13

×
14
export const ResetPasswordPage = () => {
×
15
  const [error, setError] = useState<string>();
×
16
  const [password, setPassword] = useState<string>();
×
17
  const router = useRouter();
×
18
  const code = router.query.code as string;
×
19
  const { t } = useTranslation(authConfig.i18nNamespaces);
×
20
  const { toast } = useToast();
×
21

×
22
  const {
×
23
    mutate: resetPasswordMutate,
×
24
    isLoading,
×
25
    isSuccess,
×
26
  } = useMutation({
×
27
    mutationFn: resetPassword,
×
28
    onSuccess: () => {
×
29
      toast({
×
30
        title: t('auth:resetPassword.success.title'),
×
31
        description: t('auth:resetPassword.success.description'),
×
32
      });
×
33
      setTimeout(() => {
×
34
        router.push('/auth/login');
×
35
      }, 2000);
×
36
    },
×
37
  });
×
38

×
39
  const passwordOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
×
40
    const value = event.target.value;
×
41
    setPassword(value);
×
42
    setError(undefined);
×
43
  };
×
44

×
45
  const validPassword = (e: React.FocusEvent<HTMLInputElement, Element>) => {
×
46
    const value = e.target.value;
×
47
    if (!value) {
×
48
      return setError(t('auth:resetPassword.error.requiredPassword'));
×
49
    }
×
50
    const res = passwordSchema.safeParse(value);
×
51
    if (!res.success) {
×
52
      return setError(fromZodError(res.error).message);
×
53
    }
×
54
  };
×
55

×
56
  return (
×
57
    <LayoutMain>
×
58
      <h1 className="mb-3 text-2xl lg:text-3xl">{t('auth:resetPassword.header')}</h1>
×
59
      <p className="mb-10 text-sm text-muted-foreground">{t('auth:resetPassword.description')}</p>
×
60
      <div className="flex flex-col gap-2">
×
61
        <Label>{t('auth:resetPassword.label')}</Label>
×
62
        <div>
×
63
          <Input
×
64
            id="new-password"
×
65
            placeholder={t('auth:placeholder.password')}
×
66
            type="password"
×
67
            autoComplete="password"
×
68
            disabled={isLoading}
×
69
            onChange={passwordOnChange}
×
70
            onBlur={validPassword}
×
71
          />
×
72
          <Error error={code ? error : t('auth:resetPassword.error.invalidLink')} />
×
73
        </div>
×
74
        <Separator className="my-2" />
×
75
        <Button
×
76
          onClick={() => {
×
77
            if (error || isLoading || !password || isSuccess) return;
×
78
            resetPasswordMutate({ code, password });
×
79
          }}
×
80
        >
×
81
          {isLoading && <Spin />}
×
82
          {t('auth:resetPassword.buttonText')}
×
83
        </Button>
×
84
      </div>
×
85
    </LayoutMain>
×
86
  );
×
UNCOV
87
};
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc