From bdd382042c59951fbd20b13349214110743f90d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=8E=D1=82=D0=BA=D0=B8=D0=BD=D0=B0=20=D0=94=D0=B0?= =?UTF-8?q?=D1=80=D1=8C=D1=8F=20=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D1=80=D0=BE=D0=B2=D0=BD=D0=B0=20=284047910=29?= Date: Thu, 8 Feb 2024 02:28:24 +0400 Subject: [PATCH] feat: add normal auth --- messages/en.json | 1 - src/actions/auth.ts | 16 +- src/actions/profile.ts | 15 ++ .../{ => (account)}/information/page.tsx | 2 +- src/app/[locale]/account/(account)/layout.tsx | 61 +++++ .../messages/[textId]/page.tsx | 14 +- .../account/{ => (account)}/messages/page.tsx | 16 +- .../{ => (account)}/notifications/page.tsx | 3 - .../account/(account)/sessions/page.tsx | 27 +++ .../settings/change-password/page.tsx | 2 +- .../account/{ => (account)}/settings/page.tsx | 15 +- .../account/{ => (account)}/support/page.tsx | 2 +- .../work-with-us/coaching/add-offer/page.tsx | 94 ++++++++ .../(account)/work-with-us/coaching/page.tsx | 131 +++++++++++ .../(account)/work-with-us/new-topic/page.tsx | 55 +++++ .../{ => (account)}/work-with-us/page.tsx | 2 +- src/app/[locale]/account/layout.tsx | 78 ++----- src/app/[locale]/account/page.tsx | 18 +- src/app/[locale]/account/sessions/page.tsx | 25 --- src/components/Account/AccountMenu.tsx | 34 ++- src/components/Account/SessionsTabs.tsx | 63 ++++-- src/components/Experts/ExpertsList.tsx | 2 +- src/components/Experts/Filter.tsx | 17 +- src/components/Modals/AuthModal.tsx | 209 +++--------------- .../Modals/authModalContent/EnterContent.tsx | 116 ++++++++++ .../Modals/authModalContent/FinishContent.tsx | 17 ++ .../authModalContent/RegisterContent.tsx | 128 +++++++++++ .../Modals/authModalContent/ResetContent.tsx | 56 +++++ .../Modals/authModalContent/index.tsx | 4 + .../Page/Header/HeaderAuthLinks.tsx | 11 +- src/components/view/CustomInputPassword.tsx | 8 +- src/components/view/FilledButton.tsx | 17 ++ src/components/view/LinkButton.tsx | 16 ++ src/components/view/OutlinedButton.tsx | 26 +++ src/components/view/index.ts | 3 + src/hooks/useLocalStorage.ts | 26 +++ src/styles/_default.scss | 7 +- src/styles/_form.scss | 1 + src/styles/_header.scss | 5 +- src/styles/_pages.scss | 38 ++-- src/utils/filter.ts | 20 +- src/utils/storage/auth.ts | 23 -- 42 files changed, 1037 insertions(+), 387 deletions(-) create mode 100644 src/actions/profile.ts rename src/app/[locale]/account/{ => (account)}/information/page.tsx (98%) create mode 100644 src/app/[locale]/account/(account)/layout.tsx rename src/app/[locale]/account/{ => (account)}/messages/[textId]/page.tsx (85%) rename src/app/[locale]/account/{ => (account)}/messages/page.tsx (89%) rename src/app/[locale]/account/{ => (account)}/notifications/page.tsx (90%) create mode 100644 src/app/[locale]/account/(account)/sessions/page.tsx rename src/app/[locale]/account/{ => (account)}/settings/change-password/page.tsx (96%) rename src/app/[locale]/account/{ => (account)}/settings/page.tsx (71%) rename src/app/[locale]/account/{ => (account)}/support/page.tsx (92%) create mode 100644 src/app/[locale]/account/(account)/work-with-us/coaching/add-offer/page.tsx create mode 100644 src/app/[locale]/account/(account)/work-with-us/coaching/page.tsx create mode 100644 src/app/[locale]/account/(account)/work-with-us/new-topic/page.tsx rename src/app/[locale]/account/{ => (account)}/work-with-us/page.tsx (95%) delete mode 100644 src/app/[locale]/account/sessions/page.tsx create mode 100644 src/components/Modals/authModalContent/EnterContent.tsx create mode 100644 src/components/Modals/authModalContent/FinishContent.tsx create mode 100644 src/components/Modals/authModalContent/RegisterContent.tsx create mode 100644 src/components/Modals/authModalContent/ResetContent.tsx create mode 100644 src/components/Modals/authModalContent/index.tsx create mode 100644 src/components/view/FilledButton.tsx create mode 100644 src/components/view/LinkButton.tsx create mode 100644 src/components/view/OutlinedButton.tsx create mode 100644 src/hooks/useLocalStorage.ts delete mode 100644 src/utils/storage/auth.ts diff --git a/messages/en.json b/messages/en.json index 5ca66b1..58aafc1 100644 --- a/messages/en.json +++ b/messages/en.json @@ -68,7 +68,6 @@ }, "Notifications": { "title": "Notifications", - "read": "Read", "delete": "Delete" }, "Sessions": { diff --git a/src/actions/auth.ts b/src/actions/auth.ts index 19cb9ac..2da04c6 100644 --- a/src/actions/auth.ts +++ b/src/actions/auth.ts @@ -1,10 +1,22 @@ import { AxiosResponse } from 'axios'; import { apiClient } from '../lib/apiClient'; -export const getAuth = (login: string, password: string, locale: string ): Promise> => ( +export const getAuth = (locale: string, data: { login: string, password: string }): Promise> => ( apiClient.post( '/auth/login', - { login, password }, + data, + { + headers: { + 'X-User-Language': locale + } + } + ) +); + +export const getRegister = (locale: string): Promise> => ( + apiClient.post( + '/auth/register', + {}, { headers: { 'X-User-Language': locale diff --git a/src/actions/profile.ts b/src/actions/profile.ts new file mode 100644 index 0000000..8fcde21 --- /dev/null +++ b/src/actions/profile.ts @@ -0,0 +1,15 @@ +import { AxiosResponse } from 'axios'; +import { apiClient } from '../lib/apiClient'; + +export const setPersonData = (person: { login: string, password: string, role: string }, locale: string, jwt: string): Promise => ( + apiClient.post( + '/home/applyperson1', + { ...person }, + { + headers: { + 'X-User-Language': locale, + Authorization: `Bearer ${jwt}` + } + } + ) +); diff --git a/src/app/[locale]/account/information/page.tsx b/src/app/[locale]/account/(account)/information/page.tsx similarity index 98% rename from src/app/[locale]/account/information/page.tsx rename to src/app/[locale]/account/(account)/information/page.tsx index d21f33e..95d8933 100644 --- a/src/app/[locale]/account/information/page.tsx +++ b/src/app/[locale]/account/(account)/information/page.tsx @@ -34,7 +34,7 @@ export default function Information() { mentors and/or consultants of our application and/or website as well as other users of our services and suppliers. -

What Personal Date We Collect About You?

+

What Personal Data We Collect About You?

We may collect, use, store and transfer different kinds of personal data about you which we have grouped together as follows:
diff --git a/src/app/[locale]/account/(account)/layout.tsx b/src/app/[locale]/account/(account)/layout.tsx new file mode 100644 index 0000000..2c2d53d --- /dev/null +++ b/src/app/[locale]/account/(account)/layout.tsx @@ -0,0 +1,61 @@ +import React, { ReactNode } from 'react'; +import { Metadata } from 'next'; +import { useTranslations } from 'next-intl'; +import { AccountMenu } from '../../../../components/Account'; + +type AccountInnerLayoutProps = { + children: ReactNode; + params: Record; +}; + +export const metadata: Metadata = { + title: 'Bbuddy User Account' +}; + +export function generateStaticParams({ + params: { locale }, +}: { params: { locale: string } }) { + const result: { locale: string, userId: string }[] = []; + const users = [{ userId: '1' }, { userId: '2' }]; + + users.forEach(({ userId }) => { + result.push({ locale, userId }); + }); + + return result; +} + +const ROUTES = ['sessions', 'notifications', 'support', 'information', 'settings', 'messages', 'work-with-us']; +const COUNTS: Record = { + sessions: 12, + notifications: 5, + messages: 113 +}; + + +export default function AccountInnerLayout({ children }: AccountInnerLayoutProps) { + const t = useTranslations('Account'); + + const getMenuConfig = () => ROUTES.map((path) => ({ + path, + title: t(`menu.${path}`), + count: COUNTS[path] || undefined + })); + + return ( +
+
+
+
+ +
+
+
+ {children} +
+
+
+
+
+ ); +}; diff --git a/src/app/[locale]/account/messages/[textId]/page.tsx b/src/app/[locale]/account/(account)/messages/[textId]/page.tsx similarity index 85% rename from src/app/[locale]/account/messages/[textId]/page.tsx rename to src/app/[locale]/account/(account)/messages/[textId]/page.tsx index 3eee46f..f79a221 100644 --- a/src/app/[locale]/account/messages/[textId]/page.tsx +++ b/src/app/[locale]/account/(account)/messages/[textId]/page.tsx @@ -1,28 +1,28 @@ import React from 'react'; import { useTranslations } from 'next-intl'; -import { Link } from '../../../../../navigation'; +import { Link } from '../../../../../../navigation'; export function generateStaticParams({ - params: { locale, userId }, -}: { params: { locale: string, userId: string } }) { - const result: { locale: string, userId: string, textId: string }[] = []; + params: { locale }, +}: { params: { locale: string } }) { + const result: { locale: string, textId: string }[] = []; const chats = [{ textId: '1' }, { textId: '2' }, { textId: '3' }]; chats.forEach(({ textId }) => { - result.push({ locale, userId, textId }); + result.push({ locale, textId }); }); return result; } -export default function Message({ params }: { params: { userId: string, textId: string } }) { +export default function Message({ params }: { params: { textId: string } }) { const t = useTranslations('Account.Messages'); return ( <>
  1. - + {t('title')}
  2. diff --git a/src/app/[locale]/account/messages/page.tsx b/src/app/[locale]/account/(account)/messages/page.tsx similarity index 89% rename from src/app/[locale]/account/messages/page.tsx rename to src/app/[locale]/account/(account)/messages/page.tsx index 2222edb..98d8fa7 100644 --- a/src/app/[locale]/account/messages/page.tsx +++ b/src/app/[locale]/account/(account)/messages/page.tsx @@ -1,14 +1,15 @@ -import React from 'react'; +import React, { Suspense } from 'react'; import type { Metadata } from 'next'; import { useTranslations } from 'next-intl'; -import { Link } from '../../../../navigation'; +import { Link } from '../../../../../navigation'; +import { CustomInput } from '../../../../../components/view'; export const metadata: Metadata = { title: 'Bbuddy - Account - Messages', description: 'Bbuddy desc messages' }; -export default function Messages({ params }: { params: { userId: string } }) { +export default function Messages() { const t = useTranslations('Account.Messages'); return ( @@ -16,10 +17,13 @@ export default function Messages({ params }: { params: { userId: string } }) {
    1. {t('title')}
    + + +
    @@ -41,7 +45,7 @@ export default function Messages({ params }: { params: { userId: string } }) {
    @@ -60,7 +64,7 @@ export default function Messages({ params }: { params: { userId: string } }) {
    diff --git a/src/app/[locale]/account/notifications/page.tsx b/src/app/[locale]/account/(account)/notifications/page.tsx similarity index 90% rename from src/app/[locale]/account/notifications/page.tsx rename to src/app/[locale]/account/(account)/notifications/page.tsx index 006a9d8..3491dda 100644 --- a/src/app/[locale]/account/notifications/page.tsx +++ b/src/app/[locale]/account/(account)/notifications/page.tsx @@ -23,7 +23,6 @@ export default function Notifications() {
    25 may 2022
    @@ -34,7 +33,6 @@ export default function Notifications() {
    25 may 2022
    @@ -45,7 +43,6 @@ export default function Notifications() {
    25 may 2022
    diff --git a/src/app/[locale]/account/(account)/sessions/page.tsx b/src/app/[locale]/account/(account)/sessions/page.tsx new file mode 100644 index 0000000..7fc4acf --- /dev/null +++ b/src/app/[locale]/account/(account)/sessions/page.tsx @@ -0,0 +1,27 @@ +import React, { Suspense } from 'react'; +import type { Metadata } from 'next'; +import { useTranslations } from 'next-intl'; +import { SessionsTabs } from '../../../../../components/Account'; + +export const metadata: Metadata = { + title: 'Bbuddy - Account - Sessions', + description: 'Bbuddy desc sessions' +}; + +export default function Sessions() { + const t = useTranslations('Account.Sessions'); + + return ( + Loading...

    }> + +
    + ); +} diff --git a/src/app/[locale]/account/settings/change-password/page.tsx b/src/app/[locale]/account/(account)/settings/change-password/page.tsx similarity index 96% rename from src/app/[locale]/account/settings/change-password/page.tsx rename to src/app/[locale]/account/(account)/settings/change-password/page.tsx index e9c72a3..d794487 100644 --- a/src/app/[locale]/account/settings/change-password/page.tsx +++ b/src/app/[locale]/account/(account)/settings/change-password/page.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { useTranslations } from 'next-intl'; -import { Link } from '../../../../../navigation'; +import { Link } from '../../../../../../navigation'; export default function ChangePassword({ params }: { params: { userId: string } }) { const t = useTranslations('Account.Settings'); diff --git a/src/app/[locale]/account/settings/page.tsx b/src/app/[locale]/account/(account)/settings/page.tsx similarity index 71% rename from src/app/[locale]/account/settings/page.tsx rename to src/app/[locale]/account/(account)/settings/page.tsx index 8f0c246..357ea03 100644 --- a/src/app/[locale]/account/settings/page.tsx +++ b/src/app/[locale]/account/(account)/settings/page.tsx @@ -1,7 +1,8 @@ -import React from 'react'; +import React, {Suspense} from 'react'; import type { Metadata } from 'next'; import { useTranslations } from 'next-intl'; -import {Link} from "../../../../navigation"; +import { Link } from '../../../../../navigation'; +import { CustomInput } from '../../../../../components/view'; export const metadata: Metadata = { title: 'Bbuddy - Account - Profile Settings', @@ -25,19 +26,19 @@ export default function Settings({ params }: { params: { userId: string } }) {
    {t('photo-desc')}
    - +
    - +
    - +
    - +
    - + {t('change-password')}
    diff --git a/src/app/[locale]/account/support/page.tsx b/src/app/[locale]/account/(account)/support/page.tsx similarity index 92% rename from src/app/[locale]/account/support/page.tsx rename to src/app/[locale]/account/(account)/support/page.tsx index 36ab43a..8ed974b 100644 --- a/src/app/[locale]/account/support/page.tsx +++ b/src/app/[locale]/account/(account)/support/page.tsx @@ -1,6 +1,6 @@ import React from 'react'; import type { Metadata } from 'next'; -import {useTranslations} from "next-intl"; +import { useTranslations } from 'next-intl'; export const metadata: Metadata = { title: 'Bbuddy - Account - Help & Support', diff --git a/src/app/[locale]/account/(account)/work-with-us/coaching/add-offer/page.tsx b/src/app/[locale]/account/(account)/work-with-us/coaching/add-offer/page.tsx new file mode 100644 index 0000000..f321464 --- /dev/null +++ b/src/app/[locale]/account/(account)/work-with-us/coaching/add-offer/page.tsx @@ -0,0 +1,94 @@ +import React from 'react'; +import { Link } from '../../../../../../../navigation'; +import { CustomSelect } from '../../../../../../../components/view'; + +export default function AddOffer() { + return ( + <> +
      +
    1. + + Work With Us + +
    2. +
    3. + + Coaching + +
    4. +
    5. Add Offer
    6. +
    + +

    Select Topic

    +
    +
    + +
    +

    Life coaching

    +
    +
    +
    +
    Work-life Balance
    + +
    +
    +
    Strategic Session
    + +
    +
    +
    Personal Growth +
    + +
    +
    +
    Executive Coaching
    + +
    +
    +
    Career Planning
    + +
    +
    +
    +

    Business coaching

    +

    Offer Details

    +
    + +
    +
    + +
    +
    +