Skip to content

Commit

Permalink
Merge pull request #12 from MarkMelior/feature/VEES-20-base-api-mock
Browse files Browse the repository at this point in the history
VEES-20 | Сделать базу api на моках
  • Loading branch information
MarkMelior authored Jan 12, 2025
2 parents f9be6d2 + 77baeb0 commit fe4d9b3
Show file tree
Hide file tree
Showing 56 changed files with 1,274 additions and 274 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BASE_API_URL=http://localhost:3000
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@

![Next.js 15](https://img.shields.io/badge/Next.js_15-000?logo=nextdotjs&logoColor=fff&style=for-the-badge)
![React 19](https://img.shields.io/badge/React_19-20232A?style=for-the-badge&logo=react&logoColor=61DAFB)
![Zustand](https://img.shields.io/badge/Zustand-FFB441?style=for-the-badge&logo=ziggo&logoColor=black)
![TypeScript 5](https://img.shields.io/badge/TypeScript_5-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
![Module SCSS](https://img.shields.io/badge/module_scss-CC6699?style=for-the-badge&logo=sass&logoColor=white)
![Feature-Sliced Design](https://img.shields.io/badge/FSD-3481FE?style=for-the-badge&logo=flat&logoColor=white)
![GIT](https://img.shields.io/badge/CI_/_CD-000000?style=for-the-badge&logo=github&logoColor=white)
![ESLint](https://img.shields.io/badge/ESLint-4B32C3?style=for-the-badge&logo=ESLint&logoColor=white)
![ESLint 9](https://img.shields.io/badge/ESLint_9-4B32C3?style=for-the-badge&logo=ESLint&logoColor=white)
![stylelint](https://img.shields.io/badge/stylelint-263238?style=for-the-badge&logo=stylelint&logoColor=white)
![TailwindCSS](https://img.shields.io/badge/Tailwind_CSS-38B2AC?style=for-the-badge&logo=tailwind-css&logoColor=white)
![Figma](https://img.shields.io/badge/Figma-F24E1E?style=for-the-badge&logo=figma&logoColor=white)
Expand All @@ -41,7 +42,8 @@
- Папки с компонентами, как и сами компоненты, должны быть в `PascalCase`. Утилиты, моки, типы и т.п. в `kebab-case`;
- Наименование `.module.scss` должно начинаться с маленькой буквы, а компонента `.tsx` с большой;
- Если в слайсе, кроме `Name.tsx`, `index.ts` и `name.module.scss` ничего нет, то не нужно создавать сегмент `ui/`;
- Серверные компоненты и типы экспортируем как обычно, через `index.ts`. Клиентские компоненты (`'use client'`) экспортируем через `client.ts`.
- Серверные компоненты и типы экспортируем как обычно, через `index.ts`. Клиентские компоненты (`'use client'`) экспортируем через `client.ts`;
- Наименование типов. Данные получаемые с сервера: `Response`. Данные отправляемые на сервер: `Dto`.

#### Git

Expand Down Expand Up @@ -81,6 +83,8 @@

### 📂⚡️ Архитектура проекта

`!` Сейчас большая часть компонентов - клиентские. Это связано с тем, что серверные компоненты не имеют доступа к хранилищу браузера. На этапе MVP мы всё храним в IndexedDB. В будущем, с появлением базы данных, мы перейдём на полноценный серверный рендеринг.

Проект написан в соответствии с архитектурной методологией [Feature-Sliced Design](https://feature-sliced.design/docs/get-started/tutorial) и [AppRouter](https://nextjs.org/docs/app) Next.js 15.

- [app](/src/app/) - [AppRouter](https://nextjs.org/docs/app);
Expand Down
6 changes: 3 additions & 3 deletions docs/naming-conventions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- Vees — Тренировка
- All Vees — Все тренировки
- Exercise — Упражнение
- Muscle — Группа мышц
- Vees Template - Шаблон тренировки
- Approach - Подход
- Exercise Template - Шаблон упражнений (вторник, среда и т.п.)
- Exercise Group - Группа упражнений (спина, бицепс и т.п.)
- Approach - Подход
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
"dependencies": {
"axios": "^1.7.9",
"clsx": "^2.1.1",
"localforage": "^1.10.0",
"nanoid": "^5.0.9",
"next": "15.1.0",
"next-themes": "^0.4.4",
"react": "^19.0.0",
"react-dom": "^19.0.0"
"react-dom": "^19.0.0",
"zustand": "^5.0.3"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
Expand Down
9 changes: 9 additions & 0 deletions persist-storage/exercise-groups.response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import localforage from 'localforage';

import { StorageKey } from '@/shared/constants';

import type { IExerciseGroupsDto } from '@/entities/exercise-groups';

export const exerciseGroupsResponse = async () => (
await localforage.getItem<IExerciseGroupsDto[]>(StorageKey.EXERCISE_GROUP)
);
9 changes: 9 additions & 0 deletions persist-storage/exercise-templates.response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import localforage from 'localforage';

import { StorageKey } from '@/shared/constants';

import type { IExerciseTemplatesDto } from '@/entities/exercise-templates';

export const exerciseTemplatesResponse = async () => (
await localforage.getItem<IExerciseTemplatesDto[]>(StorageKey.EXERCISE_TEMPLATE)
);
86 changes: 86 additions & 0 deletions persist-storage/mock/EXERCISE_GROUP.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import type { IExerciseGroupsDto } from '@/entities/exercise-groups';

export const EXERCISE_GROUP: IExerciseGroupsDto[] = [
{
color: '#FAC938',
exercises: [
{
id: '64f5d700-2ae9-4f53-8d9c-43fe90f63d32',
name: 'Горизонтальная тяга',
},
{
id: 'b8139a33-a755-4e4f-a430-8da4993c66b9',
name: 'Подтягивания с доп. весом',
},
{
id: 'b75a4e08-0fec-4edf-9fc4-6a966a20aa06',
name: 'Тяга штанги к поясу',
},
],
id: '09d399a8-ecd7-46e9-a7ef-1498a579c331',
name: 'Спина',
},
{
color: '#FA4838',
exercises: [
{
id: '147244e6-ab19-4bd2-bb2f-28e6d4145127',
name: 'Разведения в кроссовере на одну руку',
},
{
id: '0f9e9776-71d1-40d5-bf55-e9ec7e0dbdda',
name: 'Разведение гантелей в стороны',
},
],
id: '4463b999-4b96-472c-8f15-823c41630631',
name: 'Средние дельты',
},
{
color: '#00FF80',
exercises: [
{
id: '39ce3084-d7bc-471d-bdd4-c8870349dcef',
name: 'Брусья с доп. весом',
},
{
id: '77f6ecf4-9452-4f47-8fed-5c68881a19d4',
name: 'Жим лёжа узким хватом',
},
{
id: '9ae9be94-3514-487a-920f-802d2a76f804',
name: 'Французский жим лёжа',
},
],
id: '83a54707-d2bd-4c7b-8b07-5ae0a8b1c300',
name: 'Трицепс',
},
{
color: '#1A80E5',
exercises: [
{
id: '1638eeaa-164b-4e3c-ba1c-68087a4385a8',
name: 'Жим штанги',
},
{
id: 'd3dce3ed-cedf-4d1f-b907-927e24314f02',
name: 'Жим гантелей в наклоне',
},
{
id: '24233635-cbea-41bc-8669-6f07dbbc21a1',
name: 'Жим штанги в наклоне',
},
{
id: '7e040e20-61e0-4c2c-818a-192df8fc2cae',
name: 'Брусья с доп. весом',
},
],
id: 'ebc58f8d-3191-4685-8857-8bd40c834813',
name: 'Грудь',
},
{
color: '#9B693B',
exercises: [],
id: 'bdc4677b-5cec-40b0-806a-d9d87c04f89b',
name: 'Квадрицепсы',
},
];
26 changes: 26 additions & 0 deletions persist-storage/mock/EXERCISE_TEMPLATE.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { IExerciseTemplatesDto } from '@/entities/exercise-templates';

export const EXERCISE_TEMPLATE: IExerciseTemplatesDto[] = [
{
color: '#FA4838',
exercisesIds: [
'147244e6-ab19-4bd2-bb2f-28e6d4145127', // Разведения в кроссовере на одну руку
'd3dce3ed-cedf-4d1f-b907-927e24314f02', // Жим гантелей в наклоне
'9ae9be94-3514-487a-920f-802d2a76f804', // Французский жим лёжа
'64f5d700-2ae9-4f53-8d9c-43fe90f63d32', // Горизонтальная тяга
],
id: 'template-tuesday',
name: 'Вторник',
},
{
color: '#00FF80',
exercisesIds: [
'24233635-cbea-41bc-8669-6f07dbbc21a1', // Жим штанги в наклоне
'9ae9be94-3514-487a-920f-802d2a76f804', // Французский жим лёжа
'b8139a33-a755-4e4f-a430-8da4993c66b9', // Подтягивания с доп. весом
'147244e6-ab19-4bd2-bb2f-28e6d4145127', // Разведения в кроссовере на одну руку
],
id: 'template-saturday',
name: 'Суббота',
},
];
26 changes: 26 additions & 0 deletions persist-storage/mock/VEES_ACTIVE.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { IVeesDto } from '@/entities/vees';

export const VEES_ACTIVE: IVeesDto = {
duration: {
from: '2025-01-12T10:00:00',
to: '2025-01-12T11:00:00',
},
exercises: [
{
comment: 'Добавить больше подходов в следующий раз',
id: 'b75a4e08-0fec-4edf-9fc4-6a966a20aa06',
result: [{ count: 10, weight: 20 }],
},
{
comment: 'Сменить угол скамьи',
id: 'd3dce3ed-cedf-4d1f-b907-927e24314f02',
result: [{ count: 12, weight: 25 }],
},
{
comment: 'Отлично справился',
id: '9ae9be94-3514-487a-920f-802d2a76f804',
result: [{ count: 15, weight: 15 }],
},
],
exerciseTemplateId: 'template-tuesday',
};
112 changes: 112 additions & 0 deletions persist-storage/mock/VEES_LIST.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import type { IVeesDto } from '@/entities/vees';

export const VEES_LIST: IVeesDto[] = [
{
duration: {
from: '2025-01-10T10:00:00',
to: '2025-01-10T11:00:00',
},
exercises: [
{
id: '147244e6-ab19-4bd2-bb2f-28e6d4145127', // Разведения в кроссовере на одну руку
result: [
{ count: 20, weight: 10 },
{ count: 10, weight: 20 },
],
},
{
id: '9ae9be94-3514-487a-920f-802d2a76f804', // Французский жим лёжа
result: [{ count: 12, weight: 10 }],
},
],
exerciseTemplateId: 'template-tuesday',
},
{
duration: {
from: '2025-01-10T15:00:00',
to: '2025-01-10T16:34:00',
},
exercises: [
{
id: '147244e6-ab19-4bd2-bb2f-28e6d4145127', // Разведения в кроссовере на одну руку
result: [
{ count: 10, weight: 20 },
{ count: 20, weight: 10 },
],
},
{
id: '9ae9be94-3514-487a-920f-802d2a76f804', // Французский жим лёжа
result: [{ count: 10, weight: 10 }],
},
],
exerciseTemplateId: 'template-tuesday',
},
{
duration: {
from: '2025-01-08T10:00:00',
to: '2025-01-08T11:00:00',
},
exercises: [
{
id: '24233635-cbea-41bc-8669-6f07dbbc21a1', // Жим штанги в наклоне
result: [{ count: 10, weight: 50 }],
},
{
id: 'b8139a33-a755-4e4f-a430-8da4993c66b9', // Подтягивания с доп. весом
result: [{ count: 8, weight: 10 }],
},
],
exerciseTemplateId: 'template-saturday',
},
{
duration: {
from: '2025-01-05T10:00:00',
to: '2025-01-05T11:00:00',
},
exercises: [
{
id: '7e040e20-61e0-4c2c-818a-192df8fc2cae', // Брусья с доп. весом
result: [{ count: 12, weight: 15 }],
},
{
id: '0f9e9776-71d1-40d5-bf55-e9ec7e0dbdda', // Разведение гантелей в стороны
result: [{ count: 10, weight: 5 }],
},
],
exerciseTemplateId: 'template-saturday',
},
{
duration: {
from: '2025-01-03T09:00:00',
to: '2025-01-03T10:00:00',
},
exercises: [
{
id: '39ce3084-d7bc-471d-bdd4-c8870349dcef', // Брусья с доп. весом
result: [{ count: 10, weight: 10 }],
},
{
id: 'd3dce3ed-cedf-4d1f-b907-927e24314f02', // Жим гантелей в наклоне
result: [{ count: 8, weight: 25 }],
},
],
exerciseTemplateId: 'template-tuesday',
},
{
duration: {
from: '2025-01-01T08:30:00',
to: '2025-01-01T09:30:00',
},
exercises: [
{
id: 'b75a4e08-0fec-4edf-9fc4-6a966a20aa06', // Тяга штанги к поясу
result: [{ count: 10, weight: 40 }],
},
{
id: '1638eeaa-164b-4e3c-ba1c-68087a4385a8', // Жим штанги
result: [{ count: 12, weight: 60 }],
},
],
exerciseTemplateId: 'template-saturday',
},
];
4 changes: 4 additions & 0 deletions persist-storage/mock/copy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
await localforage.setItem(StorageKey.VEES_ACTIVE, VEES_ACTIVE);
await localforage.setItem(StorageKey.EXERCISE_GROUP, EXERCISE_GROUP);
await localforage.setItem(StorageKey.EXERCISE_TEMPLATE, EXERCISE_TEMPLATE);
await localforage.setItem(StorageKey.VEES_LIST, VEES_LIST);
Loading

0 comments on commit fe4d9b3

Please sign in to comment.