diff --git a/backend/src/graphql.ts b/backend/src/graphql.ts index 7f86dff..be1ceff 100644 --- a/backend/src/graphql.ts +++ b/backend/src/graphql.ts @@ -56,7 +56,7 @@ export interface IMutation { sendMessage(input?: SendMessageInput): Message | Promise; updatePassword(input?: UpdatePasswordInput): string | Promise; updateUser(input?: UpdateInput, file?: Upload): string | Promise; - signUp(input?: SignUpInput, file?: Upload): string | Promise; + signUp(input?: SignUpInput): string | Promise; signIn(input?: SignInInput): string | Promise; } diff --git a/backend/src/user/user.graphql b/backend/src/user/user.graphql index 18eba45..24366e7 100644 --- a/backend/src/user/user.graphql +++ b/backend/src/user/user.graphql @@ -20,7 +20,7 @@ type Query { type Mutation { updatePassword(input: UpdatePasswordInput): String updateUser(input: UpdateInput, file: Upload): String - signUp(input: SignUpInput, file: Upload): String + signUp(input: SignUpInput): String signIn(input: SignInInput): String } diff --git a/backend/src/user/user.resolver.ts b/backend/src/user/user.resolver.ts index aa0313d..7b73611 100644 --- a/backend/src/user/user.resolver.ts +++ b/backend/src/user/user.resolver.ts @@ -27,8 +27,8 @@ export class UserResolver { @Query() @UseGuards(new AuthGuard()) - searchUser(@Args('name') name: string) { - return this.userService.findByName(name); + searchUser(@Args('name') name: string, @CurrentUser() user: UserEntity) { + return this.userService.findByName(name, user.id); } @Mutation() @@ -37,15 +37,8 @@ export class UserResolver { } @Mutation() - async signUp( - @Args('input') signUpInput: SignUpInput, - @Args('file') file: { file: FileUpload }, - ) { - const _file = await file; - const user = await this.userService.createUser( - { ...signUpInput }, - _file.file, - ); + async signUp(@Args('input') signUpInput: SignUpInput) { + const user = await this.userService.createUser({ ...signUpInput }); pubsub.publish('userRegistred', { userRegistred: user }); return this.userService.createToken(user); } diff --git a/backend/src/user/user.service.ts b/backend/src/user/user.service.ts index 08df4e9..cad9ac0 100644 --- a/backend/src/user/user.service.ts +++ b/backend/src/user/user.service.ts @@ -5,7 +5,7 @@ import { } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { UserEntity } from './user.entity'; -import { ILike, Repository } from 'typeorm'; +import { Repository } from 'typeorm'; import * as jwt from 'jsonwebtoken'; import * as bcrypt from 'bcryptjs'; import { SignInInput, SignUpInput } from './dto/auth.inputs'; @@ -34,28 +34,27 @@ export class UserService { ); } - async findByName(name: string) { + async findByName(name: string, id: string) { if (!name) return []; - return await this.userRepo.find({ - relations: ['avatar'], - where: [ - { firstName: ILike(`%${name}%`) }, - { lastName: ILike(`%${name}%`) }, - ], - }); + + return await this.userRepo + .createQueryBuilder('user') + .innerJoinAndSelect('user.avatar', 'file') + .where('user.firstName ILike :name', { name }) + .orWhere('user.lastName ILike :name', { name }) + .andWhere('user.id != :id', { id }) + .getMany(); } async findOne(id: string) { return await this.userRepo.findOne({ id }); } - async createUser(user: SignUpInput, file: FileUpload) { + async createUser(user: SignUpInput) { const password = await bcrypt.hash(user.password, 10); - const avatar = await this.fileService.uploadDatabaseFile(file); - return this.userRepo - .create({ ...user, email: user.email.toLowerCase(), password, avatar }) + .create({ ...user, email: user.email.toLowerCase(), password }) .save() .catch((e) => { if (/(email)[\s\S]+(already exists)/.test(e.detail)) { diff --git a/frontend/src/components/chat/chat.tsx b/frontend/src/components/chat/chat.tsx index 3985836..5e82018 100644 --- a/frontend/src/components/chat/chat.tsx +++ b/frontend/src/components/chat/chat.tsx @@ -134,9 +134,9 @@ export const Chat = () => { /> ); })} -
+ {/*
Today -
+
*/} diff --git a/frontend/src/components/sidebar/search-list/styles.scss b/frontend/src/components/sidebar/search-list/styles.scss index 9d040d3..a63950c 100644 --- a/frontend/src/components/sidebar/search-list/styles.scss +++ b/frontend/src/components/sidebar/search-list/styles.scss @@ -12,6 +12,10 @@ top: calc(100% + 10px); z-index: 1; + & > div > div:last-child { + align-self: center; + } + &.not-found { padding: 16px; color: $c_text_primary; diff --git a/frontend/src/pages/Auth/register-block/register-block.tsx b/frontend/src/pages/Auth/register-block/register-block.tsx index c7513ee..2d8ebb1 100644 --- a/frontend/src/pages/Auth/register-block/register-block.tsx +++ b/frontend/src/pages/Auth/register-block/register-block.tsx @@ -1,14 +1,5 @@ import { BaseForm } from "@components"; -import { - Button, - ButtonStyle, - ButtonType, - AlertMessage, - IconDirection, - Input, - InputGroup, -} from "@ui"; -import GoogleLogoIcon from "@assets/svg/google-logo.svg"; +import { Button, ButtonType, AlertMessage, Input } from "@ui"; import styles from "./styles.scss"; import { useForm, UseFormOptions } from "react-hook-form"; import { registerModel } from "@features/models"; @@ -28,7 +19,7 @@ export const RegisterBlock = () => { fetchPolicy: "network-only", onCompleted: ({ signUp }) => { setItem(AUTH_TOKEN, signUp); - history.push(routePath.main.path); + history.push(routePath.profile.path); }, }); @@ -44,15 +35,10 @@ export const RegisterBlock = () => { password: data?.[registerModel.password], firstName: data?.[registerModel.firstName], lastName: data?.[registerModel.lastName], - avatar: data?.[registerModel.avatar].item(0), }, }); }; - const handleRegisterGoogle = () => { - console.log("google"); - }; - return ( { > New to the messenger? Instant registration - @@ -75,21 +60,13 @@ export const RegisterBlock = () => { className={styles.errorMessage} message={error?.message} /> - -