Skip to content

Commit 08900db

Browse files
authored
Merge pull request #14 from codee-sh/feat/add-more-fields-responsive
feat/add-more-fields-responsive
2 parents 5bd0086 + cc1c35f commit 08900db

122 files changed

Lines changed: 10913 additions & 1194 deletions

File tree

Some content is hidden

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

.ai/specs/2026-06-16-share-links.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ src/
4646
│ └── share-links/
4747
│ └── index.ts # new collection
4848
├── app/
49-
│ ├── (payload)/
50-
│ │ └── admin/modules/share-link-url/
51-
│ │ ├── share-link-url.tsx # custom UI component (admin)
52-
│ │ └── index.ts
5349
│ └── [locale]/(frontend)/
5450
│ └── share/
5551
│ └── [token]/
5652
│ └── page.tsx # public share page
57-
└── loaders/
58-
└── share-link-loader.ts # token validation + data fetching
53+
└── modules/
54+
└── sharing/
55+
├── admin/share-link-url/
56+
│ ├── share-link-url.tsx # custom UI component (admin)
57+
│ └── index.ts
58+
└── server/
59+
└── load-share-link.ts # token validation + data fetching
5960
```
6061

6162
### Modified files
@@ -89,7 +90,7 @@ src/
8990

9091
## Token Validation (loader)
9192

92-
`loadShareLink(token: string)` in `src/loaders/share-link-loader.ts`:
93+
`loadShareLink(token: string)` in `src/modules/sharing/server/load-share-link.ts`:
9394

9495
1. Query `share-links` with `where: { token: { equals: token } }`, `overrideAccess: true`, `limit: 1`
9596
2. If no document found → return `null`
@@ -166,16 +167,16 @@ Build the loader, the share page, and any read-only variants of existing workout
166167

167168
### Phase 2
168169

169-
- [ ] Create `src/app/(payload)/admin/modules/share-link-url/share-link-url.tsx` — client component using `useFormFields` to read `token`, compose URL from `NEXT_PUBLIC_SERVER_URL`, render copy button
170-
- [ ] Create `src/app/(payload)/admin/modules/share-link-url/index.ts` — re-export
170+
- [ ] Create `src/modules/sharing/admin/share-link-url/share-link-url.tsx` — client component using `useFormFields` to read `token`, compose URL from `NEXT_PUBLIC_SERVER_URL`, render copy button
171+
- [ ] Create `src/modules/sharing/admin/share-link-url/index.ts` — re-export
171172
- [ ] Wire component into `shareUrl` ui field in the collection
172173
- [ ] Run `yarn generate:importmap`
173174
- [ ] Run `yarn build` — verify no type errors
174175

175176
### Phase 3
176177

177178
- [ ] Add `share` namespace keys to `messages/pl.json` and `messages/en.json`
178-
- [ ] Create `src/loaders/share-link-loader.ts`
179+
- [ ] Create `src/modules/sharing/server/load-share-link.ts`
179180
- [ ] Create `src/app/[locale]/(frontend)/share/[token]/page.tsx`
180181
- [ ] Adapt plan components to support `readOnly` prop (hide set forms, logging buttons) — or create a read-only wrapper
181182
- [ ] Run `yarn build` — verify no type errors

.ai/specs/2026-06-20-exercise-client-note.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Today a client can only add a note **per set** (`set-logs.note`). We add a new l
2424

2525
## Problem Statement
2626

27-
In the workout tracker a client logs exercise execution as sets (`set-logs`). Each set can have its own note (`set-logs.note`, the field in [SeriesForm](../../src/components/workout/series-form/series-form.tsx)). What is missing is a note **for the whole exercise** — an annotation like "shoulders felt weak today, lower the weight next time" that applies to the exercise as a whole, not to one specific set.
27+
In the workout tracker a client logs exercise execution as sets (`set-logs`). Each set can have its own note (`set-logs.note`, the field in [SeriesForm](../../src/modules/training/components/series-form/series-form.tsx)). What is missing is a note **for the whole exercise** — an annotation like "shoulders felt weak today, lower the weight next time" that applies to the exercise as a whole, not to one specific set.
2828

2929
The note cannot live in the plan: `workout-exercise-rows` has `update: isAdmin` — clients do not write to the template. It must therefore be created in the log layer, tied to the **(session, exercise)** pair.
3030

@@ -111,7 +111,7 @@ src/
111111
│ │ └── index.ts # NEW collection
112112
│ └── index.ts # + re-export ExerciseLogs
113113
├── payload.config.ts # + register in collections[]
114-
├── components/workout/
114+
├── modules/training/components/
115115
│ ├── workout-tracker/
116116
│ │ ├── workout-tracker.tsx # pass note + onSaveNote to the card
117117
│ │ └── hooks/
@@ -192,7 +192,7 @@ useWorkoutSession (hook)
192192
└── update local state
193193
```
194194

