Skip to content

Commit 379c6fd

Browse files
committed
frontend format fix
1 parent 56813bd commit 379c6fd

File tree

21 files changed

+872
-778
lines changed

21 files changed

+872
-778
lines changed

frontend/.eslintrc.cjs

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ module.exports = {
3131
'@typescript-eslint/no-unused-vars': [
3232
'warn', // or "error"
3333
{
34-
'argsIgnorePattern': '^_',
35-
"varsIgnorePattern": '^_',
36-
'caughtErrorsIgnorePattern': '^_'
37-
}
38-
]
34+
argsIgnorePattern: '^_',
35+
varsIgnorePattern: '^_',
36+
caughtErrorsIgnorePattern: '^_',
37+
},
38+
],
3939
},
4040
}

frontend/src/app/routes/ui/index.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { Registration, Main } from '@/pages'
44
import { Welcome } from '@/pages/welcome/ui/Welcome.tsx'
55

66
export const Routes = () => (
7-
<>
8-
<Route route={routes.home} view={Welcome}/>
9-
<Route route={routes.registration} view={Registration}/>
10-
<Route route={routes.main} view={Main}/>
11-
</>
12-
);
7+
<>
8+
<Route route={routes.home} view={Welcome} />
9+
<Route route={routes.registration} view={Registration} />
10+
<Route route={routes.main} view={Main} />
11+
</>
12+
)
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
export interface PersonPatch {
2-
status: string | null,
3-
firstName: string | null,
4-
lastName: string | null,
5-
interests: Topic[] | null,
6-
height: number | null,
7-
birthday: string | null,
8-
facultyId: number | null,
9-
locationId: number | null
2+
status: string | null
3+
firstName: string | null
4+
lastName: string | null
5+
interests: Topic[] | null
6+
height: number | null
7+
birthday: string | null
8+
facultyId: number | null
9+
locationId: number | null
1010
}
1111

1212
export interface Topic {
13-
topicId: number,
14-
level: number
13+
topicId: number
14+
level: number
1515
}

frontend/src/entities/person/model/Person.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ export interface Person {
1717
}
1818

1919
export interface PersonLegacy {
20-
status: string,
21-
userId: number,
22-
firstName: string,
23-
zodiac: string,
24-
lastName: string,
25-
interests: Interest[],
26-
height: number,
27-
birthday: Date,
28-
facultyId: number,
29-
locationId: number
20+
status: string
21+
userId: number
22+
firstName: string
23+
zodiac: string
24+
lastName: string
25+
interests: Interest[]
26+
height: number
27+
birthday: Date
28+
facultyId: number
29+
locationId: number
3030
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export interface Coordinates {
2-
latitude: number,
3-
longitude: number
4-
}
2+
latitude: number
3+
longitude: number
4+
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Coordinates } from './Coordinates.ts'
22

33
export interface Location {
4-
id: number,
5-
name: string,
6-
coordinates: Coordinates
7-
8-
}
4+
id: number
5+
name: string
6+
coordinates: Coordinates
7+
}

frontend/src/entities/registration-data/model/RegistartionData.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { Interest } from './interest.ts'
22
import { Picture } from './picture.ts'
33

44
export type RegistrationData = {
5-
tgId: string | null;
6-
name: string | null;
7-
surname: string | null;
8-
height: number | null;
9-
facultyId: number | null;
10-
birthday: Date | null;
11-
pictures: Picture[] | null;
12-
interests: Interest[] | null;
13-
locationId: number | null;
14-
};
5+
tgId: string | null
6+
name: string | null
7+
surname: string | null
8+
height: number | null
9+
facultyId: number | null
10+
birthday: Date | null
11+
pictures: Picture[] | null
12+
interests: Interest[] | null
13+
locationId: number | null
14+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export interface Faculty {
2-
id: number,
3-
longName: string
2+
id: number
3+
longName: string
44
}
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,79 @@
1-
import {createEffect, createStore} from 'effector'
2-
import {persist} from 'effector-storage/session'
3-
import {AuthRequest} from '../model/AuthRequest.ts'
4-
import {AuthResponse} from '../model/AuthResponse.ts'
1+
import { createEffect, createStore } from 'effector'
2+
import { persist } from 'effector-storage/session'
3+
import { AuthRequest } from '../model/AuthRequest.ts'
4+
import { AuthResponse } from '../model/AuthResponse.ts'
55
import axios from 'axios'
6-
import {AuthState, initialAuthState} from '@/entities'
7-
import {backendAuthikUrl} from '@/shared/api'
6+
import { AuthState, initialAuthState } from '@/entities'
7+
import { backendAuthikUrl } from '@/shared/api'
88

