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

some reg fixes, some main page fixes, some others #79

Merged
merged 6 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion backend/consul/config/consul.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ acl {
}

limits {
http_max_conns_per_client = 400
http_max_conns_per_client = 2000
}

data_dir = "/opt/consul/data"
Expand Down
1,869 changes: 1,047 additions & 822 deletions frontend/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions frontend/src/entities/authentication/model/AuthState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { JwtToken } from '@/shared/api'
export interface AuthState {
token: JwtToken | null
isAuthenticated: boolean
tgId: string | null
userId: string | null
loading: boolean
error: string | null
}

export const initialAuthState: AuthState = {
token: null,
isAuthenticated: false,
tgId: null,
userId: null,
loading: false,
error: null,
}
3 changes: 3 additions & 0 deletions frontend/src/entities/interest-level/model/InterestLevel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface InterestLevel {
level: string
}
8 changes: 0 additions & 8 deletions frontend/src/entities/main-button/api/mainButtonOnClick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,3 @@ export function removeMainButtonOnClick(fn: VoidFunction) {
offMainButtonClick(fn)
}
}

export function setMainButtonOnAndOffClick(fn: VoidFunction) {
const fun = () => {
fn()
removeMainButtonOnClick(fun)
}
setMainButtonOnClick(fun)
}
1 change: 0 additions & 1 deletion frontend/src/entities/main-button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ export { setMainButtonParams } from './api/setMainButtonParams.ts'
export { mountMainButton } from './api/mountMainButton.ts'
export {
setMainButtonOnClick,
setMainButtonOnAndOffClick,
removeMainButtonOnClick,
} from './api/mainButtonOnClick.ts'
17 changes: 17 additions & 0 deletions frontend/src/entities/person/model/Interest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,20 @@ export interface Interest {
topic: Topic
level: number
}

export interface InterestV2 {
topicId: number
level: string
}
export interface InterestMessage {
topicId: number
level: InterestLevelMessage
}

export enum InterestLevelMessage {
_1 = '1',
_2 = '2',
_3 = '3',
_4 = '4',
_5 = '5',
}
58 changes: 56 additions & 2 deletions frontend/src/entities/person/model/Person.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Picture } from './Picture.ts'
import { Interest } from './Interest.ts'
import { Picture, PictureMessage } from './Picture.ts'
import { Interest, InterestMessage, InterestV2 } from './Interest.ts'
import { Location } from './Location.ts'
import { PersonStatusMessage } from '@/entities/person/model/Status.ts'
import { ZodiacSignMessage } from '@/entities/person/model/ZodiacSign.ts'