195-
UI: [workout-tracker.tsx](../../src/components/workout/workout-tracker/workout-tracker.tsx) passes `note` + `onSaveNote` to [exercise-card.tsx](../../src/components/workout/exercise-card/exercise-card.tsx), which renders the note in the exercise header (distinct from the plan note) and — when `!readOnly` — exposes an editable field.
195+
UI: [workout-tracker.tsx](../../src/modules/training/components/workout-tracker/workout-tracker.tsx) passes `note` + `onSaveNote` to [exercise-card.tsx](../../src/modules/training/components/exercise-card/exercise-card.tsx), which renders the note in the exercise header (distinct from the plan note) and — when `!readOnly` — exposes an editable field.
196196

197197
---
198198

@@ -220,13 +220,13 @@ Render and edit the note in `ExerciseCard`, strings in `pl.json`/`en.json`, visi
220220
- [x] `yarn payload migrate` — run by the user (DB-mutating step).
221221

222222
### Phase 2 — Runtime
223-
- [x] [use-workout-session.ts](../../src/components/workout/workout-tracker/hooks/use-workout-session.ts): load `exercise-logs` by `session` (parallel with set-logs), add `exerciseNotes` state.
223+
- [x] [use-workout-session.ts](../../src/modules/training/components/workout-tracker/hooks/use-workout-session.ts): load `exercise-logs` by `session` (parallel with set-logs), add `exerciseNotes` state.
224224
- [x] Add the `noteForRow(rowId)` selector and the `saveExerciseNote(ex, note)` mutation (upsert).
225225
- [x] Expose both in the hook's returned API.
226226

227227
### Phase 3 — UI + i18n
228-
- [x] [workout-tracker.tsx](../../src/components/workout/workout-tracker/workout-tracker.tsx): pass `clientNote` + `onSaveNote` to `ExerciseCard`.
229-
- [x] [exercise-card.tsx](../../src/components/workout/exercise-card/exercise-card.tsx): render the client note in the header (new `exercise-note` subcomponent) + allow editing when `!readOnly`.
228+
- [x] [workout-tracker.tsx](../../src/modules/training/components/workout-tracker/workout-tracker.tsx): pass `clientNote` + `onSaveNote` to `ExerciseCard`.
229+
- [x] [exercise-card.tsx](../../src/modules/training/components/exercise-card/exercise-card.tsx): render the client note in the header (new `exercise-note` subcomponent) + allow editing when `!readOnly`.
230230
- [x] Strings (`addNote`, `notePlaceholder`, `saveNote`, `cancelNote`) in `messages/pl.json` + `messages/en.json`.
231231
- [x] [export-seed.ts](../../src/scripts/export-seed.ts): comment updated (logs already excluded via the allow-list).
232232
- [x] Typecheck (`tsc --noEmit`) + lint pass.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'training-app': minor
3+
---
4+
5+
Add plan and workout structure navigation in the admin panel and fix exercise catalog selection in the structure editor.

.changeset/exercise-target-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'training-app': minor
3+
---
4+
5+
Allow workout exercises to use either repetition or duration targets.

.changeset/green-sides-log.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'training-app': minor
3+
---
4+
5+
Record left and right weights and repetitions separately for strength sets and exercise defaults.