99
export const $authStore = createStore<AuthState>(initialAuthState)
10-
export const $userIdStore = createStore<number | null>(null);
10+
export const $userIdStore = createStore<number | null>(null)
1111

12-
export const $userRegisteredStore = createStore<boolean>(false);
12+
export const $userRegisteredStore = createStore<boolean>(false)
1313

14-
15-
persist({store: $authStore, key: 'authStore'})
16-
persist({store: $userIdStore, key: 'userIdStore'})
17-
persist({store: $userRegisteredStore, key: 'userRegisteredStore'})
14+
persist({ store: $authStore, key: 'authStore' })
15+
persist({ store: $userIdStore, key: 'userIdStore' })
16+
persist({ store: $userRegisteredStore, key: 'userRegisteredStore' })
1817

1918
export const authFx = createEffect<AuthRequest, AuthState, Error>({
20-
handler: async (authReq) => {
21-
try {
22-
const response = await axios.put<AuthResponse>(
23-
`${backendAuthikUrl}/api/auth/telegram/web-app`,
24-
JSON.stringify(authReq),
25-
{
26-
method: 'PUT',
27-
headers: {
28-
'Content-Type': 'application/json',
29-
},
30-
},
31-
)
32-
return fillAuthState(response.data)
33-
} catch (error) {
34-
console.error(error)
35-
throw new Error('Auth failed')
36-
}
37-
},
19+
handler: async (authReq) => {
20+
try {
21+
const response = await axios.put<AuthResponse>(
22+
`${backendAuthikUrl}/api/auth/telegram/web-app`,
23+
JSON.stringify(authReq),
24+
{
25+
method: 'PUT',
26+
headers: {
27+
'Content-Type': 'application/json',
28+
},
29+
},
30+
)
31+
return fillAuthState(response.data)
32+
} catch (error) {
33+
console.error(error)
34+
throw new Error('Auth failed')
35+
}
36+
},
3837
})
3938

4039
const fillAuthState = (response: AuthResponse): AuthState => {
41-
return {
42-
token: response.access,
43-
loading: false,
44-
tgId: '-1',
45-
isAuthenticated: true,
46-
error: null
47-
};
40+
return {
41+
token: response.access,
42+
loading: false,
43+
tgId: '-1',
44+
isAuthenticated: true,
45+
error: null,
46+
}
4847
}
4948

50-
export const $isAuthenticated = $authStore.map(state => state.isAuthenticated)
49+
export const $isAuthenticated = $authStore.map((state) => state.isAuthenticated)
5150

52-
$authStore.on(authFx.doneData, (_, result) => result);
53-
$authStore.on(authFx.failData, (_, error) => ({...initialAuthState, loading: false, error: error.message}));
51+
$authStore.on(authFx.doneData, (_, result) => result)
52+
$authStore.on(authFx.failData, (_, error) => ({
53+
...initialAuthState,
54+
loading: false,
55+
error: error.message,
56+
}))
5457

5558
export const userIdFx = createEffect<number | null, number | null, Error>({
56-
handler: async (x) => {
57-
if (x == null)
58-
throw Error("x is null")
59-
return x
60-
}
61-
}
62-
)
59+
handler: async (x) => {
60+
if (x == null) throw Error('x is null')
61+
return x
62+
},
63+
})
6364

6465
export const userRegisteredFx = createEffect<boolean, boolean, Error>({
65-
handler: async (x) => {
66-
if (!x)
67-
throw Error("user not registered")
68-
return x
69-
}
70-
}
71-
)
66+
handler: async (x) => {
67+
if (!x) throw Error('user not registered')
68+
return x
69+
},
70+
})
7271

