fix(loans): land create as draft + private, not active + public

Loan create was forcing `status: STATUS.LOANS.ACTIVE` in the service
and never set `is_public`, so the DB column defaults
(`is_public=true`, `is_negotiable=true`, `status='active'`) took over
and rows landed publicly visible immediately. The success message
explicitly promises "saved as a draft. not visible to anyone yet" —
the row was contradicting it on every loan create.

Same bug class as the wishlist privacy fix in c9897f9a; matching
shape: explicit defaults at the service layer to override the
permissive DB column defaults.

Found by parallel-work probe during the still-pending vercel-auth
deploy blocker. Probe row 53913af5-3117-4d16-bd27-f25a95dd466c
landed status=active+is_public=true with the UI promising draft.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Georgy ButaevandClaude Opus 4.7 committed 2026-06-08 08:45:55 +02:00
1 parent bf32d807ad
commit 9267b6f053
1 file changed
+10 -1
+10 -1
View File
@@ -65,7 +65,16 @@ export async function createLoan(
current_interest_rate: normalizeToNull(loanInput.current_interest_rate),
monthly_payment: normalizeToNull(loanInput.monthly_payment),
desired_rate: normalizeToNull(loanInput.desired_rate),
status: STATUS.LOANS.ACTIVE,
// Defaults match the EntityCreationSuccess UX contract: every entity
// lands as draft and not publicly visible until the user hits Publish
// Now. Earlier this service forced status=ACTIVE and never set
// is_public — DB column defaults filled in is_public=true and
// is_negotiable=true so the row landed publicly visible immediately,
// contradicting the "saved as a draft. not visible to anyone yet"
// success message. Same bug class as the wishlist fix in c9897f9a;
// matching shape here.
status: STATUS.LOANS.DRAFT,
is_public: false,
},
{
client: supabase as unknown as AnySupabaseClient,