-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix merge problems
- Loading branch information
Showing
11 changed files
with
157 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
backend/src/configs/prisma/migrations/20240811180110_make_username_unique/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
Warnings: | ||
- A unique constraint covering the columns `[username]` on the table `User` will be added. If there are existing duplicate values, this will fail. | ||
*/ | ||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Groups from '@widgets/groups'; | ||
import { useGroupStore } from '@entities/group'; | ||
import { useEffect } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { Route } from '@shared/types'; | ||
|
||
const Main = () => { | ||
const fetchGroups = useGroupStore((state) => state.fetch); | ||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
fetchGroups().catch(() => { | ||
navigate(Route.SignIn); | ||
}); | ||
}, []); | ||
return ( | ||
<div className='md:w-6/12 m-auto h-full'> | ||
<Groups /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { create } from 'zustand'; | ||
import { authService } from '@shared/api'; | ||
import { persist } from 'zustand/middleware'; | ||
|
||
interface State { | ||
username: string; | ||
} | ||
|
||
interface Action { | ||
login: (username: string, password: string) => Promise<void>; | ||
register: (username: string, password: string) => Promise<void>; | ||
signOut: () => void; | ||
} | ||
|
||
export const useAuthStore = create( | ||
persist<State & Action>( | ||
(set) => ({ | ||
username: '', | ||
|
||
login: async (username, password) => { | ||
try { | ||
await authService.login(username, password); | ||
set(() => ({ username })); | ||
} catch { | ||
set(() => ({ username: '' })); | ||
} | ||
}, | ||
register: async (username, password) => { | ||
try { | ||
await authService.register(username, password); | ||
set(() => ({ username })); | ||
} catch { | ||
set(() => ({ username: '' })); | ||
} | ||
}, | ||
signOut: () => { | ||
set(() => ({ username: '' })); | ||
}, | ||
}), | ||
{ name: 'auth' } | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import { FC, InputHTMLAttributes } from 'react'; | ||
import { InputHTMLAttributes, forwardRef } from 'react'; | ||
import './style.css'; | ||
|
||
interface TextFieldProps extends InputHTMLAttributes<HTMLInputElement> { | ||
interface Props extends InputHTMLAttributes<HTMLInputElement> { | ||
variant?: 'primary'; | ||
autoFocus?: boolean; | ||
} | ||
|
||
export const TextField: FC<TextFieldProps> = ({ variant = 'primary', ...props }) => ( | ||
<input className={`input input--${variant}`} {...props} /> | ||
export const TextField = forwardRef<HTMLInputElement, Props>( | ||
({ variant = 'primary', ...props }, ref) => ( | ||
<input ref={ref} className={`input input--${variant}`} {...props} /> | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { WriteStudy } from '@features/write-study'; | ||
import { forwardRef } from 'react'; | ||
|
||
export const StudyModes = () => ( | ||
<div className='flex flex-col gap-2'> | ||
export const StudyModes = forwardRef<HTMLDivElement>((_, ref) => ( | ||
<div ref={ref} className='flex flex-col gap-2'> | ||
<h1 className='text-white text-xl text-center'>Study modes</h1> | ||
<div className='w-full justify-center flex'> | ||
<WriteStudy /> | ||
</div> | ||
</div> | ||
); | ||
)); |