diff --git a/front/package-lock.json b/front/package-lock.json index 6d01400..aaa465f 100644 --- a/front/package-lock.json +++ b/front/package-lock.json @@ -10,11 +10,14 @@ "dependencies": { "@ant-design/icons": "^5.3.7", "antd": "^5.17.0", + "axios": "^1.7.2", + "js-cookie": "^3.0.5", "next": "14.2.3", "react": "^18", "react-dom": "^18" }, "devDependencies": { + "@types/js-cookie": "^3.0.6", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", @@ -649,6 +652,12 @@ "tslib": "^2.4.0" } }, + "node_modules/@types/js-cookie": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.6.tgz", + "integrity": "sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==", + "dev": true + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -1165,6 +1174,11 @@ "integrity": "sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==", "dev": true }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "node_modules/available-typed-arrays": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", @@ -1189,6 +1203,16 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -1385,6 +1409,17 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", @@ -1563,6 +1598,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -2330,6 +2373,25 @@ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -2355,6 +2417,19 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3155,6 +3230,14 @@ "jiti": "bin/jiti.js" } }, + "node_modules/js-cookie": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz", + "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==", + "engines": { + "node": ">=14" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -3343,6 +3426,25 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -3971,6 +4073,11 @@ "react-is": "^16.13.1" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/front/package.json b/front/package.json index 367fd46..f785856 100644 --- a/front/package.json +++ b/front/package.json @@ -11,11 +11,14 @@ "dependencies": { "@ant-design/icons": "^5.3.7", "antd": "^5.17.0", + "axios": "^1.7.2", + "js-cookie": "^3.0.5", "next": "14.2.3", "react": "^18", "react-dom": "^18" }, "devDependencies": { + "@types/js-cookie": "^3.0.6", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", diff --git a/front/src/app/axios/api-types.ts b/front/src/app/axios/api-types.ts new file mode 100644 index 0000000..6c0a2a7 --- /dev/null +++ b/front/src/app/axios/api-types.ts @@ -0,0 +1,37 @@ +export type LoginResponse = { + token: string; + token_expired_at: number; + refresh_token: string; + refresh_token_expired_at: number; +}; +export type Organization = { + id: string; + name: string; + address: string; +}; +export type OrganizationsResponse = { + items: Organization[]; +}; +export type NewOrgResponse = { + id: string; +}; +export type Ids = { + id: string; +}; +export type ParticipantsResponse = { + ids: Ids[]; +}; +export type AddPartResponse = { + name: string; + position: string; + wallet_address: string; +}; +export type PublicKey = { + public_key: string; +}; +export type DeployResponse = { + title: string; + owners: PublicKey[]; + confirmations: number; +}; +export type MultiSigResponse = {}; diff --git a/front/src/app/axios/global-api.ts b/front/src/app/axios/global-api.ts new file mode 100644 index 0000000..c7fbc5b --- /dev/null +++ b/front/src/app/axios/global-api.ts @@ -0,0 +1,27 @@ +import axios from "axios"; +import Cookies from "js-cookie"; +// const tokenStorage = Cookies.get("accessToken"); + +export const globalService = axios.create({ + baseURL: "http://209.141.36.222:8085/", + timeout: 10000, +}); + +globalService.interceptors.request.use( + (config) => { + // Get the access token from the cookie + const token = Cookies.get("accessToken"); + console.log(token); + + // If the token exists, set it in the Authorization header + if (token) { + config.headers.Authorization = `Bearer ${token}`; + } + + return config; + }, + (error) => { + // If there's an error in the request configuration, you can handle it here + return Promise.reject(error); + } +); diff --git a/front/src/app/axios/global.service.ts b/front/src/app/axios/global.service.ts new file mode 100644 index 0000000..1173e37 --- /dev/null +++ b/front/src/app/axios/global.service.ts @@ -0,0 +1,91 @@ +import { globalService } from "../axios/global-api"; +import { AxiosResponse } from "axios"; +import Cookies from "js-cookie"; +import { + LoginResponse, + OrganizationsResponse, + NewOrgResponse, + ParticipantsResponse, + AddPartResponse, + DeployResponse, + MultiSigResponse, +} from "./api-types"; +export class AccountingService { + async login(seedKey: string): Promise> { + console.log(seedKey); + + return await globalService.post("login", { + mnemonic: seedKey, + }); + } + + async register(seedKey: string) { + return await globalService.post("join", { + mnemonic: seedKey, + }); + } + + async newOrganization( + name: string, + address: string + ): Promise> { + return await globalService.post("organizations", { + name, + address, + }); + } + + async getOrganizations(): Promise> { + return await globalService.post("organizations/fetch", { + data: { + limit: 5, + }, + }); + } + + async getEmployees( + organizationId: string + ): Promise> { + return await globalService.get( + `organizations/${organizationId}/participants` + ); + } + + async addEmployee( + name: string, + position: string, + wallet_address: string, + organizationId: string + ): Promise> { + return await globalService.post( + `organizations/${organizationId}/participants`, + { + name, + position, + wallet_address, + } + ); + } + + // POST /organizations/{organization_id}/multisig + async deployMultisig( + organization_id: string, + title: string, + owners: string[], + confirmations: number + ): Promise> { + return await globalService.post(`${organization_id}/multi-sig`, { + title, + owners, + confirmations, + }); + } + + async getAllMultisigsByOrganizationId( + organizationId: string + ): Promise> { + return await globalService.get(`organizations/${organizationId}/multisig`); + } +} + +export const apiService = new AccountingService(); diff --git a/front/src/app/login/LoginPage.tsx b/front/src/app/login/LoginPage.tsx index a0f1d29..feaaab9 100644 --- a/front/src/app/login/LoginPage.tsx +++ b/front/src/app/login/LoginPage.tsx @@ -1,37 +1,41 @@ -// 1. Страница входа (Login Page) -// Дизайн: Страница должна быть минималистичной с использованием профессиональной цветовой схемы (синие и серые тона). Должно быть поле для ввода мнемонической фразы (SEED_KEY) и кнопка для входа. -// Безопасность: Добавить элементы, подчеркивающие безопасность, например, иконку замка и текст, имитирующий шифрование. -// Валидация: Проверять формат введенного SEED_KEY на клиентской стороне перед отправкой на сервер. "use client"; import React from "react"; import { SeedItem } from "../seedItem/SeedItem"; - import { useRouter } from "next/navigation"; import { useState, useEffect, FC } from "react"; import { EyeInvisibleOutlined, EyeTwoTone } from "@ant-design/icons"; - +import { apiService } from "../axios/global.service"; import { Input, Space, Button, List, Card, Typography } from "antd"; import { LockOutlined } from "@ant-design/icons"; import useLoginHooks from "@/hooks/login"; +import Cookies from "js-cookie"; export function LoginPage() { - const { passwordVisible, setPasswordVisible, seed, getSeed } = - useLoginHooks(); + const { passwordVisible, setPasswordVisible } = useLoginHooks(); const [inp, setInp] = useState(""); + const [seed, setSeed] = useState(); const [disabled, setDisabled] = useState(true); const router = useRouter(); - const onNextPageHandler = () => { - router.push("/organization"); - }; + + const onNextPageHandler = async () => {}; + // const getSeed = (event: React.ChangeEvent) => { + // setSeed(inp); + // }; + console.log(inp); const { Text } = Typography; useEffect(() => { setDisabled(!(inp.length >= 4)); }, [inp]); - const onSubmitHandler = () => { + const onSubmitHandler = async () => { + const result = await apiService.login(inp); + if (result) { + Cookies.set("accessToken", result.data.token); + router.push("/organization"); + } setInp(""); - getSeed(inp); }; + return (
@@ -39,7 +43,9 @@ export function LoginPage() {
- Please enter 12 words always lowercase. + + Please enter by spaces 12 words always lowercase. +
@@ -59,8 +65,9 @@ export function LoginPage() { } placeholder="Enter your seed words in order" onInput={(event: any) => setInp(event.target.value)} - maxLength={8} + //maxLength={8} minLength={4} + //onChange={getSeed} />
-
- {seed.map((element: string, index: number) => ( - - ))} -
+ {/* {seed.map((element: string, index: number) => ( + // + ))} +
*/} + + + ); +} +//suffixIcon={} diff --git a/front/src/app/organization/overview/license/page.tsx b/front/src/app/organization/overview/license/page.tsx new file mode 100644 index 0000000..254267e --- /dev/null +++ b/front/src/app/organization/overview/license/page.tsx @@ -0,0 +1,11 @@ +"use client"; +import React from "react"; +import { LicensesPage } from "./LicensesPage"; + +export default function Home() { + return ( +
+ +
+ ); +} diff --git a/front/src/app/organization/multiSig/MultiSigPage.tsx b/front/src/app/organization/overview/multiSig/MultiSigPage.tsx similarity index 65% rename from front/src/app/organization/multiSig/MultiSigPage.tsx rename to front/src/app/organization/overview/multiSig/MultiSigPage.tsx index 14d5562..a4cddb4 100644 --- a/front/src/app/organization/multiSig/MultiSigPage.tsx +++ b/front/src/app/organization/overview/multiSig/MultiSigPage.tsx @@ -3,8 +3,9 @@ import React, { useState } from "react"; import { Input } from "antd"; import { Typography } from "antd"; import { Card } from "antd"; +import { WalletOutlined } from "@ant-design/icons"; import type { InputNumberProps } from "antd"; -import { Col, InputNumber, Row, Slider, Space, Button } from "antd"; +import { Col, InputNumber, Row, Slider, Select, Button } from "antd"; const { Title } = Typography; @@ -14,14 +15,14 @@ export function MultisigPage() { setInputValue(newValue as number); }; return ( -
+
- Create a new Multisig + Create a new Multisig
- Signers + Owners
@@ -29,14 +30,32 @@ export function MultisigPage() {
- - - + } + defaultValue={""} + style={{ width: "full" }} + allowClear + options={[{ value: "", label: "" }]} + /> + + + + +
+ +
+ + + + + + + +
+ +
+
+ + + + + + +
+ +
+
+
+ ); +} diff --git a/front/src/app/organization/overview/pending/page.tsx b/front/src/app/organization/overview/pending/page.tsx new file mode 100644 index 0000000..6f4cb4d --- /dev/null +++ b/front/src/app/organization/overview/pending/page.tsx @@ -0,0 +1,11 @@ +"use client"; +import React from "react"; +import { PendingPage } from "./PendingPage"; + +export default function Home() { + return ( +
+ +
+ ); +} diff --git a/front/src/app/organization/page.tsx b/front/src/app/organization/page.tsx index 114bb6f..2f50c87 100644 --- a/front/src/app/organization/page.tsx +++ b/front/src/app/organization/page.tsx @@ -1,7 +1,6 @@ "use client"; import React from "react"; -import { OrgCreatePage } from "./OrgCreatePage"; -// вместо этого надо класть большие компоненты +import { OrgCreatePage } from "../orgCreate/OrgCreatePage"; export default function organization() { return ( diff --git a/front/src/app/ui/BackBtn.tsx b/front/src/app/ui/BackBtn.tsx new file mode 100644 index 0000000..d7ef2ff --- /dev/null +++ b/front/src/app/ui/BackBtn.tsx @@ -0,0 +1,20 @@ +"use client"; +import { Button } from "antd"; +import { useRouter } from "next/navigation"; +import { ArrowLeftOutlined } from "@ant-design/icons"; +export function BackBtn() { + const router = useRouter(); + const goBack = () => { + router.back(); + }; + return ( + + ); +} diff --git a/front/src/app/ui/PayOutBtn.tsx b/front/src/app/ui/PayOutBtn.tsx new file mode 100644 index 0000000..8601dfb --- /dev/null +++ b/front/src/app/ui/PayOutBtn.tsx @@ -0,0 +1,14 @@ +"use client"; +import { Button } from "antd"; +import { useRouter } from "next/navigation"; +export function PayOutBtn() { + const router = useRouter(); + const onPayHandler = () => { + router.push("/organization/overview/pending"); + }; + return ( + + ); +} diff --git a/front/src/hooks/login.tsx b/front/src/hooks/login.tsx index 66979e3..4f3a773 100644 --- a/front/src/hooks/login.tsx +++ b/front/src/hooks/login.tsx @@ -2,14 +2,11 @@ import { useState } from "react"; export default function useLoginHooks() { const [passwordVisible, setPasswordVisible] = useState([]); - const [seed, setSeed] = useState([]); - const getSeed = (string: string) => { - if (seed.length < 12) { - setSeed((prev) => [...prev, string]); - } - }; - console.log(seed); + // const getSeed = (string: string) => { + // // if (seed.length < 12) { + // setSeed((prev) => [...prev, string]); + // }; - return { passwordVisible, setPasswordVisible, seed, getSeed }; + return { passwordVisible, setPasswordVisible }; }