From e15081f398e338c4ed4df665f7e3ecc888130481 Mon Sep 17 00:00:00 2001 From: Kostiantyn Dudkin Date: Fri, 26 Jan 2024 15:26:44 +0200 Subject: [PATCH 1/2] [CSAMPLES-3775]: fixed avatar, name in modal settings --- src/components/modals/SettingModal.tsx | 18 ++++++++++------- src/screens/RootScreen/index.tsx | 28 ++++++++++++++++---------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/components/modals/SettingModal.tsx b/src/components/modals/SettingModal.tsx index a788c0a3..fc6252bf 100644 --- a/src/components/modals/SettingModal.tsx +++ b/src/components/modals/SettingModal.tsx @@ -5,7 +5,11 @@ import { type QBUser } from 'quickblox/quickblox' import { AvatarBig, Close, Remove } from '../../assets/img' import Button from '../Button' import Input from '../Field/Input' -import { QBCreateContent, QBUserUpdate } from '../../qb-api-calls' +import { + QBCreateContent, + QBDeleteUserAvatar, + QBUserUpdate, +} from '../../qb-api-calls' interface SettingModalProps { user?: QBUser | null @@ -42,6 +46,7 @@ export default function SettingModal(props: SettingModalProps) { } const handleOnCancelClick = () => { + if (!name || !regex.test(name)) return setSelectedValue('') setAvatarFile(null) setName(user!.full_name) @@ -71,10 +76,10 @@ export default function SettingModal(props: SettingModalProps) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error - if (user?.blob_id && avatarUrl && !avatarFile) { + if (user?.blob_id && !avatarUrl) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error - QBDeleteUserAvatar(user.blob_id).catch(() => null) + await QBDeleteUserAvatar(user.blob_id).catch(() => null) } if (Object.keys(updates).length > 0) { @@ -97,9 +102,7 @@ export default function SettingModal(props: SettingModalProps) { return (
-
+
@@ -155,7 +158,8 @@ export default function SettingModal(props: SettingModalProps) { }} /> - Start with a letter, use only a-z, A-Z, hyphens, underscores, and spaces. Length: 3-50 characters. + Start with a letter, use only a-z, A-Z, hyphens, underscores, + and spaces. Length: 3-50 characters.
diff --git a/src/screens/RootScreen/index.tsx b/src/screens/RootScreen/index.tsx index 44de5cfb..5db484d1 100644 --- a/src/screens/RootScreen/index.tsx +++ b/src/screens/RootScreen/index.tsx @@ -29,7 +29,6 @@ const RootScreen = (props: RootScreenProps) => { } = useModal() const [user, setUser] = useState(null) - // const [userName, setUserName] = useState('') const [avatarUrl, setAvatarUrl] = useState(null) const findUserById = async (userId: QBUser['id']) => { @@ -54,18 +53,19 @@ const RootScreen = (props: RootScreenProps) => { if ((user && !user?.full_name) || (user && !regex.test(user.full_name))) { setSelectedValue('settings') } - // else { - // setUserName(user.full_name) - // } + } + } + const handleUserAvatar = async () => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + if (user?.blob_id) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error - if (user?.blob_id) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error - const userAvatarUrl = await QBGetUserAvatar(user.blob_id) - setAvatarUrl(userAvatarUrl) - } + const userAvatarUrl = await QBGetUserAvatar(user.blob_id) + setAvatarUrl(userAvatarUrl) + } else { + setAvatarUrl('') } } @@ -73,7 +73,13 @@ const RootScreen = (props: RootScreenProps) => { if (session?.user_id) { void handleReceiveUser() } - }, [session?.user_id]) + }, [session.user_id]) + + useEffect(() => { + void handleUserAvatar() + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + }, [user?.blob_id]) if (!user) { return From 4998d355f358272c4bcb7b982622754f91450c01 Mon Sep 17 00:00:00 2001 From: Andrii Khomutovskyi Date: Fri, 26 Jan 2024 17:08:53 +0200 Subject: [PATCH 2/2] Updated packages and README --- README.md | 5 +++++ package-lock.json | 12 ++++++------ package.json | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a4ad9168..9e272906 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,11 @@ REACT_APP_API_BASE_URL= REACT_APP_API_AUTH_PATH= ``` +## Q-Municate Server + +For the application to work correctly, you must use [Q-Municate Server](https://github.com/QuickBlox/q-municate-server). +With its help, user authentication and the operation of all AI features take place. + ## Available Scripts In the project directory, you can run: diff --git a/package-lock.json b/package-lock.json index 5c257ecd..9e737ff3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "q-municate", - "version": "4.0.0-alpha.13", + "version": "4.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "q-municate", - "version": "4.0.0-alpha.13", + "version": "4.0.0", "dependencies": { "@firebase/app": "^0.9.25", "@firebase/auth": "^1.5.1", "classnames": "^2.3.2", "quickblox": "^2.16.1", - "quickblox-react-ui-kit": "0.2.8-beta.19", + "quickblox-react-ui-kit": "0.2.8", "react": "^18.2.0", "react-dom": "^18.2.0", "react-phone-number-input": "^3.3.7", @@ -14533,9 +14533,9 @@ } }, "node_modules/quickblox-react-ui-kit": { - "version": "0.2.8-beta.19", - "resolved": "https://registry.npmjs.org/quickblox-react-ui-kit/-/quickblox-react-ui-kit-0.2.8-beta.19.tgz", - "integrity": "sha512-NkOmep4Nc+b2+M5B6PA4jwPv9dSd6oXjZUjsImgY/NGn6Ci8pTAsn2SypoRdladFtah2rxcJPEtNK2s+M0PY6w==", + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/quickblox-react-ui-kit/-/quickblox-react-ui-kit-0.2.8.tgz", + "integrity": "sha512-HarIVw1RshoSvS8xJSs+SaQDUStDIdRI+PQCOQsSVaHUhfknTd/y2fmpYuaQRXvN98nGgV7i++AHHsbM/m4F6g==", "dependencies": { "@types/node": "^16.18.6", "@types/react": "^18.0.26", diff --git a/package.json b/package.json index fcc4455c..55768ae3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "q-municate", - "version": "4.0.0-alpha.13", + "version": "4.0.0", "private": true, "devDependencies": { "@types/node": "^16.18.28", @@ -24,7 +24,7 @@ "@firebase/auth": "^1.5.1", "classnames": "^2.3.2", "quickblox": "^2.16.1", - "quickblox-react-ui-kit": "0.2.8-beta.19", + "quickblox-react-ui-kit": "0.2.8", "react": "^18.2.0", "react-dom": "^18.2.0", "react-phone-number-input": "^3.3.7",