diff --git a/.history/README_20220703212755.md b/.history/README_20220703212755.md new file mode 100644 index 0000000..fb15936 --- /dev/null +++ b/.history/README_20220703212755.md @@ -0,0 +1,28 @@ +# RoboTop сайт робототехнического фестиваля + +A Next.js starter for your next blog or personal site. Built with: + +- [Typescript](https://www.typescriptlang.org/) +- Write posts with [MDX](https://mdxjs.com/) +- Style with [Tailwind CSS](https://tailwindcss.com/) +- Linting with [ESLint](https://eslint.org/) +- Formatting with [Prettier](https://prettier.io/) +- Linting, typechecking and formatting on by default using [`husky`](https://github.com/typicode/husky) for commit hooks +- Testing with [Jest](https://jestjs.io/) and [`react-testing-library`](https://testing-library.com/docs/react-testing-library/intro) + +## Getting Started + +```bash +git clone https://github.com/ChangoMan/nextjs-typescript-mdx-blog.git +cd nextjs-typescript-mdx-blog + +yarn install +# or +npm install + +yarn dev +# or +npm run dev +``` + +Your new site will be up at http://localhost:3000/ diff --git a/.history/components/RegistrationForm_20220704215413.tsx b/.history/components/RegistrationForm_20220704215413.tsx new file mode 100644 index 0000000..77a936d --- /dev/null +++ b/.history/components/RegistrationForm_20220704215413.tsx @@ -0,0 +1,248 @@ +import React,{useRef} from 'react'; +import { useForm, SubmitHandler } from "react-hook-form"; + +interface IFormInputs { + firstName: string + lastName: string + coach_telefon_number: string +} + +const alerError = (props) => { + return

{props}

