Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint 3 #3

Merged
merged 269 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
269 commits
Select commit Hold shift + click to select a range
e2617e8
refactoring code
Karmyshkov Jul 8, 2022
7ce2a86
added BaseAPI class
Karmyshkov Jul 8, 2022
64c3b7a
refactoring code
Karmyshkov Jul 8, 2022
abce4ce
added alias for Api
Karmyshkov Jul 8, 2022
71144c9
changes logic of handleSubmitForm function
Karmyshkov Jul 8, 2022
8dc9f8a
code style
Karmyshkov Jul 8, 2022
18e475c
refactoring BaseAPI class
Karmyshkov Jul 8, 2022
67d2e6d
added AuthAPI class
Karmyshkov Jul 8, 2022
4311306
refactoring code
Karmyshkov Jul 8, 2022
bef14e0
fixed error
Karmyshkov Jul 8, 2022
9b1c002
added sugnup function
Karmyshkov Jul 8, 2022
4c25dd9
added alias for services
Karmyshkov Jul 8, 2022
fea81d3
added service for Auth
Karmyshkov Jul 8, 2022
82f2240
added auth services
Karmyshkov Jul 8, 2022
47fa6d6
refactoring code
Karmyshkov Jul 8, 2022
6eb40d0
decomposed code
Karmyshkov Jul 8, 2022
ccf249a
fixed readme
Karmyshkov Jul 8, 2022
f0fc398
added tooltip
Karmyshkov Jul 8, 2022
997a4db
fixed error
Karmyshkov Jul 8, 2022
f3ba838
added getMessageFromResponse function
Karmyshkov Jul 8, 2022
44dde1a
changes AuthAPI class
Karmyshkov Jul 8, 2022
7cdcbd2
decomposed code
Karmyshkov Jul 8, 2022
5d4c871
fixed error
Karmyshkov Jul 8, 2022
03d056a
added close tooltip by click
Karmyshkov Jul 8, 2022
af6b00d
change regexp for phone
Karmyshkov Jul 10, 2022
0b3749b
fixed style
Karmyshkov Jul 10, 2022
dbb2c63
fixed logic of auth service
Karmyshkov Jul 10, 2022
f1ae584
added work with sign(in/up)
Karmyshkov Aug 3, 2022
4cc7191
added add chat popup element
Karmyshkov Aug 4, 2022
4cc3015
refactoring popup component
Karmyshkov Aug 4, 2022
c06720e
added formValidator for add chat form
Karmyshkov Aug 4, 2022
2f00bf8
refactoring btnProfile component
Karmyshkov Aug 4, 2022
6261ee5
added event click for signout
Karmyshkov Aug 4, 2022
2e3aecc
added signout function
Karmyshkov Aug 4, 2022
c5cab47
decomposed code
Karmyshkov Aug 4, 2022
6d0bc86
refactoring code
Karmyshkov Aug 4, 2022
5456c04
added ChatApi
Karmyshkov Aug 4, 2022
238c5ac
added ChatService
Karmyshkov Aug 4, 2022
001fc17
added logic for created of chat
Karmyshkov Aug 4, 2022
2348c5b
fixed HTTPTransport class
Karmyshkov Aug 4, 2022
805c258
replace hardcode on DTA
Karmyshkov Aug 4, 2022
c21f287
refactoring code
Karmyshkov Aug 5, 2022
55c32ff
added filtered chats
Karmyshkov Aug 5, 2022
d9710b1
clear code
Karmyshkov Aug 5, 2022
3f6f969
fixed render error
Karmyshkov Aug 5, 2022
aee0bb7
decomposed code
Karmyshkov Aug 5, 2022
accac09
fixed errors
Karmyshkov Aug 5, 2022
1fef886
refactoring code
Karmyshkov Aug 5, 2022
13bc52d
fixed style
Karmyshkov Aug 5, 2022
e715210
added put method in BaseApi
Karmyshkov Aug 6, 2022
f93b04a
added ProfileApi
Karmyshkov Aug 6, 2022
5dc5dd1
added ProfileService
Karmyshkov Aug 6, 2022
3d4f8ff
added exports for created of ProfileApi
Karmyshkov Aug 6, 2022
c288056
fixed error, change type of request
Karmyshkov Aug 6, 2022
c063a3c
fixed InputFile component
Karmyshkov Aug 6, 2022
fe5ee87
refactoring code
Karmyshkov Aug 6, 2022
d82348a
clear code
Karmyshkov Aug 6, 2022
358f43a
fixed error in HTTPTransplort class
Karmyshkov Aug 6, 2022
5591bd9
added changeAvatar method in ProfileService
Karmyshkov Aug 6, 2022
8b1a061
added export for ProfileService
Karmyshkov Aug 6, 2022
c15b990
added put method in BaseAPI
Karmyshkov Aug 6, 2022
a5bc1af
added changeAvatar in ProfileApi
Karmyshkov Aug 6, 2022
08bc9b2
refactoring code
Karmyshkov Aug 6, 2022
b2dbcf3
refactoring code
Karmyshkov Aug 6, 2022
db6c578
refactoring code
Karmyshkov Aug 6, 2022
01924d0
added base url for resources
Karmyshkov Aug 6, 2022
f733206
fixed style for change avatar
Karmyshkov Aug 6, 2022
e151bba
fixed url for avatar image
Karmyshkov Aug 6, 2022
e9a6d5c
refactoring code
Karmyshkov Aug 6, 2022
27f6a40
fixed error
Karmyshkov Aug 6, 2022
cd0ebf9
changed logic workink with HTTPTransport
Karmyshkov Aug 6, 2022
ad110c5
clear auth service
Karmyshkov Aug 6, 2022
c2b05ec
fixed style
Karmyshkov Aug 6, 2022
1c9f2a7
clear code
Karmyshkov Aug 6, 2022
260b30b
refactoring code
Karmyshkov Aug 6, 2022
15db99b
decomposed code
Karmyshkov Aug 6, 2022
23b1ed5
refactoring signin page
Karmyshkov Aug 6, 2022
cf34d68
refactoring signup page
Karmyshkov Aug 6, 2022
885e2dc
fixed error (white screen)
Karmyshkov Aug 7, 2022
277b200
decomposed code
Karmyshkov Aug 7, 2022
dc30c8c
changes BtnBackProfile component
Karmyshkov Aug 7, 2022
8d8f8a0
refactoring code
Karmyshkov Aug 7, 2022
f70a8fc
added onClick event for BtnBackProfile component
Karmyshkov Aug 7, 2022
e70e1f2
fixed code
Karmyshkov Aug 7, 2022
b2275aa
changes edit profile page
Karmyshkov Aug 7, 2022
50fd289
cchanges edit password page
Karmyshkov Aug 7, 2022
8afe370
fixed style for profile page
Karmyshkov Aug 7, 2022
14941a6
changes profile page
Karmyshkov Aug 7, 2022
ecb2662
refactoring BtnProfile component
Karmyshkov Aug 7, 2022
63552b6
refactoring code
Karmyshkov Aug 7, 2022
9b15ec8
refactoring code
Karmyshkov Aug 7, 2022
cf65bce
clear code
Karmyshkov Aug 7, 2022
ec62a9b
added logic working with change user info
Karmyshkov Aug 7, 2022
96136f7
added changeUserPassword in ProfileApi
Karmyshkov Aug 7, 2022
de01fe4
added changeUserPassword in ProfileService
Karmyshkov Aug 7, 2022
05f11f4
added logic change of password
Karmyshkov Aug 7, 2022
b8371e8
refactoring code
Karmyshkov Aug 7, 2022
2cc2eb1
added ui for deleted chat
Karmyshkov Aug 7, 2022
5695f06
addded delete method in BaseAPI
Karmyshkov Aug 7, 2022
198dd78
added base api and service for remove chat logic
Karmyshkov Aug 7, 2022
948a5d9
fixed error
Karmyshkov Aug 7, 2022
d2e1a01
fixed bag
Karmyshkov Aug 7, 2022
0bffec7
refactoring signin page
Karmyshkov Aug 7, 2022
6c76ef0
refactoring signup page
Karmyshkov Aug 7, 2022
28b7eb9
refactoring chats page
Karmyshkov Aug 7, 2022
a378d2f
refactoring profile page
Karmyshkov Aug 7, 2022
3e01c74
refactoring edit password page
Karmyshkov Aug 7, 2022
a7231db
refactoring edit profile page
Karmyshkov Aug 7, 2022
343ce52
refactoring service files
Karmyshkov Aug 7, 2022
6b08180
added api and service for find user by login
Karmyshkov Aug 7, 2022
27860ed
fixed actions for popup
Karmyshkov Aug 7, 2022
1a2bb1b
added logic searching user by login
Karmyshkov Aug 7, 2022
f75970c
rename constant
Karmyshkov Aug 7, 2022
8090b21
improvements app
Karmyshkov Aug 7, 2022
c6d4de5
fixed base styles
Karmyshkov Aug 8, 2022
86c289c
added style for popup
Karmyshkov Aug 8, 2022
aa16fb4
added addUserToChat for ChatApi
Karmyshkov Aug 8, 2022
642842a
added addUserToChat for ChatService
Karmyshkov Aug 8, 2022
07ba14c
code style
Karmyshkov Aug 8, 2022
17a84d3
refactoring code
Karmyshkov Aug 8, 2022
0d8c901
clear code
Karmyshkov Aug 8, 2022
03d4123
refactoring code
Karmyshkov Aug 8, 2022
3f7d81a
refactoring code for tooltip
Karmyshkov Aug 8, 2022
426efaf
fixed service
Karmyshkov Aug 8, 2022
68e9b57
refactoring code
Karmyshkov Aug 9, 2022
5ba5415
fixed error
Karmyshkov Aug 9, 2022
6a3dde8
clear code
Karmyshkov Aug 9, 2022
7fa3496
refactoring code
Karmyshkov Aug 9, 2022
368ce97
refactoring code
Karmyshkov Aug 9, 2022
942237b
fixed bug margin
Karmyshkov Aug 9, 2022
34ecd8b
fixed style
Karmyshkov Aug 9, 2022
fe50de0
fixed submit function
Karmyshkov Aug 9, 2022
015177a
added onClick props for UserItem component
Karmyshkov Aug 9, 2022
1c0e248
added onClick props for UserItem component
Karmyshkov Aug 9, 2022
b6f19cf
rename constants
Karmyshkov Aug 9, 2022
00a18ad
added data attribute
Karmyshkov Aug 9, 2022
6926769
fixed bug
Karmyshkov Aug 9, 2022
7f7003d
addded logic rendering current chat name and chat avatar
Karmyshkov Aug 9, 2022
956125e
clear code
Karmyshkov Aug 9, 2022
1fe3d0c
fixed errors
Karmyshkov Aug 9, 2022
9082591
fixed style
Karmyshkov Aug 9, 2022
a1a12b4
refactoring components
Karmyshkov Aug 9, 2022
0b36bbb
refactoring services
Karmyshkov Aug 9, 2022
18e2438
fixed MessagesService
Karmyshkov Aug 10, 2022
83bf6dc
added getChatToken method in ChatApi
Karmyshkov Aug 10, 2022
42ec8db
added getChatToken method in ChatService
Karmyshkov Aug 10, 2022
ed48d65
added GetChatToken type
Karmyshkov Aug 10, 2022
673a713
added logic taked chat of token
Karmyshkov Aug 10, 2022
f8f3d06
refactoring api
Karmyshkov Aug 11, 2022
b0f1954
added onSubmit prop for ChatFooter component
Karmyshkov Aug 11, 2022
6be6e80
refactoring types
Karmyshkov Aug 11, 2022
2879350
rename types
Karmyshkov Aug 11, 2022
ad891c3
clear code
Karmyshkov Aug 11, 2022
65a3900
rename types
Karmyshkov Aug 11, 2022
ecfdeb0
rename types
Karmyshkov Aug 11, 2022
605949c
refactoring BaseApi
Karmyshkov Aug 11, 2022
0e2caf5
clear code in AuthService
Karmyshkov Aug 11, 2022
31b7402
clear code in ChatService
Karmyshkov Aug 11, 2022
66f2819
clear code in ProfileService
Karmyshkov Aug 11, 2022
dc15bbd
added checking on matched password
Karmyshkov Aug 11, 2022
e1b7ec5
clear code
Karmyshkov Aug 11, 2022
da4d7d1
deleted data folder
Karmyshkov Aug 11, 2022
571ac40
refactoring code
Karmyshkov Aug 11, 2022
836f448
refactoring getChatToken method
Karmyshkov Aug 11, 2022
e97d758
refactoring searchUserByLogin method
Karmyshkov Aug 11, 2022
19e21cf
refactoring errors
Karmyshkov Aug 11, 2022
8f180dd
refactoring code
Karmyshkov Aug 12, 2022
e51c2d1
added saved created chat
Karmyshkov Aug 12, 2022
830ce45
fixed error
Karmyshkov Aug 12, 2022
2d936f2
fixed chat
Karmyshkov Aug 12, 2022
f8c7732
fixed time
Karmyshkov Aug 12, 2022
9c7afbd
refactoring code
Karmyshkov Aug 12, 2022
20f85a4
changed rendering logic for ListItem
Karmyshkov Aug 12, 2022
df4b5e0
refactoring MessagesService
Karmyshkov Aug 12, 2022
5c88491
clear code
Karmyshkov Aug 12, 2022
c364421
fixed scroll bottom
Karmyshkov Aug 12, 2022
b17f0b9
clear code
Karmyshkov Aug 12, 2022
d7a0f0b
decomposed code
Karmyshkov Aug 12, 2022
b30b420
fixed style for Menu component
Karmyshkov Aug 12, 2022
9a50e24
added getUniqDateFromMessages/getIdUniqDates functions
Karmyshkov Aug 12, 2022
669f977
fixed style for Message component
Karmyshkov Aug 12, 2022
9b35fe2
added date for message
Karmyshkov Aug 12, 2022
a16549d
fixed types
Karmyshkov Aug 12, 2022
45f069f
added tooltip for add user to chat
Karmyshkov Aug 12, 2022
cf87cbd
clear code
Karmyshkov Aug 12, 2022
f0531b2
added getUserForChat method in ChatService and ChatApi
Karmyshkov Aug 12, 2022
ee5e603
fixed style
Karmyshkov Aug 12, 2022
ba1fbfe
refactoring code
Karmyshkov Aug 12, 2022
968655a
fixed deleted user from chat form
Karmyshkov Aug 12, 2022
ddd169f
added logic deleted user from chat
Karmyshkov Aug 12, 2022
8bef8ac
fixed logic working deleted user from chat
Karmyshkov Aug 12, 2022
861ba4d
fixed logic deleted chat
Karmyshkov Aug 13, 2022
0c596c1
fixed logic added user to chat
Karmyshkov Aug 13, 2022
7482244
fixed logic added user to chat
Karmyshkov Aug 13, 2022
17551ec
clear code
Karmyshkov Aug 13, 2022
9dfdd01
refactoring Route
Karmyshkov Aug 13, 2022
1e7b702
refactoring code
Karmyshkov Aug 13, 2022
02e4e91
added check on isLoginIn
Karmyshkov Aug 13, 2022
8af8a5c
fixed style for UserItem component
Karmyshkov Aug 13, 2022
7a3c00a
fixed error
Karmyshkov Aug 13, 2022
906b2ba
decomposed code
Karmyshkov Aug 13, 2022
7c263e7
refactoring ChatApi
Karmyshkov Aug 13, 2022
2bc42e2
fixed error
Karmyshkov Aug 13, 2022
ee177a9
clear code
Karmyshkov Aug 13, 2022
e3a8597
change setState from Store
Karmyshkov Aug 13, 2022
7285a13
changed bugs
Karmyshkov Aug 13, 2022
27e6b2b
added types
Karmyshkov Aug 13, 2022
58bacf8
fixed types
Karmyshkov Aug 13, 2022
1fcc9ae
refactoring types
Karmyshkov Aug 13, 2022
094878d
refactoring type
Karmyshkov Aug 13, 2022
a6e9b99
clear code
Karmyshkov Aug 13, 2022
20b4e6f
fixed bug
Karmyshkov Aug 13, 2022
3226bf1
fixed error
Karmyshkov Aug 13, 2022
376e983
added prop role for UserList component
Karmyshkov Aug 13, 2022
c0ab3fd
fixed error
Karmyshkov Aug 13, 2022
3cb91a0
code style
Karmyshkov Aug 13, 2022
6ff6765
refactoring code
Karmyshkov Aug 13, 2022
28d603e
fixed netlify config
Karmyshkov Aug 13, 2022
a0d2523
added logic working with not found page
Karmyshkov Aug 13, 2022
ab74e0f
fixed readme
Karmyshkov Aug 13, 2022
45e7555
clear code in AuthAPI
Karmyshkov Aug 13, 2022
e1d2fdd
clear code in AuthService
Karmyshkov Aug 13, 2022
6bd2890
refactoring BaseAPI
Karmyshkov Aug 13, 2022
fa0039b
refactoring code
Karmyshkov Aug 13, 2022
7142b53
code style
Karmyshkov Aug 14, 2022
77600a3
refactoring code
Karmyshkov Aug 14, 2022
3d468df
refactoring redirect method
Karmyshkov Aug 14, 2022
2da04bf
rename StoreEvents
Karmyshkov Aug 14, 2022
3f51055
clear code
Karmyshkov Aug 14, 2022
24e8cdb
fixed error
Karmyshkov Aug 14, 2022
af66f5e
fixed readme
Karmyshkov Aug 14, 2022
658e937
refactoring code
Karmyshkov Aug 14, 2022
582966d
refactoring constants
Karmyshkov Aug 14, 2022
59bf3e8
deleted isEqual function
Karmyshkov Aug 14, 2022
0ca0773
decomposed code
Karmyshkov Aug 14, 2022
ba3e107
decomposed code
Karmyshkov Aug 14, 2022
a1c4b5b
decomposed code
Karmyshkov Aug 14, 2022
66b9e4a
refactoring code
Karmyshkov Aug 14, 2022
d8444db
fixed error
Karmyshkov Aug 14, 2022
133b0b5
decomposed code
Karmyshkov Aug 14, 2022
1dbae09
decomposed code
Karmyshkov Aug 14, 2022
5845b25
refactoring code
Karmyshkov Aug 14, 2022
07587a3
fixed types
Karmyshkov Aug 14, 2022
210860a
clear code
Karmyshkov Aug 14, 2022
2370d9c
fixed types
Karmyshkov Aug 14, 2022
2a4a72e
fixed error
Karmyshkov Aug 14, 2022
b853e78
refactoring code
Karmyshkov Aug 14, 2022
c0934c3
refactoring code
Karmyshkov Aug 14, 2022
e8fc698
refactoring code
Karmyshkov Aug 15, 2022
2cd6c3a
Merge branch 'main' into sprint_3
Karmyshkov Aug 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@

