feat: fix filter scroll, add translate for auth modals
This commit is contained in:
parent
b6d11a5b30
commit
ffbbeadb40
|
@ -5,7 +5,7 @@ import { useSearchParams } from 'next/navigation';
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
import { useRouter } from '../../navigation';
|
import { useRouter } from '../../navigation';
|
||||||
import { AdditionalFilter } from '../../types/experts';
|
import { AdditionalFilter } from '../../types/experts';
|
||||||
import { getObjectByFilter, getObjectByAdditionalFilter } from '../../utils/filter';
|
import { getObjectByFilter, getObjectByAdditionalFilter, getSearchParamsString } from '../../utils/filter';
|
||||||
import { CustomInput } from '../view/CustomInput';
|
import { CustomInput } from '../view/CustomInput';
|
||||||
import { CustomSelect } from '../view/CustomSelect';
|
import { CustomSelect } from '../view/CustomSelect';
|
||||||
import { i18nText } from '../../i18nKeys';
|
import { i18nText } from '../../i18nKeys';
|
||||||
|
@ -22,6 +22,7 @@ export const ExpertsAdditionalFilter = ({
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [filter, setFilter] = useState<AdditionalFilter | undefined>(getObjectByAdditionalFilter(searchParams));
|
const [filter, setFilter] = useState<AdditionalFilter | undefined>(getObjectByAdditionalFilter(searchParams));
|
||||||
|
const [isMounted, setIsMounted] = useState<boolean>(false);
|
||||||
|
|
||||||
const onChangeInput = useCallback(debounce((e: any) => {
|
const onChangeInput = useCallback(debounce((e: any) => {
|
||||||
const newFilter: AdditionalFilter = { ...filter };
|
const newFilter: AdditionalFilter = { ...filter };
|
||||||
|
@ -48,17 +49,35 @@ export const ExpertsAdditionalFilter = ({
|
||||||
}, [filter]);
|
}, [filter]);
|
||||||
|
|
||||||
const updateRoute = debounce(() => {
|
const updateRoute = debounce(() => {
|
||||||
router.push({
|
const newFilter = {
|
||||||
pathname: basePath as any,
|
|
||||||
query: {
|
|
||||||
...getObjectByFilter(searchParams),
|
...getObjectByFilter(searchParams),
|
||||||
...filter
|
...filter
|
||||||
}
|
};
|
||||||
})
|
const search = getSearchParamsString(newFilter);
|
||||||
|
|
||||||
|
console.log('here1');
|
||||||
|
|
||||||
|
router.push(search ? `${basePath}?${search}#filter` : `${basePath}#filter`);
|
||||||
|
|
||||||
|
// router.push({
|
||||||
|
// pathname: basePath as any,
|
||||||
|
// query: {
|
||||||
|
// ...getObjectByFilter(searchParams),
|
||||||
|
// ...filter
|
||||||
|
// }
|
||||||
|
// })
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!isMounted) {
|
||||||
|
setIsMounted(true);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isMounted) {
|
||||||
updateRoute();
|
updateRoute();
|
||||||
|
}
|
||||||
}, [filter]);
|
}, [filter]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { useSearchParams } from 'next/navigation';
|
||||||
import { useRouter } from '../../navigation';
|
import { useRouter } from '../../navigation';
|
||||||
import { Filter } from '../../types/experts';
|
import { Filter } from '../../types/experts';
|
||||||
import { Languages, SearchData, Tag } from '../../types/tags';
|
import { Languages, SearchData, Tag } from '../../types/tags';
|
||||||
import { getObjectByFilter, getObjectByAdditionalFilter } from '../../utils/filter';
|
import { getObjectByFilter, getObjectByAdditionalFilter, getSearchParamsString } from '../../utils/filter';
|
||||||
import { CustomSwitch } from '../view/CustomSwitch';
|
import { CustomSwitch } from '../view/CustomSwitch';
|
||||||
import { CustomSlider } from '../view/CustomSlider';
|
import { CustomSlider } from '../view/CustomSlider';
|
||||||
import { CustomInput } from '../view/CustomInput';
|
import { CustomInput } from '../view/CustomInput';
|
||||||
|
@ -109,21 +109,21 @@ export const ExpertsFilter = ({
|
||||||
}, [filter, searchParams, searchData]);
|
}, [filter, searchParams, searchData]);
|
||||||
|
|
||||||
const goToFilterPage = useCallback(() => {
|
const goToFilterPage = useCallback(() => {
|
||||||
// const newFilter: GeneralFilter = {
|
const newFilter = {
|
||||||
// ...filter,
|
|
||||||
// ...getObjectByAdditionalFilter(searchParams)
|
|
||||||
// };
|
|
||||||
// const search = getSearchParamsString(newFilter);
|
|
||||||
//
|
|
||||||
// router.push(search ? `${pathname}?${search}` : pathname, { scroll: false });
|
|
||||||
|
|
||||||
router.push({
|
|
||||||
pathname: basePath as any,
|
|
||||||
query: {
|
|
||||||
...filter,
|
...filter,
|
||||||
...getObjectByAdditionalFilter(searchParams)
|
...getObjectByAdditionalFilter(searchParams)
|
||||||
}
|
};
|
||||||
})
|
const search = getSearchParamsString(newFilter);
|
||||||
|
|
||||||
|
router.push(search ? `${basePath}?${search}#filter` : `${basePath}#filter`);
|
||||||
|
|
||||||
|
// router.push({
|
||||||
|
// pathname: basePath as any,
|
||||||
|
// query: {
|
||||||
|
// ...filter,
|
||||||
|
// ...getObjectByAdditionalFilter(searchParams)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
}, [filter, searchParams, searchData]);
|
}, [filter, searchParams, searchData]);
|
||||||
|
|
||||||
const getSelectedLanguage = useCallback((): string => {
|
const getSelectedLanguage = useCallback((): string => {
|
||||||
|
|
|
@ -95,10 +95,10 @@ export const AuthModal: FC<AuthModalProps> = ({
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{mode === 'reset' && (
|
{mode === 'reset' && (
|
||||||
<ResetContent form={form} updateMode={updateMode} />
|
<ResetContent form={form} updateMode={updateMode} locale={paths[1]} />
|
||||||
)}
|
)}
|
||||||
{mode === 'finish' && (
|
{mode === 'finish' && (
|
||||||
<FinishContent />
|
<FinishContent locale={paths[1]} />
|
||||||
)}
|
)}
|
||||||
<div className="b-modal__auth__agreement">
|
<div className="b-modal__auth__agreement">
|
||||||
I have read and agree with the terms of the
|
I have read and agree with the terms of the
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { CustomInputPassword } from '../../view/CustomInputPassword';
|
||||||
import { FilledButton } from '../../view/FilledButton';
|
import { FilledButton } from '../../view/FilledButton';
|
||||||
import { OutlinedButton } from '../../view/OutlinedButton';
|
import { OutlinedButton } from '../../view/OutlinedButton';
|
||||||
import { LinkButton } from '../../view/LinkButton';
|
import { LinkButton } from '../../view/LinkButton';
|
||||||
|
import { i18nText } from '../../../i18nKeys';
|
||||||
|
|
||||||
type EnterProps = {
|
type EnterProps = {
|
||||||
form: FormInstance;
|
form: FormInstance;
|
||||||
|
@ -133,7 +134,7 @@ export const EnterContent: FC<EnterProps> = ({
|
||||||
>
|
>
|
||||||
<CustomInputPassword
|
<CustomInputPassword
|
||||||
size="small"
|
size="small"
|
||||||
placeholder="Password"
|
placeholder={i18nText('password', locale)}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
onPressEnter={onLogin}
|
onPressEnter={onLogin}
|
||||||
/>
|
/>
|
||||||
|
@ -144,9 +145,9 @@ export const EnterContent: FC<EnterProps> = ({
|
||||||
onClick={onLogin}
|
onClick={onLogin}
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
Enter
|
{i18nText('enter', locale)}
|
||||||
</FilledButton>
|
</FilledButton>
|
||||||
<OutlinedButton onClick={() => updateMode('register')}>Register</OutlinedButton>
|
<OutlinedButton onClick={() => updateMode('register')}>{i18nText('registration', locale)}</OutlinedButton>
|
||||||
<LinkButton
|
<LinkButton
|
||||||
type="link"
|
type="link"
|
||||||
onClick={() => updateMode('reset')}
|
onClick={() => updateMode('reset')}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FilledButton } from '../../view/FilledButton';
|
import { FilledButton } from '../../view/FilledButton';
|
||||||
|
import { i18nText } from '../../../i18nKeys';
|
||||||
|
|
||||||
export const FinishContent = () => (
|
export const FinishContent = ({ locale }: { locale: string }) => (
|
||||||
<>
|
<>
|
||||||
<div className="b-modal__auth__agreement">
|
<div className="b-modal__auth__agreement">
|
||||||
A link to reset your password has been sent
|
A link to reset your password has been sent
|
||||||
|
@ -11,7 +12,7 @@ export const FinishContent = () => (
|
||||||
<FilledButton
|
<FilledButton
|
||||||
type="primary"
|
type="primary"
|
||||||
>
|
>
|
||||||
Enter Account
|
{i18nText('enter', locale)}
|
||||||
</FilledButton>
|
</FilledButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { CustomInput } from '../../view/CustomInput';
|
||||||
import { CustomInputPassword } from '../../view/CustomInputPassword';
|
import { CustomInputPassword } from '../../view/CustomInputPassword';
|
||||||
import { FilledButton } from '../../view/FilledButton';
|
import { FilledButton } from '../../view/FilledButton';
|
||||||
import { OutlinedButton } from '../../view/OutlinedButton';
|
import { OutlinedButton } from '../../view/OutlinedButton';
|
||||||
|
import { i18nText } from '../../../i18nKeys';
|
||||||
|
|
||||||
type RegisterProps = {
|
type RegisterProps = {
|
||||||
form: FormInstance;
|
form: FormInstance;
|
||||||
|
@ -138,7 +139,7 @@ export const RegisterContent: FC<RegisterProps> = ({
|
||||||
>
|
>
|
||||||
<CustomInputPassword
|
<CustomInputPassword
|
||||||
size="small"
|
size="small"
|
||||||
placeholder="Password"
|
placeholder={i18nText('password', locale)}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
|
@ -163,7 +164,7 @@ export const RegisterContent: FC<RegisterProps> = ({
|
||||||
>
|
>
|
||||||
<CustomInputPassword
|
<CustomInputPassword
|
||||||
size="small"
|
size="small"
|
||||||
placeholder="Confirm password"
|
placeholder={i18nText('confirmPass', locale)}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -172,9 +173,9 @@ export const RegisterContent: FC<RegisterProps> = ({
|
||||||
onClick={onRegister}
|
onClick={onRegister}
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
Register
|
{i18nText('registration', locale)}
|
||||||
</FilledButton>
|
</FilledButton>
|
||||||
<OutlinedButton onClick={() => updateMode('enter')}>Enter</OutlinedButton>
|
<OutlinedButton onClick={() => updateMode('enter')}>{i18nText('enter', locale)}</OutlinedButton>
|
||||||
<span>or</span>
|
<span>or</span>
|
||||||
<OutlinedButton
|
<OutlinedButton
|
||||||
icon={<Image src="/images/facebook-logo.png" height={20} width={20} alt="" />}
|
icon={<Image src="/images/facebook-logo.png" height={20} width={20} alt="" />}
|
||||||
|
|
|
@ -3,15 +3,18 @@ import { Form, FormInstance } from 'antd';
|
||||||
import { CustomInput } from '../../view/CustomInput';
|
import { CustomInput } from '../../view/CustomInput';
|
||||||
import { FilledButton } from '../../view/FilledButton';
|
import { FilledButton } from '../../view/FilledButton';
|
||||||
import { LinkButton } from '../../view/LinkButton';
|
import { LinkButton } from '../../view/LinkButton';
|
||||||
|
import { i18nText } from '../../../i18nKeys';
|
||||||
|
|
||||||
type ResetProps = {
|
type ResetProps = {
|
||||||
form: FormInstance;
|
form: FormInstance;
|
||||||
updateMode: (mode: 'enter' | 'register' | 'reset' | 'finish') => void;
|
updateMode: (mode: 'enter' | 'register' | 'reset' | 'finish') => void;
|
||||||
|
locale: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ResetContent: FC<ResetProps> = ({
|
export const ResetContent: FC<ResetProps> = ({
|
||||||
form,
|
form,
|
||||||
updateMode
|
updateMode,
|
||||||
|
locale
|
||||||
}) => {
|
}) => {
|
||||||
const onResetPassword = () => {
|
const onResetPassword = () => {
|
||||||
console.log('reset');
|
console.log('reset');
|
||||||
|
@ -51,7 +54,7 @@ export const ResetContent: FC<ResetProps> = ({
|
||||||
type="link"
|
type="link"
|
||||||
onClick={() => updateMode('enter')}
|
onClick={() => updateMode('enter')}
|
||||||
>
|
>
|
||||||
Enter
|
{i18nText('enter', locale)}
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -32,6 +32,7 @@ export default {
|
||||||
topic: 'Thema',
|
topic: 'Thema',
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
surname: 'Nachname',
|
surname: 'Nachname',
|
||||||
|
password: 'Passwort',
|
||||||
birthday: 'Geburtsdatum',
|
birthday: 'Geburtsdatum',
|
||||||
oldPass: 'Altes Passwort',
|
oldPass: 'Altes Passwort',
|
||||||
newPass: 'Neues Passwort',
|
newPass: 'Neues Passwort',
|
||||||
|
|
|
@ -32,6 +32,7 @@ export default {
|
||||||
topic: 'Topic',
|
topic: 'Topic',
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
surname: 'Surname',
|
surname: 'Surname',
|
||||||
|
password: 'Password',
|
||||||
birthday: 'Date of Birth',
|
birthday: 'Date of Birth',
|
||||||
oldPass: 'Old Password',
|
oldPass: 'Old Password',
|
||||||
newPass: 'New Password',
|
newPass: 'New Password',
|
||||||
|
|
|
@ -32,6 +32,7 @@ export default {
|
||||||
topic: 'Tema',
|
topic: 'Tema',
|
||||||
name: 'Nombre',
|
name: 'Nombre',
|
||||||
surname: 'Apellido',
|
surname: 'Apellido',
|
||||||
|
password: 'Contraseña',
|
||||||
birthday: 'Fecha de nacimiento',
|
birthday: 'Fecha de nacimiento',
|
||||||
oldPass: 'Contraseña antigua',
|
oldPass: 'Contraseña antigua',
|
||||||
newPass: 'Nueva contraseña',
|
newPass: 'Nueva contraseña',
|
||||||
|
|
|
@ -32,6 +32,7 @@ export default {
|
||||||
topic: 'Sujet',
|
topic: 'Sujet',
|
||||||
name: 'Prénom',
|
name: 'Prénom',
|
||||||
surname: 'Nom de famille',
|
surname: 'Nom de famille',
|
||||||
|
password: 'Passe',
|
||||||
birthday: 'Date de naissance',
|
birthday: 'Date de naissance',
|
||||||
oldPass: 'Ancien mot de passe',
|
oldPass: 'Ancien mot de passe',
|
||||||
newPass: 'Nouveau mot de passe',
|
newPass: 'Nouveau mot de passe',
|
||||||
|
|
|
@ -32,6 +32,7 @@ export default {
|
||||||
topic: 'Argomento',
|
topic: 'Argomento',
|
||||||
name: 'Nome',
|
name: 'Nome',
|
||||||
surname: 'Cognome',
|
surname: 'Cognome',
|
||||||
|
password: 'Password',
|
||||||
birthday: 'Data di nascita',
|
birthday: 'Data di nascita',
|
||||||
oldPass: 'Vecchia password',
|
oldPass: 'Vecchia password',
|
||||||
newPass: 'Nuova password',
|
newPass: 'Nuova password',
|
||||||
|
|
|
@ -32,6 +32,7 @@ export default {
|
||||||
topic: 'Тема',
|
topic: 'Тема',
|
||||||
name: 'Имя',
|
name: 'Имя',
|
||||||
surname: 'Фамилия',
|
surname: 'Фамилия',
|
||||||
|
password: 'Пароль',
|
||||||
birthday: 'Дата рождения',
|
birthday: 'Дата рождения',
|
||||||
oldPass: 'Старый пароль',
|
oldPass: 'Старый пароль',
|
||||||
newPass: 'Новый пароль',
|
newPass: 'Новый пароль',
|
||||||
|
|
Loading…
Reference in New Issue