From edf3c11ac2d61965e4b4fb99f5706504205805aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 22:56:15 +0000 Subject: [PATCH 1/3] Initial plan From 19bc81437fb3d08aa79de6d5fc33160e63bb3127 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 23:08:34 +0000 Subject: [PATCH 2/3] feat(E6): tutor onboarding, approval workflow, and admin tutor directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Migration: tutor_profiles, tutor_subjects, tutor_availability + RLS - Tutor profile form with subjects×levels, availability grid, bio, timezone - Server action to save/update tutor profile (upsert pattern) - Admin approve/revoke server actions with audit log - Admin tutor directory (/admin/tutors) with status/subject/level filters - Admin tutor detail page (/admin/tutors/[id]) - Shared fetchApprovedTutors() query helper for E7 matching - Updated admin nav and README Closes #37 #38 #39 #40 #41 #42 #43 Co-authored-by: Taleef7 <89072337+Taleef7@users.noreply.github.com> --- README.md | 10 +- app/admin/layout.tsx | 6 + app/admin/tutors/TutorActions.tsx | 63 ++++ app/admin/tutors/TutorFilters.tsx | 71 ++++ app/admin/tutors/[id]/page.tsx | 189 ++++++++++ app/admin/tutors/actions.ts | 94 +++++ app/admin/tutors/page.tsx | 230 +++++++++++- app/tutor/profile/TutorProfileForm.tsx | 339 ++++++++++++++++++ app/tutor/profile/actions.ts | 56 +++ app/tutor/profile/page.tsx | 95 ++++- lib/services/matching.ts | 62 +++- lib/validators/tutor.ts | 30 ++ .../20260224000002_create_tutor_tables.sql | 102 ++++++ 13 files changed, 1343 insertions(+), 4 deletions(-) create mode 100644 app/admin/tutors/TutorActions.tsx create mode 100644 app/admin/tutors/TutorFilters.tsx create mode 100644 app/admin/tutors/[id]/page.tsx create mode 100644 app/admin/tutors/actions.ts create mode 100644 app/tutor/profile/TutorProfileForm.tsx create mode 100644 app/tutor/profile/actions.ts create mode 100644 lib/validators/tutor.ts create mode 100644 supabase/migrations/20260224000002_create_tutor_tables.sql diff --git a/README.md b/README.md index e891237..7a4d46a 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,14 @@ Open [http://localhost:3000](http://localhost:3000). You'll see the CorvEd landi | **Admin: mark payment rejected** | ✅ Updates `payments.status → rejected` with optional rejection note, writes audit log | | **DB: packages + payments tables** | ✅ `supabase/migrations/20260224000001_create_packages_payments.sql` — packages (tier_sessions 8/12/20, start/end date, sessions_total/used, status), payments (amount_pkr, method, reference, proof_path, rejection_note, verified_by/at), audit_logs; all with RLS | | **Pricing config** | ✅ `lib/config/pricing.ts` — `PACKAGES` array (8/12/20 tiers, PKR prices, typicalFrequency) + `PAYMENT_INSTRUCTIONS` (bank details, reference format) | -| Sessions | 🚧 Coming in E6–E10 | +| **Tutor application form** | ✅ `app/tutor/profile/page.tsx` — tutor can fill in bio, timezone, subjects × levels (O/A checkboxes), weekly availability grid; saves to `tutor_profiles`, `tutor_subjects`, `tutor_availability`; shows pending/approved status badge | +| **Admin: tutor directory** | ✅ `app/admin/tutors/page.tsx` — lists all tutors with status, subjects, levels, timezone; filter by status (pending/approved), subject, level; Approve and Revoke buttons | +| **Admin: tutor detail page** | ✅ `app/admin/tutors/[id]/page.tsx` — full tutor profile including bio, all subjects × levels, availability windows, WhatsApp number; approve/revoke controls | +| **Tutor approval workflow** | ✅ `app/admin/tutors/actions.ts` — `approveTutor` sets `approved = true`; `revokeTutorApproval` sets `approved = false`; both write audit log entries | +| **DB: tutor tables** | ✅ `supabase/migrations/20260224000002_create_tutor_tables.sql` — `tutor_profiles` (approved, bio, timezone), `tutor_subjects` (subject_id × level per tutor), `tutor_availability` (JSONB windows); RLS policies for all three tables | +| **Tutor Zod schema** | ✅ `lib/validators/tutor.ts` — validates bio (min 50 chars), timezone, subjects array, availability windows | +| **Matching query helper** | ✅ `lib/services/matching.ts` — `fetchApprovedTutors()` shared query filtered to `approved = true`; ready for E7 matching screen | +| Sessions | 🚧 Coming in E7–E10 | --- @@ -211,6 +218,7 @@ Recommended workflow | `20260223000006_user_profiles_insert_rls.sql` | Adds INSERT policy on `user_profiles` so authenticated users can upsert their own row during profile setup (safety net if trigger row is absent). | | `20260223000007_create_requests_table.sql` | `requests` table with all fields from the data model; indexes on `(status, created_at desc)` and `created_by_user_id`; `updated_at` trigger; 4 RLS policies (creator insert, creator/admin select, creator update limited to `new`/`payment_pending`, admin update). | | `20260224000001_create_packages_payments.sql` | `packages` table (tier_sessions 8/12/20, start/end date, sessions_total/used, status enum, updated_at trigger, 3 RLS policies); `payments` table (amount_pkr, method, reference, proof_path, rejection_note, status enum, verified_by/at, updated_at trigger, 4 RLS policies); `audit_logs` table for admin payment actions. | +| `20260224000002_create_tutor_tables.sql` | `tutor_profiles` (approved bool default false, bio, timezone, updated_at trigger); `tutor_subjects` (tutor × subject × level, composite PK); `tutor_availability` (JSONB windows array, updated_at trigger); RLS policies for all three tables — tutors manage own rows, admins read/update all. | > **Supabase Dashboard settings required for auth** (after running migrations): > diff --git a/app/admin/layout.tsx b/app/admin/layout.tsx index 7aa6497..6915489 100644 --- a/app/admin/layout.tsx +++ b/app/admin/layout.tsx @@ -61,6 +61,12 @@ export default async function AdminLayout({ > Payments + + Tutors +