[![Netlify Status](https://api.netlify.com/api/v1/badges/8d2019e6-98b7-43d0-8cad-a2d86bee843b/deploy-status)](https://app.netlify.com/sites/mellifluous-bunny-f4b9fb/deploys)

* Макет в Figma: [https://www.figma.com/file/tT9Qv8j6OeVC2AmgQzXEG3/Chat?node-id=0%3A1](https://www.figma.com/file/tT9Qv8j6OeVC2AmgQzXEG3/Chat?node-id=0%3A1)
* Netlify: [https://deploy--sprightly-kataifi-71c800.netlify.app](https://deploy--sprightly-kataifi-71c800.netlify.app)
* Макет в Figma: [Ссылка на макет](https://www.figma.com/file/tT9Qv8j6OeVC2AmgQzXEG3/Chat?node-id=0%3A1)
* Netlify: [Ссылка на приложение](https://deploy--sprightly-kataifi-71c800.netlify.app)

#### Логин

```bash
as1211516dasd
```

#### Пароль

```bash
asdasdasdasd
```

### Описание

Expand Down
8 changes: 4 additions & 4 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
command = "npm run build"

[[redirects]]
from = "/signup"
from = "/sign-up"
to = "/"
status = 200

[[redirects]]
from = "/chat"
from = "/messenger"
to = "/"
status = 200

[[redirects]]
from = "/profile"
from = "/settings"
to = "/"
status = 200

[[redirects]]
from = "/edit-profile"
from = "/edit-settings"
to = "/"
status = 200

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"img": "./src/image",
"routes": "./src/routes",
"types": "./src/types",
"data": "./src/data",
"vendor": "./src/vendor",
"variables": "./src/variables",
"utils": "./src/utils",
"styles": "./src/styles"
"styles": "./src/styles",
"api": "./src/Api",
"services": "./src/services"
},
"repository": {
"type": "git",
Expand Down
25 changes: 25 additions & 0 deletions src/Api/AuthAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { BaseAPI } from './BaseAPI';
import { SignupType, SigninType } from 'types';

class AuthAPI extends BaseAPI {
constructor() {
super({ path: '/auth' });
}

public signup({ ...rest }: SignupType) {
return this.post('signup', { ...rest });
}

public signin({ ...rest }: SigninType) {
return this.post('signin', { ...rest });
}
public signout() {
return this.post('logout', {});
}

public getInfo() {
return this.get('user');
}
}

export default new AuthAPI();
33 changes: 33 additions & 0 deletions src/Api/BaseAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { HTTPTransport } from 'utils/classes';
import { URLS, HEADERS } from 'utils/constants';

export abstract class BaseAPI {
private _http: HTTPTransport;
private _baseUrl: string;
private _headers: Record<string, string>;

constructor({ path }: Record<string, string>) {
this._http = new HTTPTransport();
this._baseUrl = `${URLS.BASE}${path}`;
this._headers = HEADERS.CT_APPLICATION_JSON;
}

post(url: string, data: unknown) {
return this._http.post(`${this._baseUrl}/${url}`, { headers: this._headers, data });
}

get(url: string) {
return this._http.get(`${this._baseUrl}/${url}`, { headers: this._headers });
}

put(url: string, data: unknown, headers?: unknown) {
return this._http.put(`${this._baseUrl}/${url}`, {
headers: headers ? headers : this._headers,
data,
});
}

delete(url: string, data: unknown) {
return this._http.delete(`${this._baseUrl}/${url}`, { headers: this._headers, data });
}
}
45 changes: 45 additions & 0 deletions src/Api/ChatApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { BaseAPI } from './BaseAPI';
import {
CreateChatType,
RemoveChatType,
AddUserToChatType,
GetChatTokenType,
GetUserForChatType,
RemoveUserFromChat,
} from 'types';

class ChatApi extends BaseAPI {
constructor() {
super({ path: '/chats' });
}

public createChat({ ...rest }: CreateChatType) {
return this.post('', { ...rest });
}

public getChats() {
return this.get('');
}

public removeChatById({ ...rest }: RemoveChatType) {
return this.delete('', { ...rest });
}

public addUserToChat({ ...rest }: AddUserToChatType) {
return this.put('users', { ...rest });
}

public getChatToken({ chatId }: GetChatTokenType) {
return this.post(`token/${chatId}`, {});
}

public getUserForChat({ chatId }: GetUserForChatType) {
return this.get(`${chatId}/users`);
}

public removeUserFromChat({ ...rest }: RemoveUserFromChat) {
return this.delete('users', { ...rest });
}
}

export default new ChatApi();
26 changes: 26 additions & 0 deletions src/Api/ProfileApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { BaseAPI } from './BaseAPI';
import { UserInfoDTO, UserPasswordType, SearchUserByLoginType } from 'types';

class ProfileApi extends BaseAPI {
constructor() {
super({ path: '/user' });
}

public changeAvatar(avatar: FormData) {
return this.put('/profile/avatar', avatar, {});
}

public changeUserInfo(userInfo: UserInfoDTO) {
return this.put('/profile', userInfo);
}

public changeUserPassword(userPassword: UserPasswordType) {
return this.put('/password', userPassword);
}

public searchUserByLogin({ login }: SearchUserByLoginType) {
return this.post('/search', login);
}
}

export default new ProfileApi();
3 changes: 3 additions & 0 deletions src/Api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as authAPI } from './AuthAPI';
export { default as chatApi } from './ChatApi';
export { default as profileApi } from './ProfileApi';
16 changes: 16 additions & 0 deletions src/components/authLink/authLink.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.auth-link {
cursor: pointer;
background-color: transparent;
border: none;
margin: 0 auto;
display: block;
font-size: 11px;
color: var(--color-secondary);
font-weight: 500;
line-height: 11px;
transition: 0.3s opacity;

&:hover {
opacity: 0.8;
}
}
25 changes: 25 additions & 0 deletions src/components/authLink/authLink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Block } from 'core';
import './authLink.css';
import { AuthLinkProps } from './types';

export class AuthLink extends Block {
static componentName = 'AuthLink';

constructor({ onClick, ...rest }: AuthLinkProps) {
super({ events: { click: onClick }, ...rest });
}

protected getStateFromProps(props: AuthLinkProps): void {
this.state = {
text: props.text,
};
}

protected render(): string {
const { text } = this.state;
// language=hbs
return `
<Button class="auth-link" type="button">${text}</Button>
`;
}
}
1 change: 1 addition & 0 deletions src/components/authLink/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { AuthLink as default } from './authLink';
4 changes: 4 additions & 0 deletions src/components/authLink/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface AuthLinkProps {
onClick: () => void;
text: string;
}
18 changes: 14 additions & 4 deletions src/components/avatar/avatar.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
import Block from 'core/Block';
import { Block } from 'core';
import './avatar.css';
import { AvatarProps } from './types';
import defaultIcon from 'img/avatar.svg';
import { URLS } from 'utils';

export class Avatar extends Block {
static componentName = 'Avatar';
constructor({ srcAvatar, userName }: AvatarProps) {
super({ srcAvatar, userName });

constructor({ ...rest }: AvatarProps) {
super({ ...rest });
}

protected getStateFromProps(props: AvatarProps): void {
this.state = {
userName: props.userName,
srcAvatar: props.srcAvatar,
};
}

protected render(): string {
const { userName, srcAvatar } = this.state;

// language=hbs
return `
<img
class="avatar"
src="${srcAvatar}"
src="${
srcAvatar !== 'undefined' && srcAvatar !== 'null'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не понял, а почему undefined и null строками? Если бы они были не строками, можно было бы просто проверить srcAvatar ? ${BASE_URL_RESOURCES}${srcAvatar} : defaultIcon

? `${URLS.RESOURCES}${srcAvatar}`
: defaultIcon
}"
alt="Аватар пользователя ${userName}"
/>
`;
Expand Down
2 changes: 1 addition & 1 deletion src/components/btnBackProfile/btnBackProfile.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

&__link {
box-sizing: border-box;
text-decoration: none;
cursor: pointer;
border: none;
padding: 0;
width: 100%;
Expand Down
17 changes: 7 additions & 10 deletions src/components/btnBackProfile/btnBackProfile.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import Block from 'core/Block';
import { Block } from 'core';
import './btnBackProfile.css';
import { BtnBackProfileProps } from './types';
import left_arrow from 'img/left-arrow.svg';

export class BtnBackProfile extends Block {
static componentName = 'BtnBackProfile';
constructor({ href }: BtnBackProfileProps) {
super({ href });
}
protected getStateFromProps(props: BtnBackProfileProps): void {
this.state = {
href: props.href,
};

constructor({ onClick }: BtnBackProfileProps) {
super({ events: { click: onClick } });
}

protected render(): string {
// language=hbs
return `
<li class="profile-btn">
<a href="${this.state.href}" class="profile-btn__link" aria-label="Вернуться назад">
<Button class="profile-btn__link" aria-label="Вернуться назад">
<div class="profile-btn__wrap">
<img
class="profile__icon"
src="${left_arrow}"
alt="Иконка вернуться назад"
/>
</div>
</a>
</Button>
</li>
`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/btnBackProfile/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface BtnBackProfileProps {
href: string;
onClick: () => void;
}
20 changes: 19 additions & 1 deletion src/components/btnProfile/btnProfile.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
}

&__link {
text-decoration: none;
cursor: pointer;
background-color: transparent;
border: none;
padding: 0;
display: inline-block;
font-size: 13px;
font-weight: 500;
Expand All @@ -31,4 +34,19 @@
&__link_color_blue {
color: var(--color-secondary);
}

&__btn {
cursor: pointer;
background-color: transparent;
border: none;
padding: 0;
font-size: 13px;
font-weight: 500;
line-height: 13px;
transition: 0.3s opacity;
}

&__btn:hover {
opacity: 0.7;
}
}
Loading