+} + +export const RegistrationForm = (props): JSX.Element => { + const form = useRef(null); + const { register, handleSubmit, reset, formState: { errors } } = useForm(); + + const onSubmit: SubmitHandler = data => { + fetch('/api/registration', { method: 'POST', body: Object.values(data) }) + .then(props.updateData(2)) + reset(); + } + return ( + <> +
+
+
+
+

Регистрация команды

+

Введите актуальные данные команды

+

От каждого учебного заведения может быть зарегистрированно неограниченое количеставо команд

+

Подписывайтесь на наш Telegram канал , что-бы быть в курсе новосте про соревнование

. +
+
+
+
+
+
+
+
+ + + {errors.name_team_coach && alerError('Введите ФИО тренера команды') } +
+ +
+ + + {errors.coach_telefon_number && alerError('Введите номер телефона')} +
+ +
+ + ()[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ })} + placeholder="you@example.com" + className="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" + /> + {errors.trainer_mail && alerError('Введите коректный Email адресс') + } +
+ +
+ + + { errors.city_team && alerError('Введите город команды') } +
+ +
+ + + {errors.training_institution_team && alerError('Введите название учебного заведения') } +
+ +
+ + + {errors.team_name && alerError('Введите название команды') } +
+ +
+ + + {errors.name_first_participant && alerError('Введите ФИО участника') } +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ +
+
+
+
+
+
+ + ); +}; + +export default RegistrationForm; diff --git a/.history/components/RegistrationForm_20220704215442.tsx b/.history/components/RegistrationForm_20220704215442.tsx new file mode 100644 index 0000000..3fed69b --- /dev/null +++ b/.history/components/RegistrationForm_20220704215442.tsx @@ -0,0 +1,248 @@ +import React,{useRef} from 'react'; +import { useForm, SubmitHandler } from "react-hook-form"; + +interface IFormInputs { + firstName: string + lastName: string + coach_telefon_number: string +} + +const alerError = (props) => { + return

{props}

+} + +export const RegistrationForm = (props): JSX.Element => { + const form = useRef(null); + const { register, handleSubmit, reset, formState: { errors } } = useForm(); + + const onSubmit: SubmitHandler = data => { + fetch('/api/registration', { method: 'POST', body: Object.values(data) }) + .then(props.updateData(2)) + reset(); + } + return ( + <> +
+
+
+
+

Регистрация команды

+

Введите актуальные данные команды

+

От каждого учебного заведения может быть зарегистрированно неограниченое количеставо команд

+

Подписывайтесь на наш Telegram канал , что-бы быть в курсе новосте про соревнование

. +
+
+
+
+
+
+
+
+ + + {errors.name_team_coach && alerError('Введите ФИО тренера команды') } +
+ +
+ + + {errors.coach_telefon_number && alerError('Введите номер телефона')} +
+ +
+ + ()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ })} + placeholder="you@example.com" + className="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" + /> + {errors.trainer_mail && alerError('Введите коректный Email адресс') + } +
+ +
+ + + { errors.city_team && alerError('Введите город команды') } +
+ +
+ + + {errors.training_institution_team && alerError('Введите название учебного заведения') } +
+ +
+ + + {errors.team_name && alerError('Введите название команды') } +
+ +
+ + + {errors.name_first_participant && alerError('Введите ФИО участника') } +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ +
+
+
+
+
+
+ + ); +}; + +export default RegistrationForm; diff --git a/.history/components/RegistrationForm_20220704215515.tsx b/.history/components/RegistrationForm_20220704215515.tsx new file mode 100644 index 0000000..1269801 --- /dev/null +++ b/.history/components/RegistrationForm_20220704215515.tsx @@ -0,0 +1,249 @@ +import React,{useRef} from 'react'; +import { useForm, SubmitHandler } from "react-hook-form"; + +interface IFormInputs { + firstName: string + lastName: string + coach_telefon_number: string + body: string[] +} + +const alerError = (props) => { + return

{props}

+} + +export const RegistrationForm = (props): JSX.Element => { + const form = useRef(null); + const { register, handleSubmit, reset, formState: { errors } } = useForm(); + + const onSubmit: SubmitHandler = data => { + fetch('/api/registration', { method: 'POST', body: Object.values(data) }) + .then(props.updateData(2)) + reset(); + } + return ( + <> +
+
+
+
+

Регистрация команды

+

Введите актуальные данные команды

+

От каждого учебного заведения может быть зарегистрированно неограниченое количеставо команд

+

Подписывайтесь на наш Telegram канал , что-бы быть в курсе новосте про соревнование

. +
+
+
+
+
+
+
+
+ + + {errors.name_team_coach && alerError('Введите ФИО тренера команды') } +
+ +
+ + + {errors.coach_telefon_number && alerError('Введите номер телефона')} +
+ +
+ + ()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ })} + placeholder="you@example.com" + className="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" + /> + {errors.trainer_mail && alerError('Введите коректный Email адресс') + } +
+ +
+ + + { errors.city_team && alerError('Введите город команды') } +
+ +
+ + + {errors.training_institution_team && alerError('Введите название учебного заведения') } +
+ +
+ + + {errors.team_name && alerError('Введите название команды') } +
+ +
+ + + {errors.name_first_participant && alerError('Введите ФИО участника') } +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ +
+
+
+
+
+
+ + ); +}; + +export default RegistrationForm; diff --git a/.history/components/RegistrationForm_20220704215742.tsx b/.history/components/RegistrationForm_20220704215742.tsx new file mode 100644 index 0000000..baded70 --- /dev/null +++ b/.history/components/RegistrationForm_20220704215742.tsx @@ -0,0 +1,249 @@ +import React,{useRef} from 'react'; +import { useForm, SubmitHandler } from "react-hook-form"; + +interface IFormInputs { + firstName: string + lastName: string + coach_telefon_number: string + body: string[] +} + +const alerError = (props) => { + return

{props}

+} + +export const RegistrationForm = (props): JSX.Element => { + const form = useRef(null); + const { register, handleSubmit, reset, formState: { errors } } = useForm(); + + const onSubmit: SubmitHandler = data => { + fetch('/api/registration', { method: 'POST', body: JSON.stringify(Object.values(data)) }) + .then(props.updateData(2)) + reset(); + } + return ( + <> +
+
+
+
+

Регистрация команды

+

Введите актуальные данные команды

+

От каждого учебного заведения может быть зарегистрированно неограниченое количеставо команд

+

Подписывайтесь на наш Telegram канал , что-бы быть в курсе новосте про соревнование

. +
+
+
+
+
+
+
+
+ + + {errors.name_team_coach && alerError('Введите ФИО тренера команды') } +
+ +
+ + + {errors.coach_telefon_number && alerError('Введите номер телефона')} +
+ +
+ + ()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ })} + placeholder="you@example.com" + className="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" + /> + {errors.trainer_mail && alerError('Введите коректный Email адресс') + } +
+ +
+ + + { errors.city_team && alerError('Введите город команды') } +
+ +
+ + + {errors.training_institution_team && alerError('Введите название учебного заведения') } +
+ +
+ + + {errors.team_name && alerError('Введите название команды') } +
+ +
+ + + {errors.name_first_participant && alerError('Введите ФИО участника') } +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ +
+
+
+
+
+
+ + ); +}; + +export default RegistrationForm; diff --git a/.history/env_20220704212619.local b/.history/env_20220704212619.local new file mode 100644 index 0000000..e69de29 diff --git a/.history/env_20220704212627.local b/.history/env_20220704212627.local new file mode 100644 index 0000000..a1d837d --- /dev/null +++ b/.history/env_20220704212627.local @@ -0,0 +1,12 @@ +// .env.local + +USER_="crapshr6_robotop" +HOST="crapshr6.beget.tech" +DATABASE="crapshr6_robotop" +PASSWORD="sJ9&alNk" + +MAILSERVER="smtp.beget.com" +MAILNAME="service@vsst.su" +MAILPASS = "&ekS0NPD" + +SITE="http://localhost:3000/api/" \ No newline at end of file diff --git a/.history/pages/api/registration_20220704215825.ts b/.history/pages/api/registration_20220704215825.ts new file mode 100644 index 0000000..c7d69cd --- /dev/null +++ b/.history/pages/api/registration_20220704215825.ts @@ -0,0 +1,20 @@ +import type { NextApiRequest, NextApiResponse } from 'next' +import Insert from "../../server/db/insert"; + +const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +type Data = { + error: string, + data: string, + } + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export default function handler( + req: NextApiRequest, + res: NextApiResponse + ) { + const re = /\s*,\s*/; + const parm = req.body; + Insert(sql, parm.split(re), function(data){ + res.status(200).json(data); + }) + } \ No newline at end of file diff --git a/.history/pages/api/registration_20220704220325.ts b/.history/pages/api/registration_20220704220325.ts new file mode 100644 index 0000000..da73435 --- /dev/null +++ b/.history/pages/api/registration_20220704220325.ts @@ -0,0 +1,20 @@ +import type { NextApiRequest, NextApiResponse } from 'next' +import Insert from "../../server/db/insert"; + +const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +type Data = { + error: string, + data?: any, + } + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export default function handler( + req: NextApiRequest, + res: NextApiResponse + ) { + const re = /\s*,\s*/; + const parm = req.body; + Insert(sql, parm.split(re), function(data){ + return res.status(200).json({data}); + }) + } \ No newline at end of file diff --git a/.history/pages/api/registration_20220704220506.ts b/.history/pages/api/registration_20220704220506.ts new file mode 100644 index 0000000..0d64c8a --- /dev/null +++ b/.history/pages/api/registration_20220704220506.ts @@ -0,0 +1,20 @@ +import type { NextApiRequest, NextApiResponse } from 'next' +import Insert from "../../server/db/insert"; + +const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +type Data = { + error: string, + message: string, + } + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export default function handler( + req: NextApiRequest, + res: NextApiResponse + ) { + const re = /\s*,\s*/; + const parm = req.body; + Insert(sql, parm.split(re), function(message){ + res.status(200).json(message); + }) + } \ No newline at end of file diff --git a/.history/pages/api/registration_20220704220818.ts b/.history/pages/api/registration_20220704220818.ts new file mode 100644 index 0000000..83e1af4 --- /dev/null +++ b/.history/pages/api/registration_20220704220818.ts @@ -0,0 +1,19 @@ +import type { NextApiRequest, NextApiResponse } from 'next' +import Insert from "../../server/db/insert"; + +const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +type Data = { + message: Data[], + } + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export default function handler( + req: NextApiRequest, + res: NextApiResponse + ) { + const re = /\s*,\s*/; + const parm = req.body; + Insert(sql, parm.split(re), function(message){ + res.status(200).json(message); + }) + } \ No newline at end of file diff --git a/.history/pages/api/registration_20220704220843.ts b/.history/pages/api/registration_20220704220843.ts new file mode 100644 index 0000000..3cb374f --- /dev/null +++ b/.history/pages/api/registration_20220704220843.ts @@ -0,0 +1,19 @@ +import type { NextApiRequest, NextApiResponse } from 'next' +import Insert from "../../server/db/insert"; + +const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +type Data = { + message: Data[], + } + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export default function handler( + req: NextApiRequest, + res: NextApiResponse + ) { + const re = /\s*,\s*/; + const parm = req.body; + Insert(sql, parm.split(re), function(message){ + return res.status(200).json(message); + }) + } \ No newline at end of file diff --git a/.history/pages/api/registration_20220704220959.ts b/.history/pages/api/registration_20220704220959.ts new file mode 100644 index 0000000..3cb374f --- /dev/null +++ b/.history/pages/api/registration_20220704220959.ts @@ -0,0 +1,19 @@ +import type { NextApiRequest, NextApiResponse } from 'next' +import Insert from "../../server/db/insert"; + +const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +type Data = { + message: Data[], + } + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export default function handler( + req: NextApiRequest, + res: NextApiResponse + ) { + const re = /\s*,\s*/; + const parm = req.body; + Insert(sql, parm.split(re), function(message){ + return res.status(200).json(message); + }) + } \ No newline at end of file diff --git a/.history/pages/api/registration_20220704221605.ts b/.history/pages/api/registration_20220704221605.ts new file mode 100644 index 0000000..48ae87d --- /dev/null +++ b/.history/pages/api/registration_20220704221605.ts @@ -0,0 +1,21 @@ +import type { NextApiRequest, NextApiResponse } from 'next' +import Insert from "../../server/db/insert"; + +const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +type Data = { + message?: Data[], + name?: Data[] + } + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export default function handler( + req: NextApiRequest, + res: NextApiResponse + ) { + const re = /\s*,\s*/; + const parm = req.body; + Insert(sql, parm.split(re), function(message){ + const name: Data[] = message; + return res.status(200).json(name); + }) + } \ No newline at end of file diff --git a/.history/pages/api/registration_20220704222116.ts b/.history/pages/api/registration_20220704222116.ts new file mode 100644 index 0000000..900de3d --- /dev/null +++ b/.history/pages/api/registration_20220704222116.ts @@ -0,0 +1,21 @@ +import type { NextApiRequest, NextApiResponse } from 'next' +import Insert from "../../server/db/insert"; + +const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +type Data = { + message?: Data[], + name?: Data[] + } + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export default function handler( + req: NextApiRequest, + res: NextApiResponse + ) { + const re = /\s*,\s*/; + const parm = req.body; + Insert(sql, parm.split(re), function(message){ + //const obj: Data = message; + return res.status(200).json(message); + }) + } \ No newline at end of file diff --git a/.history/pages/api/registration_20220704222543.ts b/.history/pages/api/registration_20220704222543.ts new file mode 100644 index 0000000..323189d --- /dev/null +++ b/.history/pages/api/registration_20220704222543.ts @@ -0,0 +1,20 @@ +import type { NextApiRequest, NextApiResponse } from 'next' +import Insert from "../../server/db/insert"; + +const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +type Data = { + message?: Data[], + name?: Data[] + } + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export default function handler( + req: NextApiRequest, + res: NextApiResponse + ) { + const re = /\s*,\s*/; + const parm = req.body; + Insert(sql, parm.split(re), function(message){ + res.status(200).json(message); + }) + } \ No newline at end of file diff --git a/.history/pages/api/registration_20220704222556.ts b/.history/pages/api/registration_20220704222556.ts new file mode 100644 index 0000000..2a1b5f7 --- /dev/null +++ b/.history/pages/api/registration_20220704222556.ts @@ -0,0 +1,17 @@ +import type { NextApiRequest, NextApiResponse } from 'next' +import Insert from "../../server/db/insert"; + +const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export default function handler( + req: NextApiRequest, + res: NextApiResponse + ) { + const re = /\s*,\s*/; + const parm = req.body; + Insert(sql, parm.split(re), function(message){ + res.status(200).json(message); + }) + } \ No newline at end of file diff --git a/.history/pages/registration_20220704214443.tsx b/.history/pages/registration_20220704214443.tsx new file mode 100644 index 0000000..c1a2e59 --- /dev/null +++ b/.history/pages/registration_20220704214443.tsx @@ -0,0 +1,66 @@ +import React, {useEffect, useState} from 'react'; +import Layout from '../components/Layout'; +import RegistrationForm from '../components/RegistrationForm'; +import LoadingTeamsForm from '../components/LoadingTeamsForm'; +import { useSelector } from 'react-redux'; +import { useAppDispatch } from '../redux/store'; +import { fetchUser, selectUserData } from '../redux/user'; +import { ToastContainer, toast } from 'react-toastify'; +import 'react-toastify/dist/ReactToastify.css'; + +export const Registration = (): JSX.Element => { + const dispatch = useAppDispatch(); + const [UserAdd, setUserAdd] = useState(0); + + const UpdateUser = () => { + setUserAdd(UserAdd+1); + toast("Спасибо Ваша команда зарегистрирована"); + } + useEffect(() => { + dispatch( fetchUser() ); + }, [UserAdd]); + + const { user_items } = useSelector(selectUserData); + const User = user_items.map((obj, index) => ); + return ( + + + +
+
+

