mirror of
https://github.com/bitbaum/petvity.git
synced 2026-12-04 06:38:45 +01:00
* feat(bookings,shop): calendar conflict blocking + Stripe payment integration Tier-1 scheduling: the booking API now rejects (409) any request that overlaps a professional's active bookings or their self-declared blocked dates; vets/sitters manage blocked ranges at /portal/professional-profile (new professional_blocked_dates table + /api/availability CRUD). Payments: full Stripe Checkout flow, env-gated like Resend — without STRIPE_SECRET_KEY nothing changes; with it, checkout redirects to Stripe, the signed webhook (/api/payments/webhook) marks orders paid, and unpaid orders stay payable from /portal/orders (Pay now + paid/awaiting badges). orders gains paid_at + checkout_session_id. Critical bug found by the smoke test: the login JWT callback wrote resolveRole(email) back to the DB, silently DEMOTING every vet/sitter to pet_owner at their next sign-in (residents were safe only because they never log in). ADMIN_EMAILS now only promotes; professional roles survive. Verified end-to-end locally: sitter registers → blocks dates → owner booking overlap 409, blocked-dates 409, disjoint 201; checkout w/o keys falls back to recorded orders. verify green (1209 tests incl. 12 new). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * chore: nudge CI (pull_request event was never delivered) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
14 lines
830 B
SQL
14 lines
830 B
SQL
CREATE TABLE "professional_blocked_dates" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"professional_id" uuid NOT NULL,
|
|
"start_date" date NOT NULL,
|
|
"end_date" date NOT NULL,
|
|
"reason" varchar(200),
|
|
"created_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "orders" ADD COLUMN "paid_at" timestamp;--> statement-breakpoint
|
|
ALTER TABLE "orders" ADD COLUMN "checkout_session_id" varchar(255);--> statement-breakpoint
|
|
ALTER TABLE "professional_blocked_dates" ADD CONSTRAINT "professional_blocked_dates_professional_id_users_id_fk" FOREIGN KEY ("professional_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "professional_blocked_dates_professional_id_idx" ON "professional_blocked_dates" USING btree ("professional_id");
|