From 5e1d4a38ff90e96019a860095b84621d766cee69 Mon Sep 17 00:00:00 2001 From: tigran Date: Tue, 24 Dec 2024 16:57:00 +0400 Subject: [PATCH] added user profile and logout --- package-lock.json | 10 ++++++ package.json | 1 + src/components/Comment/style.ts | 1 + src/components/Editor/index.tsx | 54 ++++++++++++++++------------ src/components/UserProfile/index.tsx | 32 +++++++++++++++++ src/components/UserProfile/style.ts | 21 +++++++++++ src/providers/Requests/index.tsx | 16 ++++----- src/utils/getToken.ts | 9 +++++ 8 files changed, 114 insertions(+), 30 deletions(-) create mode 100644 src/components/UserProfile/index.tsx create mode 100644 src/components/UserProfile/style.ts create mode 100644 src/utils/getToken.ts diff --git a/package-lock.json b/package-lock.json index 9238635..0a8831b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "clientjs": "^0.2.1", "dayjs": "^1.11.9", "i18next": "^19.8.3", + "jwt-decode": "^4.0.0", "lscache": "^1.3.0", "react": ">= 16.8.0", "react-dom": "^17.0.1", @@ -3598,6 +3599,15 @@ "node": ">=6" } }, + "node_modules/jwt-decode": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", + "integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/lightningcss": { "version": "1.24.0", "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.24.0.tgz", diff --git a/package.json b/package.json index 9a19f33..0390390 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "clientjs": "^0.2.1", "dayjs": "^1.11.9", "i18next": "^19.8.3", + "jwt-decode": "^4.0.0", "lscache": "^1.3.0", "react": ">= 16.8.0", "react-dom": "^17.0.1", diff --git a/src/components/Comment/style.ts b/src/components/Comment/style.ts index 7ab44c0..4d23a2d 100644 --- a/src/components/Comment/style.ts +++ b/src/components/Comment/style.ts @@ -56,6 +56,7 @@ export const Body = styled.div` font-size: 14px; font-weight: 400; line-height: 1.5; + word-wrap: anywhere; letter-spacing: 0.3px; white-space: break-spaces; color: ${props => props.theme.textColor}; diff --git a/src/components/Editor/index.tsx b/src/components/Editor/index.tsx index ec16e6a..b98e282 100644 --- a/src/components/Editor/index.tsx +++ b/src/components/Editor/index.tsx @@ -2,7 +2,9 @@ import React, { useState, useLayoutEffect, useEffect, useRef } from 'react'; import lscache from 'lscache'; import { useCommentsDispatch, IComment } from 'providers/Comments'; import { Container, Textarea, Button, Footer, Input, Form } from './style'; +import UserProfile from 'components/UserProfile'; import { useTranslation } from 'react-i18next'; +import { getToken } from 'utils/getToken'; type Props = { replyTo?: IComment; @@ -13,6 +15,7 @@ export default function Editor(props: Props) { const [loading, setLoading] = useState(false); const [name, setName] = useState(lscache.get('name') || ''); const [email, setEmail] = useState(lscache.get('email') || ''); + const token = getToken(); const form: React.RefObject = useRef(null); const submit: React.RefObject = useRef(null); @@ -75,28 +78,35 @@ export default function Editor(props: Props) { required />