Skip to content

Commit

Permalink
fix:Codacy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
iakivpekarskyi committed Jul 21, 2024
1 parent ac4a0ef commit 850bd0c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
54 changes: 34 additions & 20 deletions src/components/Auth/Forms/LoginForm/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'

import useAuthRedirect from '@/hooks/useAuthRedirect'
import Button from '@/components/UI/Buttons/Button/Button'
import FormInput from '@/components/UI/FormInput/FormInput'
Expand All @@ -16,6 +17,11 @@ import Link from 'next/link'
import Image from 'next/image'
import eye from '../../../../../public/eye-password-hide.svg'

type LoginResponse = {

Check warning on line 20 in src/components/Auth/Forms/LoginForm/LoginForm.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/Auth/Forms/LoginForm/LoginForm.tsx#L20

Use an `interface` instead of a `type`.
token: string
refreshToken: string
}

export default function LoginForm() {
const [loading, setLoading] = useState(false)
const { authenticate, setRefreshToken } = useAuthStore()
Expand All @@ -39,7 +45,7 @@ export default function LoginForm() {
const onSubmit: SubmitHandler<IFormValues> = async (formData) => {
try {
setLoading(true)
const data = await apiLoginUser(formData)
const data: LoginResponse = await apiLoginUser(formData)

Check failure on line 48 in src/components/Auth/Forms/LoginForm/LoginForm.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/Auth/Forms/LoginForm/LoginForm.tsx#L48

Unsafe assignment of an `any` value.

Check failure on line 48 in src/components/Auth/Forms/LoginForm/LoginForm.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/Auth/Forms/LoginForm/LoginForm.tsx#L48

Unsafe call of an `any` typed value.

if (data) {
await setCookie('token', data.token, { path: '/' })
Expand All @@ -60,52 +66,60 @@ export default function LoginForm() {
onSubmit={handleSubmit(onSubmit)}

Check failure on line 66 in src/components/Auth/Forms/LoginForm/LoginForm.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/Auth/Forms/LoginForm/LoginForm.tsx#L66

Unsafe assignment of an `any` value.

Check failure on line 66 in src/components/Auth/Forms/LoginForm/LoginForm.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/Auth/Forms/LoginForm/LoginForm.tsx#L66

Unsafe call of an `any` typed value.
className="flex flex-col font-bold text-disabled "

Check notice on line 67 in src/components/Auth/Forms/LoginForm/LoginForm.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/Auth/Forms/LoginForm/LoginForm.tsx#L67

Props should be sorted alphabetically
>
{errorMessage && (
<div className="mt-4 text-negative">{errorMessage}</div>
)}
{errorMessage && <div className="mt-4 text-negative">{errorMessage}</div>}

<FormInput
className="mt-0"
error={errors.email}
id="email"
register={register}
name="email"
type="text"
label=""
name="email"
placeholder="Email"
error={errors.email}
register={register}
type="text"
/>
<div className="relative font-bold">
{/* Updated: Alphabetically sorted props */}
<FormInput
className="mt-0"
error={errors.password}
id="password"
register={register}
type={passwordVisible ? 'text' : 'password'}
name="password"
label=""
name="password"
placeholder="Password"
error={errors.password}
className="mt-0"
register={register}
type={passwordVisible ? 'text' : 'password'}
/>

<button
type="button"
onMouseDown={() => setPasswordVisible(true)}
onMouseUp={() => setPasswordVisible(false)}
onMouseLeave={() => setPasswordVisible(false)}
className="absolute inset-y-0 right-0 mt-5 flex items-center pr-3"
onMouseDown={() => {
setPasswordVisible(true)
}}
onMouseLeave={() => {
setPasswordVisible(false)
}}
onMouseUp={() => {
setPasswordVisible(false)
}}
type="button"
>
<div className="h-[18px] w-[18px] sm:h-[31px] sm:w-[28px]">
<Image src={eye} width={24} alt="Logo" priority />

Check notice on line 108 in src/components/Auth/Forms/LoginForm/LoginForm.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/Auth/Forms/LoginForm/LoginForm.tsx#L108

Props should be sorted alphabetically

Check failure on line 108 in src/components/Auth/Forms/LoginForm/LoginForm.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/Auth/Forms/LoginForm/LoginForm.tsx#L108

Unsafe assignment of an `any` value.
</div>
</button>
</div>
<Link
onClick={resetOpenModal}
href={'/forgotpass'}
className="mt-2 flex items-center font-bold text-focus"
href={'/forgotpass'}
onClick={resetOpenModal}

Check failure on line 115 in src/components/Auth/Forms/LoginForm/LoginForm.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/Auth/Forms/LoginForm/LoginForm.tsx#L115

Unsafe assignment of an `any` value.
>
Forgot password?
</Link>
<Button
className="mt-6 flex w-full items-center justify-center hover:bg-brand-solid-hover"
id="login-btn"
type="submit"
className="mt-6 flex w-full items-center justify-center hover:bg-brand-solid-hover"
>
{loading ? <Loader /> : 'Login'}
</Button>
Expand Down
5 changes: 3 additions & 2 deletions src/components/UI/Buttons/GoogleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Image from 'next/image'
import google from '../../../../public/google.svg'

const GoogleAuthButton: React.FC = () => {
const handleGoogleAuth = () => {
const handleGoogleAuth = (): void => {
// Implement Google authentication logic here
console.log('Initiating Google authentication...')
}
Expand All @@ -12,9 +12,10 @@ const GoogleAuthButton: React.FC = () => {
<button
aria-label="Sign in with Google"
className="flex w-full items-center justify-start rounded-full border-2 border-black bg-white py-2"
id="goodle-btn"
onClick={handleGoogleAuth}
>
<div className="ml-6 flex h-9 w-9 items-center justify-center rounded-full bg-white ">
<div className="ml-6 flex h-9 w-9 items-center justify-center rounded-full bg-white">
<div className="flex h-[24px] w-[24px] items-center justify-center sm:h-[31px] sm:w-[28px]">
<Image src={google} width={24} alt="google logo" priority />

Check notice on line 20 in src/components/UI/Buttons/GoogleButton.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/UI/Buttons/GoogleButton.tsx#L20

Props should be sorted alphabetically

Check failure on line 20 in src/components/UI/Buttons/GoogleButton.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/components/UI/Buttons/GoogleButton.tsx#L20

Unsafe assignment of an `any` value.
</div>
Expand Down

0 comments on commit 850bd0c

Please sign in to comment.