Зарегистрированные команды

+
+ + + + + + + + + + + + { User } + +
+ Название команды + + ФИО тренера + + Учебное заведение + + ФИО участников + + Возрастная группа +
+
+
+ ); +}; + +export default Registration; diff --git a/.history/server/db/select_20220704222642.ts b/.history/server/db/select_20220704222642.ts new file mode 100644 index 0000000..4f57240 --- /dev/null +++ b/.history/server/db/select_20220704222642.ts @@ -0,0 +1,13 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +const pool = require("./connect"); +import {QueryError} from 'mysql2'; + +interface definitionInterface{ + (message:string):void; +} +export default function Select(sql: string, callback: definitionInterface) { + pool.query(sql, (err: QueryError, rows: string) => { + callback(rows); + pool.releaseConnection(pool); +}); +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..910613e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cSpell.words": [ + "fdfdf" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 7a90798..fb15936 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,28 @@ -# RoboTop - Сайт для робототехнического фестиваля +# RoboTop сайт робототехнического фестиваля -Next.js \ No newline at end of file +A Next.js starter for your next blog or personal site. Built with: + +- [Typescript](https://www.typescriptlang.org/) +- Write posts with [MDX](https://mdxjs.com/) +- Style with [Tailwind CSS](https://tailwindcss.com/) +- Linting with [ESLint](https://eslint.org/) +- Formatting with [Prettier](https://prettier.io/) +- Linting, typechecking and formatting on by default using [`husky`](https://github.com/typicode/husky) for commit hooks +- Testing with [Jest](https://jestjs.io/) and [`react-testing-library`](https://testing-library.com/docs/react-testing-library/intro) + +## Getting Started + +```bash +git clone https://github.com/ChangoMan/nextjs-typescript-mdx-blog.git +cd nextjs-typescript-mdx-blog + +yarn install +# or +npm install + +yarn dev +# or +npm run dev +``` + +Your new site will be up at http://localhost:3000/ diff --git a/components/RegistrationForm.tsx b/components/RegistrationForm.tsx index 05e6c54..baded70 100644 --- a/components/RegistrationForm.tsx +++ b/components/RegistrationForm.tsx @@ -5,9 +5,9 @@ interface IFormInputs { firstName: string lastName: string coach_telefon_number: string + body: string[] } - const alerError = (props) => { return

{props}

} @@ -17,7 +17,7 @@ export const RegistrationForm = (props): JSX.Element => { const { register, handleSubmit, reset, formState: { errors } } = useForm(); const onSubmit: SubmitHandler = data => { - fetch('/api/registration', { method: 'POST', body: Object.values(data) }) + fetch('/api/registration', { method: 'POST', body: JSON.stringify(Object.values(data)) }) .then(props.updateData(2)) reset(); } @@ -69,7 +69,7 @@ export const RegistrationForm = (props): JSX.Element => { Email тренера ()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ })} + {...register("trainer_mail",{ required: true, maxLength: 80, pattern: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ })} placeholder="you@example.com" className="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" /> diff --git a/env.local b/env.local new file mode 100644 index 0000000..a1d837d --- /dev/null +++ b/env.local @@ -0,0 +1,12 @@ +// .env.local + +USER_="crapshr6_robotop" +HOST="crapshr6.beget.tech" +DATABASE="crapshr6_robotop" +PASSWORD="sJ9&alNk" + +MAILSERVER="smtp.beget.com" +MAILNAME="service@vsst.su" +MAILPASS = "&ekS0NPD" + +SITE="http://localhost:3000/api/" \ No newline at end of file diff --git a/pages/api/registration.ts b/pages/api/registration.ts index 1669c32..2a1b5f7 100644 --- a/pages/api/registration.ts +++ b/pages/api/registration.ts @@ -2,18 +2,16 @@ import type { NextApiRequest, NextApiResponse } from 'next' import Insert from "../../server/db/insert"; const sql = "INSERT INTO members (name_team_coach, coach_telefon_number, trainer_mail, city_team, training_institution_team, team_name, name_first_participant, first_partial_class, name_second_participant, second_class, name_third_party, third_part_class) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; -type Data = { - error: string, - } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export default function handler( req: NextApiRequest, - res: NextApiResponse + res: NextApiResponse ) { const re = /\s*,\s*/; const parm = req.body; - Insert(sql, parm.split(re), function(data){ - res.status(200).json(data); + Insert(sql, parm.split(re), function(message){ + res.status(200).json(message); }) } \ No newline at end of file diff --git a/pages/registration.tsx b/pages/registration.tsx index 3c94809..c1a2e59 100644 --- a/pages/registration.tsx +++ b/pages/registration.tsx @@ -20,7 +20,7 @@ export const Registration = (): JSX.Element => { dispatch( fetchUser() ); }, [UserAdd]); - const { user_items, user_status } = useSelector(selectUserData); + const { user_items } = useSelector(selectUserData); const User = user_items.map((obj, index) => ); return ( { + pool.query(sql, (err: QueryError, rows: string) => { callback(rows); pool.releaseConnection(pool); });