Skip to content

Commit

Permalink
feat(AuthPage, validateSchema): move validateSchema, change arrowFunc…
Browse files Browse the repository at this point in the history
…tion for AuthPage, AuthLayout
  • Loading branch information
TanNguyen17112003 committed Sep 18, 2023
1 parent 92ae9cf commit 9d1e871
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

2 changes: 1 addition & 1 deletion src/layouts/AuthLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ILayout } from '@interfaces';
import logo from '@assets/images/logobk.png';
import corner from '@assets/images/corner.png';
export const AuthLayout: ILayout = function ({ children }) {
export const AuthLayout: ILayout = ({ children }) => {
return (
<div className='flex flex-col items-center w-full h-[100vh] gap-6 bg-[#F8F9FA] fixed'>
<div className="bg-[url('./src/assets/images/header.png')] bg-no-repeat bg-cover bg-center py-5">
Expand Down
14 changes: 7 additions & 7 deletions src/pages/AuthPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { authService } from '@services';
import { useUserStore } from '@states';
import { useState } from 'react';
import { EyeIcon, EyeSlashIcon } from '@heroicons/react/24/outline';
import { validateSchema } from '@utils';
import { validateSchema } from './validateSchema';
import { yupResolver } from '@hookform/resolvers/yup';

export function AuthPage() {
export const AuthPage = () => {
const {
register,
handleSubmit,
Expand Down Expand Up @@ -42,20 +42,20 @@ export function AuthPage() {
<div className='mb-16 flex flex-col gap-6'>
<Input
size='lg'
label='Username'
{...register('username', {
label='Email'
{...register('email', {
required: true,
minLength: 5
})}
type='text'
crossOrigin=''
className={
errors.username
errors.email
? 'focus:text-red-200 focus:font-bold focus:bg-[#fdf2f2] !text-red-200 !font-bold !bg-[#fdf2f2]'
: 'bg-white'
}
/>
<h4 className='text-[red] font-bold'>{errors.username?.message}</h4>
<h4 className='text-[red] font-bold'>{errors.email?.message}</h4>
<div className='relative'>
<Input
type={showPassword}
Expand Down Expand Up @@ -94,4 +94,4 @@ export function AuthPage() {
</form>
</Card>
);
}
};
1 change: 1 addition & 0 deletions src/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
export * from './AuthPage';
export * from './ProjectDetailPage';
export * from './ProjectGeneralPage';
export * from './validateSchema';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Yup from 'yup';
export const validateSchema = Yup.object().shape({
username: Yup.string()
email: Yup.string()
.required('Username is required!')
.min(5, 'Username must be at least 5 characters'),
password: Yup.string()
Expand Down
2 changes: 1 addition & 1 deletion src/services/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { server, invoke } from './common';

export const userService = {
getInfo: () => invoke<string[]>(server.get('/api/users'))
getInfo: () => invoke<string[]>(server.get('/api/user'))
};
2 changes: 1 addition & 1 deletion src/types/loginFormData.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type LoginFormData = {
username: string;
email: string;
password: string;
};
1 change: 0 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
*/

export * from './escapeRegex';
export * from './validateSchema';

0 comments on commit 9d1e871

Please sign in to comment.