Moved frontend to separate folder, added basic user context and user page
This commit is contained in:
parent
da8a37dfbd
commit
452518f898
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,7 +1,7 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
node_modules/
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
@ -9,11 +9,11 @@
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
build/
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
|
20
front/components/User/RouteCard.tsx
Normal file
20
front/components/User/RouteCard.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
|
||||
import { IRouteCard } from "types/user";
|
||||
import { formatTimeLength } from "utils";
|
||||
|
||||
const RouteCard: React.FC<IRouteCard> = ({ route }) => {
|
||||
return (
|
||||
<div>
|
||||
<h2>{route.name}</h2>
|
||||
<p>
|
||||
Данный квесты вы сможете пройти за {formatTimeLength(route.averageTime)}
|
||||
</p>
|
||||
<p>Длинна маршрута: {route.length} м</p>
|
||||
<p>Примерное время прохождения: {route.averageTime}</p>
|
||||
<p>Точка старта:</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default RouteCard;
|
16
front/components/User/RouteView.tsx
Normal file
16
front/components/User/RouteView.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
import React from "react";
|
||||
import { IRouteView } from "types/user";
|
||||
import RouteCard from "./RouteCard";
|
||||
|
||||
const RouteView: React.FC<IRouteView> = ({ header, routes }) => {
|
||||
return (
|
||||
<>
|
||||
<h1>{header}</h1>
|
||||
{routes.map((route) => (
|
||||
<RouteCard key={route.id} route={route} />
|
||||
))}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default RouteView;
|
28
front/components/User/header.tsx
Normal file
28
front/components/User/header.tsx
Normal file
@ -0,0 +1,28 @@
|
||||
import React from "react";
|
||||
import Link from "next/link";
|
||||
|
||||
import { IHeaderProps } from "types/user";
|
||||
|
||||
const Header: React.FC<IHeaderProps> = ({ points }) => {
|
||||
return (
|
||||
<header>
|
||||
<div>Очки: {points}</div>
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<Link href="/profile">
|
||||
<a>Профиль</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/achivements">
|
||||
<a>Ачивки</a>
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
||||
export default Header;
|
26
front/context/user/index.tsx
Normal file
26
front/context/user/index.tsx
Normal file
@ -0,0 +1,26 @@
|
||||
import React, { useMemo, useState } from "react";
|
||||
|
||||
import { UserContextT, UserT } from "types/userContext";
|
||||
|
||||
const UserContext = React.createContext<UserContextT>(null);
|
||||
|
||||
const initialContext: UserT = {
|
||||
username: "",
|
||||
email: "",
|
||||
points: 0,
|
||||
id: 0,
|
||||
};
|
||||
|
||||
const UserProvider: React.FC = ({ children }) => {
|
||||
const [state, setState] = useState<UserT>(initialContext);
|
||||
|
||||
const value = useMemo(() => ({ userState: state, setUserState: setState }), [
|
||||
state,
|
||||
]);
|
||||
|
||||
return <UserContext.Provider value={value}>{children}</UserContext.Provider>;
|
||||
};
|
||||
|
||||
export { UserProvider, UserContext };
|
||||
|
||||
export type { UserT, UserContextT } from "../../types/userContext";
|
7
front/layouts/EmptyLayout.tsx
Normal file
7
front/layouts/EmptyLayout.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import React from "react";
|
||||
|
||||
const EmptyLayout: React.FC = ({ children }) => {
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
export default EmptyLayout;
|
14
front/layouts/MainLayout.tsx
Normal file
14
front/layouts/MainLayout.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React from "react";
|
||||
|
||||
import styles from "styles/layout.module.css";
|
||||
import { UserProvider } from "context/user";
|
||||
|
||||
const Layout: React.FC = ({ children }) => {
|
||||
return (
|
||||
<UserProvider>
|
||||
<div className={styles.content}>{children}</div>
|
||||
</UserProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default Layout;
|
16
front/layouts/UserLayout.tsx
Normal file
16
front/layouts/UserLayout.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
import React, { useContext } from "react";
|
||||
|
||||
import Header from "components/User/header";
|
||||
import { UserContext } from "context/user";
|
||||
|
||||
const UserLayout: React.FC = ({ children }) => {
|
||||
const { userState } = useContext(UserContext);
|
||||
return (
|
||||
<>
|
||||
<Header points={userState.points} />
|
||||
<main>{children}</main>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default UserLayout;
|
0
next-env.d.ts → front/next-env.d.ts
vendored
0
next-env.d.ts → front/next-env.d.ts
vendored
@ -11,7 +11,8 @@
|
||||
"dependencies": {
|
||||
"next": "10.0.3",
|
||||
"react": "17.0.1",
|
||||
"react-dom": "17.0.1"
|
||||
"react-dom": "17.0.1",
|
||||
"react-yandex-maps": "^4.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.14.10",
|
18
front/pages/_app.tsx
Normal file
18
front/pages/_app.tsx
Normal file
@ -0,0 +1,18 @@
|
||||
import React from "react";
|
||||
|
||||
import "styles/globals.css";
|
||||
import Layout from "layouts/MainLayout";
|
||||
import EmptyLayout from "layouts/EmptyLayout";
|
||||
|
||||
function MyApp({ Component, pageProps }) {
|
||||
const ComponentLayout = Component.Layout || EmptyLayout;
|
||||
return (
|
||||
<Layout>
|
||||
<ComponentLayout>
|
||||
<Component {...pageProps} />
|
||||
</ComponentLayout>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export default MyApp;
|
39
front/pages/routes/[id].tsx
Normal file
39
front/pages/routes/[id].tsx
Normal file
@ -0,0 +1,39 @@
|
||||
import React from "react";
|
||||
import { YMaps, Map, Placemark } from "react-yandex-maps";
|
||||
import { RouteT } from "types/main";
|
||||
|
||||
const route: RouteT = {
|
||||
id: 0,
|
||||
length: 10,
|
||||
name: "Тест",
|
||||
averageTime: 10,
|
||||
startCoordinates: {
|
||||
latitude: 10,
|
||||
longitude: 10,
|
||||
},
|
||||
};
|
||||
|
||||
const Route: React.FC = () => {
|
||||
return (
|
||||
<YMaps>
|
||||
<Map
|
||||
defaultState={{
|
||||
center: [
|
||||
route.startCoordinates.latitude,
|
||||
route.startCoordinates.longitude,
|
||||
],
|
||||
zoom: 14,
|
||||
}}
|
||||
>
|
||||
<Placemark
|
||||
geometry={[
|
||||
route.startCoordinates.latitude,
|
||||
route.startCoordinates.longitude,
|
||||
]}
|
||||
/>
|
||||
</Map>
|
||||
</YMaps>
|
||||
);
|
||||
};
|
||||
|
||||
export default Route;
|
31
front/pages/user.tsx
Normal file
31
front/pages/user.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
import UserLayout from "layouts/UserLayout";
|
||||
import { UserContext } from "context/user";
|
||||
import React, { useContext } from "react";
|
||||
import RouteView from "components/User/RouteView";
|
||||
import { RouteT } from "types/main";
|
||||
|
||||
const routes: RouteT[] = [
|
||||
{
|
||||
id: 0,
|
||||
name: "Пешком",
|
||||
length: 100,
|
||||
averageTime: 100,
|
||||
startCoordinates: {
|
||||
latitude: 60.977313,
|
||||
longitude: 69.039326,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const User = () => {
|
||||
const { userState, setUserState } = useContext(UserContext);
|
||||
return (
|
||||
<>
|
||||
<RouteView header={"Новые маршруты"} routes={routes} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
User.Layout = UserLayout;
|
||||
|
||||
export default User;
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
0
front/styles/globals.css
Normal file
0
front/styles/globals.css
Normal file
0
front/styles/layout.module.css
Normal file
0
front/styles/layout.module.css
Normal file
0
front/styles/user.module.css
Normal file
0
front/styles/user.module.css
Normal file
16
front/types/main.ts
Normal file
16
front/types/main.ts
Normal file
@ -0,0 +1,16 @@
|
||||
type RouteT = {
|
||||
id: number;
|
||||
name: string;
|
||||
length: number;
|
||||
averageTime?: number;
|
||||
userTime?: number;
|
||||
startCoordinates?: CoordinatesT;
|
||||
coordinates?: CoordinatesT[];
|
||||
};
|
||||
|
||||
type CoordinatesT = {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
};
|
||||
|
||||
export type { RouteT, CoordinatesT };
|
16
front/types/user.ts
Normal file
16
front/types/user.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { RouteT } from "./main";
|
||||
|
||||
interface IHeaderProps {
|
||||
points: number;
|
||||
}
|
||||
|
||||
interface IRouteView {
|
||||
header: string;
|
||||
routes: RouteT[];
|
||||
}
|
||||
|
||||
interface IRouteCard {
|
||||
route: RouteT;
|
||||
}
|
||||
|
||||
export type { IHeaderProps, IRouteView, IRouteCard };
|
13
front/types/userContext.ts
Normal file
13
front/types/userContext.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
|
||||
export type UserT = {
|
||||
username: string;
|
||||
email: string;
|
||||
id: number;
|
||||
points: number;
|
||||
};
|
||||
|
||||
export type UserContextT = {
|
||||
userState: UserT;
|
||||
setUserState: Dispatch<SetStateAction<UserT>>;
|
||||
};
|
5
front/utils/index.ts
Normal file
5
front/utils/index.ts
Normal file
@ -0,0 +1,5 @@
|
||||
const formatTimeLength = (minutes: number) =>
|
||||
(Math.floor(minutes / 60) > 0 ? `${Math.floor(minutes / 60)} ч. ` : "") +
|
||||
(minutes % 60 > 0 ? `${minutes % 60} мин.` : "");
|
||||
|
||||
export { formatTimeLength };
|
@ -462,6 +462,11 @@ array-unique@^0.3.2:
|
||||
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428"
|
||||
integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=
|
||||
|
||||
asap@~2.0.3:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
|
||||
integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=
|
||||
|
||||
asn1.js@^5.2.0:
|
||||
version "5.4.1"
|
||||
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07"
|
||||
@ -1015,6 +1020,11 @@ copy-descriptor@^0.1.0:
|
||||
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
|
||||
integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=
|
||||
|
||||
core-js@^1.0.0:
|
||||
version "1.2.7"
|
||||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
|
||||
integrity sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=
|
||||
|
||||
core-util-is@~1.0.0:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
|
||||
@ -1051,6 +1061,14 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7:
|
||||
safe-buffer "^5.0.1"
|
||||
sha.js "^2.4.8"
|
||||
|
||||
create-react-context@^0.2.3:
|
||||
version "0.2.3"
|
||||
resolved "https://registry.yarnpkg.com/create-react-context/-/create-react-context-0.2.3.tgz#9ec140a6914a22ef04b8b09b7771de89567cb6f3"
|
||||
integrity sha512-CQBmD0+QGgTaxDL3OX1IDXYqjkp2It4RIbcb99jS6AEg27Ga+a9G3JtK6SIu0HBwPLZlmwt9F7UwWA4Bn92Rag==
|
||||
dependencies:
|
||||
fbjs "^0.8.0"
|
||||
gud "^1.0.0"
|
||||
|
||||
cross-fetch@3.0.5:
|
||||
version "3.0.5"
|
||||
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.0.5.tgz#2739d2981892e7ab488a7ad03b92df2816e03f4c"
|
||||
@ -1348,9 +1366,9 @@ duplexify@^3.4.2, duplexify@^3.6.0:
|
||||
stream-shift "^1.0.0"
|
||||
|
||||
electron-to-chromium@^1.3.585:
|
||||
version "1.3.607"
|
||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.607.tgz#1bff13f1cf89f2fee0d244b8c64a7138f80f3a3b"
|
||||
integrity sha512-h2SYNaBnlplGS0YyXl8oJWokfcNxVjJANQfMCsQefG6OSuAuNIeW+A8yGT/ci+xRoBb3k2zq1FrOvkgoKBol8g==
|
||||
version "1.3.610"
|
||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.610.tgz#1254eb394acd220a836ea1f203f8cded4e487052"
|
||||
integrity sha512-eFDC+yVQpEhtlapk4CYDPfV9ajF9cEof5TBcO49L1ETO+aYogrKWDmYpZyxBScMNe8Bo/gJamH4amQ4yyvXg4g==
|
||||
|
||||
elliptic@^6.5.3:
|
||||
version "6.5.3"
|
||||
@ -1375,6 +1393,13 @@ emojis-list@^3.0.0:
|
||||
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78"
|
||||
integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==
|
||||
|
||||
encoding@^0.1.11:
|
||||
version "0.1.13"
|
||||
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9"
|
||||
integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==
|
||||
dependencies:
|
||||
iconv-lite "^0.6.2"
|
||||
|
||||
end-of-stream@^1.0.0, end-of-stream@^1.1.0, end-of-stream@^1.4.1:
|
||||
version "1.4.4"
|
||||
resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0"
|
||||
@ -1556,6 +1581,19 @@ fast-json-stable-stringify@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
|
||||
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
|
||||
|
||||
fbjs@^0.8.0:
|
||||
version "0.8.17"
|
||||
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.17.tgz#c4d598ead6949112653d6588b01a5cdcd9f90fdd"
|
||||
integrity sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=
|
||||
dependencies:
|
||||
core-js "^1.0.0"
|
||||
isomorphic-fetch "^2.1.1"
|
||||
loose-envify "^1.0.0"
|
||||
object-assign "^4.1.0"
|
||||
promise "^7.1.1"
|
||||
setimmediate "^1.0.5"
|
||||
ua-parser-js "^0.7.18"
|
||||
|
||||
figgy-pudding@^3.5.1:
|
||||
version "3.5.2"
|
||||
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"
|
||||
@ -1738,6 +1776,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2:
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
|
||||
integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
|
||||
|
||||
gud@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0"
|
||||
integrity sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw==
|
||||
|
||||
has-flag@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
|
||||
@ -1856,6 +1899,13 @@ iconv-lite@0.4.24:
|
||||
dependencies:
|
||||
safer-buffer ">= 2.1.2 < 3"
|
||||
|
||||
iconv-lite@^0.6.2:
|
||||
version "0.6.2"
|
||||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.2.tgz#ce13d1875b0c3a674bd6a04b7f76b01b1b6ded01"
|
||||
integrity sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==
|
||||
dependencies:
|
||||
safer-buffer ">= 2.1.2 < 3.0.0"
|
||||
|
||||
icss-utils@^4.0.0, icss-utils@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467"
|
||||
@ -2048,6 +2098,11 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4:
|
||||
dependencies:
|
||||
isobject "^3.0.1"
|
||||
|
||||
is-stream@^1.0.1:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
|
||||
integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ=
|
||||
|
||||
is-windows@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
|
||||
@ -2075,6 +2130,14 @@ isobject@^3.0.0, isobject@^3.0.1:
|
||||
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
|
||||
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
|
||||
|
||||
isomorphic-fetch@^2.1.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
|
||||
integrity sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=
|
||||
dependencies:
|
||||
node-fetch "^1.0.1"
|
||||
whatwg-fetch ">=0.10.0"
|
||||
|
||||
jest-worker@24.9.0:
|
||||
version "24.9.0"
|
||||
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.9.0.tgz#5dbfdb5b2d322e98567898238a9697bcce67b3e5"
|
||||
@ -2206,7 +2269,7 @@ lodash@^4.17.11, lodash@^4.17.13:
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
||||
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
|
||||
|
||||
loose-envify@^1.1.0, loose-envify@^1.4.0:
|
||||
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
|
||||
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
|
||||
@ -2524,6 +2587,14 @@ node-fetch@2.6.1:
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
|
||||
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
|
||||
|
||||
node-fetch@^1.0.1:
|
||||
version "1.7.3"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
|
||||
integrity sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==
|
||||
dependencies:
|
||||
encoding "^0.1.11"
|
||||
is-stream "^1.0.1"
|
||||
|
||||
node-html-parser@1.4.9:
|
||||
version "1.4.9"
|
||||
resolved "https://registry.yarnpkg.com/node-html-parser/-/node-html-parser-1.4.9.tgz#3c8f6cac46479fae5800725edb532e9ae8fd816c"
|
||||
@ -2894,9 +2965,9 @@ prebuild-install@^5.3.5:
|
||||
which-pm-runs "^1.0.0"
|
||||
|
||||
prettier@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.0.tgz#8a03c7777883b29b37fb2c4348c66a78e980418b"
|
||||
integrity sha512-yYerpkvseM4iKD/BXLYUkQV5aKt4tQPqaGW6EsZjzyu0r7sVZZNPJW4Y8MyKmicp6t42XUPcBVA+H6sB3gqndw==
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
|
||||
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==
|
||||
|
||||
process-nextick-args@~2.0.0:
|
||||
version "2.0.1"
|
||||
@ -2913,7 +2984,14 @@ promise-inflight@^1.0.1:
|
||||
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
|
||||
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=
|
||||
|
||||
prop-types@15.7.2:
|
||||
promise@^7.1.1:
|
||||
version "7.3.1"
|
||||
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
|
||||
integrity sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==
|
||||
dependencies:
|
||||
asap "~2.0.3"
|
||||
|
||||
prop-types@15.7.2, prop-types@^15.7.2:
|
||||
version "15.7.2"
|
||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
|
||||
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
|
||||
@ -3024,6 +3102,11 @@ rc@^1.2.7:
|
||||
minimist "^1.2.0"
|
||||
strip-json-comments "~2.0.1"
|
||||
|
||||
react-display-name@^0.2.4:
|
||||
version "0.2.5"
|
||||
resolved "https://registry.yarnpkg.com/react-display-name/-/react-display-name-0.2.5.tgz#304c7cbfb59ee40389d436e1a822c17fe27936c6"
|
||||
integrity sha512-I+vcaK9t4+kypiSgaiVWAipqHRXYmZIuAiS8vzFvXHHXVigg/sMKwlRgLy6LH2i3rmP+0Vzfl5lFsFRwF1r3pg==
|
||||
|
||||
react-dom@17.0.1:
|
||||
version "17.0.1"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.1.tgz#1de2560474ec9f0e334285662ede52dbc5426fc6"
|
||||
@ -3043,6 +3126,15 @@ react-refresh@0.8.3:
|
||||
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.8.3.tgz#721d4657672d400c5e3c75d063c4a85fb2d5d68f"
|
||||
integrity sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg==
|
||||
|
||||
react-yandex-maps@^4.4.0:
|
||||
version "4.4.0"
|
||||
resolved "https://registry.yarnpkg.com/react-yandex-maps/-/react-yandex-maps-4.4.0.tgz#42b116b94675dd3845fc808110f5e981fc3e7000"
|
||||
integrity sha512-AdLah4/xtCXFvuVAA3S76k6/otMsGnDp8G6Z5ku6rF4Rag3cSfv33GZOoDKQXXY4O7QefNFY3v+BWoDuzKSZvQ==
|
||||
dependencies:
|
||||
create-react-context "^0.2.3"
|
||||
prop-types "^15.7.2"
|
||||
react-display-name "^0.2.4"
|
||||
|
||||
react@17.0.1:
|
||||
version "17.0.1"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-17.0.1.tgz#6e0600416bd57574e3f86d92edba3d9008726127"
|
||||
@ -3200,7 +3292,7 @@ safe-regex@^1.1.0:
|
||||
dependencies:
|
||||
ret "~0.1.10"
|
||||
|
||||
"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.1.0:
|
||||
"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.1.0:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
||||
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
||||
@ -3288,7 +3380,7 @@ set-value@^2.0.0, set-value@^2.0.1:
|
||||
is-plain-object "^2.0.3"
|
||||
split-string "^3.0.1"
|
||||
|
||||
setimmediate@^1.0.4:
|
||||
setimmediate@^1.0.4, setimmediate@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
|
||||
integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=
|
||||
@ -3811,6 +3903,11 @@ typescript@^4.1.2:
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.2.tgz#6369ef22516fe5e10304aae5a5c4862db55380e9"
|
||||
integrity sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==
|
||||
|
||||
ua-parser-js@^0.7.18:
|
||||
version "0.7.22"
|
||||
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.22.tgz#960df60a5f911ea8f1c818f3747b99c6e177eae3"
|
||||
integrity sha512-YUxzMjJ5T71w6a8WWVcMGM6YWOTX27rCoIQgLXiWaxqXSx9D7DNjiGWn1aJIRSQ5qr0xuhra77bSIh6voR/46Q==
|
||||
|
||||
union-value@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847"
|
||||
@ -3982,6 +4079,11 @@ webpack@4.44.1:
|
||||
watchpack "^1.7.4"
|
||||
webpack-sources "^1.4.1"
|
||||
|
||||
whatwg-fetch@>=0.10.0:
|
||||
version "3.5.0"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.5.0.tgz#605a2cd0a7146e5db141e29d1c62ab84c0c4c868"
|
||||
integrity sha512-jXkLtsR42xhXg7akoDKvKWE40eJeI+2KZqcp2h3NsOrRnDvtWX36KcKl30dy+hxECivdk2BVUHVNrPtoMBUx6A==
|
||||
|
||||
whatwg-url@^7.0.0:
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-7.1.0.tgz#c2c492f1eca612988efd3d2266be1b9fc6170d06"
|
@ -1,21 +0,0 @@
|
||||
import { useState } from "react";
|
||||
|
||||
// Если функционал можно где-то переиспользовать или если код логики компонента занимает больше 150 строк, стоит разбить его на кастомные хуки и вынести сюда
|
||||
/**
|
||||
* Simple counter hook
|
||||
* @param {number} initialState
|
||||
*/
|
||||
const useCounter = (initialState = 0) => {
|
||||
if (typeof initialState !== "number")
|
||||
throw new Error("Initial counter state must be a number");
|
||||
|
||||
const [counter, setCounter] = useState(initialState);
|
||||
|
||||
const increaseCounter = () => {
|
||||
setCounter((prev) => prev + 1);
|
||||
};
|
||||
|
||||
return { counter, increaseCounter };
|
||||
};
|
||||
|
||||
export { useCounter }
|
@ -1,15 +0,0 @@
|
||||
import React from 'react'
|
||||
|
||||
import "styles/globals.css";
|
||||
import { CounterProvider } from "context/counterContext";
|
||||
|
||||
function MyApp({ Component, pageProps }) {
|
||||
return (
|
||||
// Здесь компонент Component оборачиваем провайдеры глобального контекста. Если контекст используется не во всём приложении, а в каком-то определённом компоненте и его дочерних элементах, стоит занести провайдер туда
|
||||
<CounterProvider>
|
||||
<Component {...pageProps} />
|
||||
</CounterProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default MyApp;
|
Loading…
x
Reference in New Issue
Block a user