export interface Person {
id: number
Expand Down Expand Up @@ -28,3 +30,55 @@ export interface PersonLegacy {
facultyId: number
locationId: number
}

export interface SearchPerson {
userId: number
zodiac: string
firstName: string
lastName: string
pictures: PictureMessage[]
interests: InterestV2[]
height: number
birthday: string
facultyId: number
locationId: number
}

export interface PersonDraftV2 {
status: PersonStatusMessage
userId: number
firstName: string | null
lastName: string | null
interests: Array<InterestMessage> | null
height: number | null
birthday: string | null
facultyId: number | null
locationId: number | null
pictures: Array<PictureMessage> | null
}

export interface PersonV2 {
firstName: string
lastName: string
interests: Array<InterestMessage>
height: number
birthday: string
pictures: Array<PictureMessage>
zodiac: ZodiacSignMessage
status: PersonStatusMessage
userId: number
facultyId: number | null
locationId: number | null
}

export interface PersonPatchV2 {
status: PersonStatusMessage
firstName: string | null
lastName: string | null
interests: Array<InterestMessage> | null
height: number | null
birthday: string | null
facultyId: number | null
locationId: number | null
pictures: Array<PictureMessage> | null
}
4 changes: 4 additions & 0 deletions frontend/src/entities/person/model/Picture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ export interface Picture {
medium: string
large: string
}

export interface PictureMessage {
id: number
}
4 changes: 4 additions & 0 deletions frontend/src/entities/person/model/Status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum PersonStatusMessage {
draft = 'draft',
ready = 'ready',
}
14 changes: 14 additions & 0 deletions frontend/src/entities/person/model/ZodiacSign.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export enum ZodiacSignMessage {
aries = 'aries',
taurus = 'taurus',
gemini = 'gemini',
cancer = 'cancer',
leo = 'leo',
virgo = 'virgo',
libra = 'libra',
scorpio = 'scorpio',
sagittarius = 'sagittarius',
capricorn = 'capricorn',
aquarius = 'aquarius',
pisces = 'pisces',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createEffect, createStore } from 'effector'
import { RegistrationData } from '@/entities'
import { persist } from 'effector-storage/session'

export const $registrationDataStore = createStore<RegistrationData>({
firstName: null,
lastName: null,
height: null,
facultyId: null,
birthday: null,
pictures: null,
interests: null,
locationId: null,
})

persist({ store: $registrationDataStore, key: 'registrationDataStore' })

export const registrationDataFx = createEffect<
RegistrationData,
RegistrationData,
Error
>({
handler: async (regData) => {
return regData
},
})

$registrationDataStore.on(registrationDataFx.doneData, (_, result) => result)
$registrationDataStore.on(registrationDataFx.failData, (rd, _error) => rd)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { Interest } from './interest.ts'
import { Picture } from './picture.ts'

export type RegistrationData = {
tgId: string | null
name: string | null
surname: string | null
firstName: string | null
lastName: string | null
height: number | null
facultyId: number | null
birthday: Date | null
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/entities/registration-data/model/picture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export interface Picture {
id: number
small: string
medium: string
large: string
}
3 changes: 1 addition & 2 deletions frontend/src/entities/registration-data/model/topic.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export interface Topic {
id: number
name: string
icon: any // eslint-disable-line
color: any // eslint-disable-line
color: string
}
2 changes: 1 addition & 1 deletion frontend/src/features/authentication/api/authFx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const fillAuthState = (response: AuthResponse): AuthState => {
return {
token: response.access,
loading: false,
tgId: '-1',
userId: JSON.parse(atob(response.access.split('.')[1])).user_id,
isAuthenticated: true,
error: null,
}
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/features/delete-picture/api/deletePicture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import axios, { AxiosResponse } from 'axios'
import { backendUrl } from '@/shared/api'
import { $authStore } from '@/features/authentication/api/authFx.ts'
import { IError } from '@/shared/model'

export function deletePicture(
pictureId: number,
): Promise<AxiosResponse<void | IError>> {
const url = `${backendUrl}/api/people/${$authStore.getState().userId}/photos/${pictureId}`
const config = {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${$authStore.getState().token}`,
},
}

return axios.delete(url, config)
}
20 changes: 20 additions & 0 deletions frontend/src/features/delete-topic/api/deleteTopic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import axios, { AxiosResponse } from 'axios'
import { backendUrl } from '@/shared/api'
import { $authStore } from '@/features/authentication/api/authFx.ts'
import { IError } from '@/shared/model'

export function deleteTopic(
topicId: number,
): Promise<AxiosResponse<void | IError>> {
console.log(`delete topic ${topicId}`)
const url = `${backendUrl}/api/people/${$authStore.getState().userId}/interests/${topicId}`
const config = {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${$authStore.getState().token}`,
},
}

return axios.delete(url, config)
}
11 changes: 10 additions & 1 deletion frontend/src/features/get-faculties/api/getFaculties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ import axios from 'axios'
import React from 'react'
import { backendUrl } from '@/shared/api'
import { Faculty } from '@/entities/registration-data/model/faculty.ts'
import { $authStore } from '@/features/authentication/api/authFx.ts'

export function getFaculties(
setFaculties: React.Dispatch<React.SetStateAction<Array<Faculty>>>,
) {
const url = `${backendUrl}/api/faculties`
const basicAuth = `Bearer ${$authStore.getState().token}`
const config = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: basicAuth,
},
}

axios
.get(url)
.get(url, config)
.then((response) => {
console.log(response.data)
//FIXME after integration with backend
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/features/get-locations/api/getLocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ import axios from 'axios'
import React from 'react'
import { backendUrl } from '@/shared/api'
import { Location } from '@/entities/registration-data/model/Location.ts'
import { $authStore } from '@/features/authentication/api/authFx.ts'

export function getLocations(
setLocations: React.Dispatch<React.SetStateAction<Array<Location>>>,
) {
const url = `${backendUrl}/api/locations`
const basicAuth = `Bearer ${$authStore.getState().token}`
const config = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: basicAuth,
},
}

axios
.get(url)
.get(url, config)
.then((response) => {
console.log(response.data)
//FIXME after integration with backend
Expand Down
27 changes: 27 additions & 0 deletions frontend/src/features/get-matches/api/getMatches.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import axios from 'axios'
import React from 'react'
import { backendUrl } from '@/shared/api'
import { $authStore } from '@/features/authentication/api/authFx.ts'

export function getMatches(
setMatchesId: React.Dispatch<React.SetStateAction<Array<number>>>,
) {
const url = `${backendUrl}/api/people/${$authStore.getState().userId}/matches`
const config = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${$authStore.getState().token}`,
},
}
axios
.get(url, config)
.then((response) => {
console.log(response.data)
setMatchesId(response.data)
})
.catch((error) => {
console.error('Error getting matches: ', error)
setMatchesId([])
})
}
Loading
Loading