.changeset/group-protocol-meta.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'training-app': minor
3+
---
4+
5+
Show group protocol details above exercises in workout tracking.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'training-app': patch
3+
---
4+
5+
Reorganize training and sharing code into domain-oriented business modules. Move frontend components, server queries, and Payload Admin extensions behind explicit module boundaries without changing user-facing behavior.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'training-app': patch
3+
---
4+
5+
Standardize rest duration labels as `Rest(s)` in workout group configuration.

AGENTS.md

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ Operational guide for AI agents working in this repository.
77
## Before Writing Code
88

99
- Write everything in English: code, comments, variable names, documentation.
10+
- Do not implement code, schema, migration, script, configuration, or documentation changes unless the user explicitly authorizes implementation with "wdrażamy" or an equivalent clear instruction. Analysis, investigation, and recommendations do not authorize changes.
1011
- Check `.ai/specs/` before coding any non-trivial feature.
1112
- Skills are installed in `.claude/skills/` (Claude Code) and `.agents/skills/` (Codex). `.agents/skills/` is the local source of truth — edit a skill **only** there, then run `ags push-skill` to propagate it to the source repo (it also syncs the `.claude/skills/` copy). See Installing skills.
1213
- Prefer minimal, focused changes. Do not refactor code outside the task scope.
13-
- Run `yarn build` after every implementation to catch type errors.
14+
- Do not run `yarn build` automatically after implementation. Run it only when the user explicitly asks.
1415
- Comment and naming conventions are defined in the `code-style` skill. Load it before writing or reviewing TypeScript.
1516

1617
---
@@ -23,7 +24,7 @@ Match the task to the table before starting. A single task often maps to multipl
2324
|---|---|
2425
| Creating a new collection or extending the schema | Load skill `payload-build-collections` |
2526
| Adding a custom admin view, tab, or field UI | Load skill `payload-build-modules` |
26-
| Building a front-end component or page (`src/components`, `(frontend)`) | Load skill `payload-frontend-build-components` |
27+
| Building a front-end component or page (`src/components`, `src/modules/*/components`, `(frontend)`) | Load skill `payload-frontend-build-components` |
2728
| Debugging hooks, queries, access control, transactions | Load skill `payload` |
2829
| Security review, or adding/modifying auth, access control, uploads, CORS/CSRF, headers | Load skill `payload-security`; keep `.ai/audits/security-audit.md` current |
2930
| Writing questions for a client or stakeholder | Load skill `writing-questions` |
@@ -97,16 +98,19 @@ src/
9798
│ └── (payload)/ # Payload admin routes and API
9899
├── collections/ # One folder per collection (index.ts + optional hooks.ts, types.ts)
99100
├── components/
100-
│ ├── common/
101-
│ ├── ui/
102-
│ └── workout/
101+
│ ├── common/ # App-wide, non-domain components
102+
│ └── ui/ # Domain-agnostic UI primitives
103103
├── data/ # Static/seed data
104104
├── i18n/ # next-intl config
105-
├── lib/ # Utilities and SDK client
106-
├── loaders/ # Server-side data fetching
105+
├── lib/ # Business-agnostic utilities and SDK client
107106
├── migrations/ # Payload DB migrations (auto-generated)
107+
├── modules/ # Vertical business modules
108+
│ └── <module>/
109+
│ ├── <area>/ # Domain area (types, constants, rules)
110+
│ ├── components/ # Module-owned frontend components
111+
│ ├── server/ # Server-only queries and use cases
112+
│ └── admin/ # Module-owned Payload Admin UI
108113
├── scripts/ # One-off CLI scripts
109-
├── types/
110114
├── payload-types.ts # Auto-generated — do not edit
111115
└── payload.config.ts
112116
.claude/skills/ # Skills for Claude Code
@@ -118,19 +122,82 @@ src/
118122

119123
---
120124

