Skip to content

Commit

Permalink
Some code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Matushl committed Dec 10, 2023
1 parent 2e4b613 commit fc3a44c
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/components/Admin/resources/cms/post/PostList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {FC} from 'react'
import {Datagrid, DateField, FunctionField, List, NumberField, RaRecord, TextField} from 'react-admin'
import {Datagrid, DateField, FunctionField, List, RaRecord, TextField} from 'react-admin'

import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField'
import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField'
Expand Down
24 changes: 11 additions & 13 deletions src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@ export const LoginFormWrapper: FC<LoginFormWrapperProps> = ({closeOverlay}) => {

if (form === 'login')
return (
<>
<Stack gap={2}>
<LoginForm closeOverlay={closeOverlay} />
<Stack alignItems="center" mt={2}>
<Button
onClick={() => {
changeForm('reset')
}}
>
Zabudnuté heslo
</Button>
</Stack>
<Stack gap={2}>
<LoginForm closeOverlay={closeOverlay} />
<Stack alignItems="center" mt={2}>
<Button
onClick={() => {
changeForm('reset')
}}
>
Zabudnuté heslo
</Button>
</Stack>
</>
</Stack>
)

return (
Expand Down
86 changes: 41 additions & 45 deletions src/components/PasswordReset/PasswordReset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,54 +54,50 @@ export const PasswordResetForm: FC<PasswordResetFormProps> = ({uid, token}) => {

if (isReset)
return (
<>
<Stack gap={2}>
<Typography variant="body1">Heslo úspešne zmenené, môžeš sa prihlásiť</Typography>
<LoginForm
closeOverlay={() => {
router.push('/')
}}
/>
</Stack>
</>
<Stack gap={2}>
<Typography variant="body1">Heslo úspešne zmenené, môžeš sa prihlásiť</Typography>
<LoginForm
closeOverlay={() => {
router.push('/')
}}
/>
</Stack>
)

return (
<>
<form onSubmit={handleSubmit(onSubmit)}>
<Stack gap={2}>
<FormInput
control={control}
name="password1"
label="heslo*"
type="password"
rules={{
...requiredRule,
minLength: {
value: 8,
message: '* Toto heslo je príliš krátke. Musí obsahovať aspoň 8 znakov.',
},
}}
/>
<FormInput
control={control}
name="password2"
label="potvrdenie hesla*"
type="password"
rules={{
...requiredRule,
validate: (val) => {
if (val !== getValues().password1) return '* Zadané heslá sa nezhodujú.'
},
}}
/>
<Stack alignItems="center" mt={2}>
<Button variant="button2" type="submit">
Resetovať heslo
</Button>
</Stack>
<form onSubmit={handleSubmit(onSubmit)}>
<Stack gap={2}>
<FormInput
control={control}
name="password1"
label="heslo*"
type="password"
rules={{
...requiredRule,
minLength: {
value: 8,
message: '* Toto heslo je príliš krátke. Musí obsahovať aspoň 8 znakov.',
},
}}
/>
<FormInput
control={control}
name="password2"
label="potvrdenie hesla*"
type="password"
rules={{
...requiredRule,
validate: (val) => {
if (val !== getValues().password1) return '* Zadané heslá sa nezhodujú.'
},
}}
/>
<Stack alignItems="center" mt={2}>
<Button variant="button2" type="submit">
Resetovať heslo
</Button>
</Stack>
</form>
</>
</Stack>
</form>
)
}
2 changes: 1 addition & 1 deletion src/components/Posts/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IPost {
sites: number[]
}

export const Post: FC<IPost> = ({id, caption, short_text, links, sites, added_at}) => {
export const Post: FC<IPost> = ({caption, short_text, links, sites, added_at}) => {
const {seminarId} = useSeminarInfo()

if (!sites.includes(seminarId)) return null
Expand Down
3 changes: 1 addition & 2 deletions src/pages/malynar/reset-sent/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {NextPage} from 'next'

import {PageLayout} from '@/components/PageLayout/PageLayout'
import {PasswordResetSent} from '@/components/PasswordResetSent/PasswordResetSent'

import {PageLayout} from '../../../components/PageLayout/PageLayout'

const Verifikacia: NextPage = () => {
return (
<PageLayout title="Zabudnuté heslo" contentWidth={2}>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/malynar/verifikacia/[[...params]].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {NextPage} from 'next'

import {PageLayout} from '../../../components/PageLayout/PageLayout'
import {PageLayout} from '@/components/PageLayout/PageLayout'

import {Verification} from '../../../components/Verification/Verification'

const Verifikacia: NextPage = () => {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/matik/reset-sent/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {NextPage} from 'next'

import {PageLayout} from '@/components/PageLayout/PageLayout'
import {PasswordResetSent} from '@/components/PasswordResetSent/PasswordResetSent'

import {PageLayout} from '../../../components/PageLayout/PageLayout'

const Verifikacia: NextPage = () => {
return (
<PageLayout title="Zabudnuté heslo" contentWidth={2}>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/matik/verifikacia/[[...params]].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {NextPage} from 'next'

import {PageLayout} from '../../../components/PageLayout/PageLayout'
import {PageLayout} from '@/components/PageLayout/PageLayout'

import {Verification} from '../../../components/Verification/Verification'

const Verifikacia: NextPage = () => {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/strom/archiv/[[...params]].tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {NextPage} from 'next'

import {PageLayout} from '@/components/PageLayout/PageLayout'

import {Archive} from '../../../components/Archive/Archive'
import {PageLayout} from '../../../components/PageLayout/PageLayout'

const Archiv: NextPage = () => {
return (
Expand Down
3 changes: 1 addition & 2 deletions src/pages/strom/reset-sent/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {NextPage} from 'next'

import {PageLayout} from '@/components/PageLayout/PageLayout'
import {PasswordResetSent} from '@/components/PasswordResetSent/PasswordResetSent'

import {PageLayout} from '../../../components/PageLayout/PageLayout'

const Verifikacia: NextPage = () => {
return (
<PageLayout title="Zabudnuté heslo" contentWidth={2}>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/strom/verifikacia/[[...params]].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {NextPage} from 'next'

import {PageLayout} from '../../../components/PageLayout/PageLayout'
import {PageLayout} from '@/components/PageLayout/PageLayout'

import {Verification} from '../../../components/Verification/Verification'

const Verifikacia: NextPage = () => {
Expand Down

0 comments on commit fc3a44c

Please sign in to comment.