Skip to content

Commit 7bad6f4

Browse files
authored
Second part frontend (#57)
1 parent d47b871 commit 7bad6f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2468
-687
lines changed

frontend/package-lock.json

+915-630
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
"@ant-design/icons": "^5.2.6",
1212
"antd": "^5.13.2",
1313
"axios": "^1.6.7",
14-
"effector-storage": "^7.0.0",
14+
"effector": "^23.2.3",
15+
"effector-storage": "^7.1.0",
1516
"react": "^18.2.0",
1617
"react-dom": "^18.2.0",
1718
"atomic-router": "^0.9.4",
1819
"atomic-router-react": "^0.9.1",
19-
"history": "^5.3.0"
20+
"history": "^5.3.0",
21+
"swiper": "^11.1.15"
2022
},
2123
"devDependencies": {
2224
"@eslint/js": "^9.2.0",

frontend/src/app/index.tsx

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import {useEffect} from "react";
2-
import { router } from "./routes/api";
3-
import { RouterProvider } from "atomic-router-react";
2+
import {router} from "./routes/api";
3+
import {RouterProvider} from "atomic-router-react";
44

55
import {$errorStore} from "@/shared/api";
66
import {message} from "antd";
77
import {Routes} from "@/app/routes/ui";
88

9-
import { init, mockTgEnv } from './telegram-sdk';
10-
import { retrieveLaunchParams } from '@telegram-apps/sdk';
9+
import {init, mockTgEnv} from './telegram-sdk';
10+
import {retrieveLaunchParams} from '@telegram-apps/sdk';
1111

1212

1313
export const App = () => {
14-
mockTgEnv().then( () => {
15-
init(retrieveLaunchParams().startParam === 'debug' || import.meta.env.DEV);
16-
}
17-
)
14+
mockTgEnv()
15+
.then(() => {
16+
init(retrieveLaunchParams().startParam === 'debug' || import.meta.env.DEV);
17+
})
18+
1819
const [messageApi, contextHolder] = message.useMessage();
1920
useEffect(() => {
2021
$errorStore.watch(state => {
@@ -26,7 +27,7 @@ export const App = () => {
2627
return (
2728
<RouterProvider router={router}>
2829
{contextHolder}
29-
<Routes />
30+
<Routes/>
3031
</RouterProvider>
3132
);
3233
};

frontend/src/app/routes/api/routing.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ const basePath = "/itmo-dating-mini-app"
55
export const routes = {
66
home: createRoute(),
77
registration: createRoute(),
8+
main: createRoute()
89
};
910

1011
export const routesMap = [
1112
{ path: "", route: routes.home },
1213
{ path: "/registration", route: routes.registration},
14+
{ path: "/main", route: routes.main},
1315
];
1416

1517
const history = createBrowserHistory();

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import {Route} from "atomic-router-react";
22
import {routes} from "../api";
3-
import {Registration, Home} from "@/pages";
3+
import {Registration, Home, Main} from "@/pages";
44

55
export const Routes = () => (
66
<>
77
<Route route={routes.home} view={Home}/>
88
<Route route={routes.registration} view={Registration}/>
9+
<Route route={routes.main} view={Main}/>
910
</>
1011
);

frontend/src/app/telegram-sdk/api/init.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
$debug,
88
init as initSDK,
99
} from '@telegram-apps/sdk';
10+
import {mountMainButton} from "@/entities/main-button";
11+
import {mountBackButton} from "@/entities/back-button";
1012

1113
/**
1214
* Initializes the application and configures its dependencies.
@@ -30,7 +32,9 @@ export function init(debug: boolean): void {
3032
}
3133

3234
// Mount all components used in the project.
33-
backButton.mount();
35+
mountMainButton()
36+
mountBackButton()
37+
3438
miniApp.mount();
3539
themeParams.mount();
3640
initData.restore();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {AddPictureButton} from "./ui/AddPictureButton.tsx"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {Icon28AddCircle} from "@telegram-apps/telegram-ui/dist/icons/28/add_circle";
2+
import {Card} from "@telegram-apps/telegram-ui";
3+
import {ChangeEventHandler} from "react";
4+
5+
interface addPictureButtonProps {
6+
handleUploadingPhotos: ChangeEventHandler<any>
7+
}
8+
export const AddPictureButton = ({handleUploadingPhotos}: addPictureButtonProps) => (
9+
<Card style={{
10+
background: 'var(--tgui--secondary_bg_color)',
11+
display: "block"
12+
}}>
13+
<Icon28AddCircle style={{
14+
display: "block",
15+
margin: "auto",
16+
// marginRight: "auto",
17+
marginBottom: "50%",
18+
marginTop: "50%",
19+
transform: "scale(5)"
20+
}} mode="plain"/>
21+
<input type="file" multiple accept="image/*" onInput={handleUploadingPhotos} style={{
22+
display: "block",
23+
height: "100%",
24+
width: "100%",
25+
position: "absolute",
26+
top: "0",
27+
bottom: "0",
28+
left: "0",
29+
right: "0",
30+
opacity: "0",
31+
cursor: "pointer"
32+
}}/>
33+
</Card>
34+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {backButton, offBackButtonClick, onBackButtonClick} from "@telegram-apps/sdk";
2+
3+
export function setBackButtonOnClick(fn: VoidFunction) {
4+
if (backButton.isMounted()) {
5+
return onBackButtonClick(fn)
6+
} else return () => {}
7+
}
8+
9+
export function removeBackButtonOnClick(fn: VoidFunction) {
10+
if (backButton.isMounted()) {
11+
offBackButtonClick(fn)
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {backButton} from "@telegram-apps/sdk";
2+
3+
export function mountBackButton() {
4+
if (backButton.mount.isAvailable()) {
5+
backButton.mount()
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {backButton} from "@telegram-apps/sdk";
2+
3+
export function setBackButtonVisible(isVisible: boolean) {
4+
if (backButton.isMounted()) {
5+
if (backButton.isSupported()) {
6+
if (isVisible) {
7+
backButton.show()
8+
} else {
9+
backButton.hide()
10+
}
11+
}
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {setBackButtonVisible} from "./api/setBackButtonVisible.ts"
2+
export {mountBackButton} from "./api/mountBackButton.ts"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {mainButton, offMainButtonClick, onMainButtonClick} from "@telegram-apps/sdk";
2+
3+
export function setMainButtonOnClick(fn: VoidFunction) {
4+
if (mainButton.isMounted()) {
5+
return onMainButtonClick(fn)
6+
} else return () => {}
7+
}
8+
9+
export function removeMainButtonOnClick(fn: VoidFunction) {
10+
if (mainButton.isMounted()) {
11+
offMainButtonClick(fn)
12+
}
13+
}
14+
15+
export function setMainButtonOnAndOffClick(fn: VoidFunction) {
16+
const fun = () => {fn(); removeMainButtonOnClick(fun)}
17+
setMainButtonOnClick(fun)
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {mainButton} from "@telegram-apps/sdk";
2+
3+
export function mountMainButton() {
4+
if (mainButton.mount.isAvailable()) {
5+
mainButton.mount()
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {mainButton} from "@telegram-apps/sdk";
2+
3+
export function setMainButtonParams(
4+
text: string,
5+
hasShineEffect: boolean,
6+
isEnabled: boolean,
7+
) {
8+
if (mainButton.isMounted()) {
9+
if (mainButton.setParams.isAvailable()) {
10+
mainButton.setParams({
11+
text: text,
12+
isEnabled: isEnabled,
13+
hasShineEffect: hasShineEffect,
14+
});
15+
}
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {mainButton} from "@telegram-apps/sdk";
2+
3+
export function setMainButtonVisible(isVisible: boolean) {
4+
if (mainButton.isMounted()) {
5+
if (mainButton.setParams.isAvailable()) {
6+
mainButton.setParams({
7+
isVisible: isVisible
8+
});
9+
}
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export {setMainButtonVisible} from "./api/setMainButtonVisible.ts"
2+
export {setMainButtonParams} from "./api/setMainButtonParams.ts"
3+
export {mountMainButton} from "./api/mountMainButton.ts"
4+
export {setMainButtonOnClick, setMainButtonOnAndOffClick, removeMainButtonOnClick} from "./api/mainButtonOnClick.ts"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export interface PersonPatch {
2+
status: string,
3+
firstName: string,
4+
lastName: string,
5+
interests: Topic[],
6+
height: number,
7+
birthday: string,
8+
facultyId: number,
9+
locationId: number
10+
}
11+
12+
export interface Topic {
13+
topicId: number,
14+
level: number
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface Coordinates {
2+
latitude: number,
3+
longitude: number
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {Topic} from "@/entities/person/model/Topic.ts";
2+
3+
export interface Interest {
4+
topic: Topic
5+
level: number
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {Coordinates} from "./Coordinates.ts";
2+
3+
export interface Location {
4+
name: string,
5+
coordinates: Coordinates
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {Picture} from "./Picture.ts";
2+
import {Interest} from "./Interest.ts";
3+
import {Location} from "./Location.ts";
4+
5+
export interface Person {
6+
id: number,
7+
zodiac: string,
8+
updateMoment: Date,
9+
firstName: string,
10+
lastName: string,
11+
pictures: Picture[],
12+
interests: Interest[],
13+
height: number,
14+
birthday: Date,
15+
faculty: string,
16+
location: Location
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export interface Picture {
2+
id: number,
3+
small: string,
4+
medium: string,
5+
large: string
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {Picture} from "./Picture.ts";
2+
3+
export interface Topic {
4+
id: number,
5+
name: string,
6+
icon: Picture,
7+
color: string
8+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
import {Interest} from "./interest.ts";
2+
import {Picture} from "./picture.ts";
3+
14
export type RegistrationData = {
25
tgId: string;
36
name: string;
47
surname: string;
58
height: number;
69
faculty: string;
10+
birthday: Date;
11+
pictures: Picture[],
12+
interests: Interest[]
713
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface Interest {
2+
topicId: number,
3+
level: number,
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export interface Picture {
2+
id: number,
3+
small: string,
4+
medium: string,
5+
large: string
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export interface Topic {
2+
id: number,
3+
name: string,
4+
icon: any,
5+
color: any
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export interface PersonDraft {
2+
firstName: string,
3+
lastName: string,
4+
pictures: Picture[],
5+
interests: Interest[],
6+
height: number,
7+
birthday: Date,
8+
faculty: string,
9+
location: Location
10+
}
11+
12+
interface Picture {
13+
id: number,
14+
small: string,
15+
medium: string | null,
16+
large: string | null
17+
}
18+
19+
interface Interest {
20+
topicId: number,
21+
level: number
22+
}
23+
24+
interface Location {
25+
name: string,
26+
coordinates: Coordinates
27+
28+
}
29+
30+
interface Coordinates {
31+
latitude: number,
32+
longitude: number
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {RegistrationPictureElement} from "./ui/RegistrationPictureElement.tsx"

0 commit comments

Comments
 (0)