7372
$userIdStore.on(userIdFx.doneData, (_, result) => result)
7473
$userIdStore.on(userIdFx.failData, (_, __) => {
75-
return null
74+
return null
7675
})
7776
$userRegisteredStore.on(userRegisteredFx.doneData, (_, result) => result)
7877
$userRegisteredStore.on(userRegisteredFx.failData, (_, __) => {
79-
return false
78+
return false
8079
})

frontend/src/features/edit-profile/api/editProfile.ts

+29-29
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@ import { PersonPatch } from '@/entities/person-patch/model/PersonPatch.ts'
66
export function editProfile(profile: Person) {
77
const url = `${backendPeopleUrl}/api/people/${profile.id}`
88

9-
// FIXME jwt token
10-
const basicAuth = 'test basic auth'
11-
const config = {
12-
method: 'POST',
13-
headers: {
14-
'Content-Type': 'application/json',
15-
'Authorization': +basicAuth,
16-
},
17-
}
18-
const profilePatch: PersonPatch = {
19-
status: 'ready',
20-
firstName: profile.firstName,
21-
lastName: profile.lastName,
22-
interests: profile.interests.map((interest) => {
23-
return { topicId: interest.topic.id, level: interest.level }
24-
}),
25-
height: profile.height,
26-
birthday: `${profile.birthday.getFullYear()}-${profile.birthday.getMonth()}-${profile.birthday.getDay()}`,
27-
facultyId: 1,
28-
locationId: 1,
29-
}
30-
axios
31-
.post(url, profilePatch, config)
32-
.then((response) => {
33-
console.log(response.data);
34-
})
35-
.catch((error) => {
36-
console.error('Error patching: ', error)
37-
})
9+
// FIXME jwt token
10+
const basicAuth = 'test basic auth'
11+
const config = {
12+
method: 'POST',
13+
headers: {
14+
'Content-Type': 'application/json',
15+
Authorization: +basicAuth,
16+
},
17+
}
18+
const profilePatch: PersonPatch = {
19+
status: 'ready',
20+
firstName: profile.firstName,
21+
lastName: profile.lastName,
22+
interests: profile.interests.map((interest) => {
23+
return { topicId: interest.topic.id, level: interest.level }
24+
}),
25+
height: profile.height,
26+
birthday: `${profile.birthday.getFullYear()}-${profile.birthday.getMonth()}-${profile.birthday.getDay()}`,
27+
facultyId: 1,
28+
locationId: 1,
29+
}
30+
axios
31+
.post(url, profilePatch, config)
32+
.then((response) => {
33+
console.log(response.data)
34+
})
35+
.catch((error) => {
36+
console.error('Error patching: ', error)
37+
})
3838
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
import axios from "axios";
2-
import React from "react";
3-
import {backendPeopleUrl} from "@/shared/api";
4-
import {Faculty} from "@/entities/registration-data/model/faculty.ts";
1+
import axios from 'axios'
2+
import React from 'react'
3+
import { backendPeopleUrl } from '@/shared/api'
4+
import { Faculty } from '@/entities/registration-data/model/faculty.ts'
55

6-
export function getFaculties(setFaculties: React.Dispatch<React.SetStateAction<Array<Faculty>>>) {
7-
const url = `${backendPeopleUrl}/api/faculties`;
6+
export function getFaculties(
7+
setFaculties: React.Dispatch<React.SetStateAction<Array<Faculty>>>,
8+
) {
9+
const url = `${backendPeopleUrl}/api/faculties`
810

9-
axios.get(url)
10-
.then((response) => {
11-
console.log(response.data);
12-
//FIXME after integration with backend
13-
setFaculties(response.data)
14-
})
15-
.catch((error) => {
16-
console.error("Error getting faculties: ", error);
17-
//TODO remove after integration with backend
18-
setFaculties([
19-
{id: 1, longName: "piict"}
20-
])
21-
})
22-
}
11+
axios
12+
.get(url)
13+
.then((response) => {
14+
console.log(response.data)
15+
//FIXME after integration with backend
16+
setFaculties(response.data)
17+
})
18+
.catch((error) => {
19+
console.error('Error getting faculties: ', error)
20+
//TODO remove after integration with backend
21+
setFaculties([{ id: 1, longName: 'piict' }])
22+
})
23+
}

0 commit comments

Comments
 (0)