125+
## Module Architecture
126+
127+
- `src/modules/` is organized by business capability, not by Payload collection. A module
128+
is a vertical slice that may own domain rules, frontend components, server queries, and
129+
Payload Admin UI.
130+
- Closely related concepts belong to areas inside one module. For example, `training`
131+
contains `exercises`, `plans`, and `logs`; do not create a separate top-level module for
132+
every table or entity.
133+
- Keep `src/app/` thin: route files compose module entry points but do not own feature
134+
implementations. Modules must never import from `src/app/`.
135+
- Keep Payload `CollectionConfig`, fields, hooks, access control, relationships, and
136+
indexes in `src/collections/`. Collections may import only client-safe domain APIs from
137+
modules, never module components, admin UI, or server entry points.
138+
- Put domain-specific React components under `src/modules/<module>/components/`. Keep only
139+
domain-agnostic primitives in `src/components/ui/` and cross-module application UI in
140+
`src/components/common/`.
141+
- Put server-side queries and use cases under an explicit `server/` entry point and add
142+
`import 'server-only'`. Do not re-export server code from a client-safe module barrel.
143+
- Put Payload Admin implementations under `src/modules/<module>/admin/<feature>/`.
144+
Collection configuration must reference the exact component file and the import map
145+
must be regenerated after a path changes.
146+
- Use `types.ts` only for types and interfaces, and `constants.ts` only for constants and
147+
declarative configuration. Name operation files after their responsibility; do not add
148+
generic `utils.ts`, `helpers.ts`, or `models.ts` files.
149+
- Code outside a domain area must use its public `index.ts`. Environment-specific APIs use
150+
explicit subpaths such as `@/modules/training/plans/server` or
151+
`@/modules/training/components/workout-plans`.
152+
- Cross-module dependencies must use public entry points, remain one-directional, and
153+
stay cycle-free. For example, `sharing` may use the public `training/plans/server` API;
154+
`training` must not depend back on `sharing`.
155+
- Keep only business-agnostic technical functions and SDK clients in `src/lib/`.
156+
157+
---
158+
159+
## Payload-Generated Types
160+
161+
- `src/payload-types.ts` is generated by Payload from collection, field, global, and
162+
`payload.config.ts` definitions. Never edit it manually; regenerate it with
163+
`yarn generate:types`.
164+
- A type declared in a module may use the same name as a generated Payload type. Types
165+
exported from different files do not conflict merely because their names match.
166+
- A naming conflict occurs only when two types with the same local name are imported
167+
into the same scope. Alias the imports when both representations are needed, for
168+
example `Workout as PayloadWorkout` and `Workout as PlanWorkout`.
169+
- Name module-owned types according to their domain role. Do not add prefixes or
170+
suffixes solely to avoid a same-name type exported by another module.
171+
172+
---
173+
121174
## Key Commands
122175

123176
```bash
124177
yarn dev # start dev server
125-
yarn build # production build — run after every implementation
126-
yarn payload migrate # run pending DB migrations
178+
yarn build # production build - run only when explicitly requested
179+
yarn payload migrate:create # generate a migration after a schema change - run manually
180+
yarn payload migrate # run pending DB migrations - run manually
127181
yarn generate:types # regenerate payload-types.ts
128182
yarn generate:importmap # regenerate admin import map (after adding custom views)
129183
yarn seed # seed demo data
130184
yarn lint # ESLint
131185
npx skills add <src> -a claude-code -a codex --copy # install skills
132186
```
133187

188+
## Database Migrations
189+
190+
- Generate migrations with `yarn payload migrate:create` after every schema change.
191+
- Maintainers run `yarn payload migrate:create` and `yarn payload migrate` manually. Agents must not run either command.
192+
- Agents must never create migration files manually or edit Payload-generated migration files.
193+
- Keep Payload-generated schema migrations in their generated form. Do not add manual SQL or data updates to them.
194+
195+
## Data Backfills
196+
197+
- Implement every data backfill as a separate, idempotent script through the Payload Local API.
198+
- Do not add data backfill SQL to Payload-generated schema migrations.
199+
- Maintainers run backfill scripts manually. Agents must not run them.
200+
134201
---
135202

136203
## Release

0 commit comments

Comments
 (0)