Commit graph

301 commits

Author SHA1 Message Date
Khalim Conn-Kowlessar
3b63c5ea1a Confirm invitation accept with a dialog + refresh portfolios list
Replaces the auto-dismiss toast on accept with a shadcn Dialog that
names the portfolio and offers a "Go to {portfolioName}" CTA. Decline
keeps the existing toast. router.refresh() updates /home in place, and
revalidatePath("/home") in the API handler guarantees the server-rendered
portfolio list is fresh on any later navigation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 10:55:34 +00:00
Khalim Conn-Kowlessar
d70b15e705 Unify invitation flow: explicit accept/decline via profile-menu notifications
Replaces the auto-accept-on-signin behaviour with an explicit accept or
decline step. Every invitee (existing user or brand new) is now treated
the same way: an invitation lands in portfolio_invitations, the email
is a deep-link "Sign in to Ara", and the invitee accepts (or declines)
explicitly from a notifications panel hanging off their profile avatar.

Why: the previous flow silently added existing users to portfolios with
no way to refuse, and gave them no in-app confirmation that the invite
landed. Existing users complained they didn't know which account they
were signed in as either — both gaps are closed by the same panel.

Backend:
  - POST /collaborators no longer creates portfolioUsers directly for
    existing users; it writes a portfolio_invitations row in every case
    except the trivial "already a member of THIS portfolio" path
    (silent role update, no email)
  - New /api/user/invitations endpoint: GET lists pending invitations
    addressed to the current user across all portfolios, joined with
    portfolio + inviter context; POST accepts or declines a single
    invitation, scoped to session.email so users can't act on others'
  - Accept reuses the existing planInvitationApplication helper for
    the "already a member" idempotency check
  - Decline is a silent delete (matches GitHub/Linear/Notion convention;
    no email to inviter, no tombstone)
  - signIn callback no longer auto-applies pending invitations — that
    block is removed entirely along with its now-unused imports
  - Email template subject + body unified, no longer suggests the user
    is "added"; both modes say "invited" and direct them to the profile
    menu

Frontend:
  - ProfileDropDown rewritten as a notifications panel: shows the
    signed-in email at the top (closing the "which account?" gap),
    lists pending invitations with Accept/Decline buttons, displays a
    red count badge on the avatar (max "9+"). Uses TanStack Query with
    optimistic update on accept/decline and toast on outcome. Existing
    Help + Sign Out menu items preserved.
  - No useEffect — pending-count derived from query data, mutations
    handle the rest

Vercel preview test plan:
  - Invite a user already in another portfolio → red badge appears on
    their next page load; Accept lands them in the portfolio
  - Invite a new email → sign-up flow finishes; new account lands on
    home with a badge waiting for Accept (no longer auto-accepted)
  - Existing member of THIS portfolio re-invited → silent role update,
    no email

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 09:43:13 +00:00
Khalim Conn-Kowlessar
f3887a215c Polish user-access UX: shadcn confirm dialog + toast feedback
Two small UX upgrades on the portfolio user-access page:

- Replace native confirm() prompts (for "Remove user" and "Revoke
  invitation") with a shadcn-based ConfirmDialog. Shows the email of
  the user/invitation being acted on, disables buttons while the
  mutation is in flight, and matches the visual language of the rest
  of the app. New ConfirmDialog component is generic and reusable.

- Toast on every mutation outcome (invite/remove/revoke, success and
  failure), using the existing useToast hook. Invite success now
  surfaces "Invitation sent — We've emailed <email>…" so admins get
  immediate feedback that the email was dispatched, instead of just
  the form silently clearing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 17:29:36 +00:00
Khalim Conn-Kowlessar
d042606955 Add 6-digit code sign-in as primary, magic link as fast-path fallback
Same email now contains a 6-digit code and a magic link, both backed by a
single verificationToken row. After submitting their email, the user
lands on /auth/verify-code with a single-input form (inputmode=numeric,
autocomplete=one-time-code, auto-submit on 6 digits or paste) and can
either type the code or use the link from the email. Either path
consumes the same row — single-use, replace-on-resend.

This is the structural fix for the silent-quarantine pattern observed
with Atkins and Sustainable Building UK: corporate gateways are happier
with short transactional content than long opaque token URLs, and a
code can't be broken by SafeLinks-style URL rewriting. The link path is
preserved so users whose email gets through unmangled keep one-click UX.

Security:
  - Codes are 6-digit, crypto.randomInt-generated, stored as sha256
    hashed against NEXTAUTH_SECRET on the same row as the link token
  - 5-attempt lockout per code (attempts column); 6th attempt with the
    correct code still fails
  - Per-email send rate limit: 5/hour fixed window (authRateLimits
    table); 6th send returns an error
  - Code + link share a 10-minute window (maxAge dropped from 1h)
  - Resending replaces any prior token rows for the identifier so only
    the latest send is ever live

Implementation:
  - verificationCode.ts holds generateCode + hashCode + the pure
    evaluateCodeAttempt decision tree; 9 unit tests cover every branch
    of the verification outcome (no-such-row, expired, locked-out, ok,
    wrong-with-newAttempts, locked-out-still-rejects-correct-code)
  - sendVerificationRequest now hashes the URL token the same way
    /verify/[token]/page.tsx does, applies the rate limit + records the
    code + replaces older rows in two transactions
  - CredentialsProvider (id: "email-code") calls evaluateCodeAttempt
    inside a transaction, handles all 5 outcomes, creates the user on
    first successful code (parity with the magic-link callback path)
  - oauthId backfill in the signIn callback is now guarded on
    account.type === "oauth" so the credentials flow doesn't pollute
    oauthProvider with "email-code"
  - Migration is additive: code_hash nullable, attempts default 0; new
    authRateLimits table is independent. In-flight tokens at deploy time
    keep working via the link path.

Vercel preview deployment is the test surface; a Mailpit + Cypress E2E
loop is intentionally deferred per the lean-setup plan in docs/wip/
auth-email-code-fallback-plan.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 14:16:47 +00:00
Jun-te Kim
8170601efb refactored with improve-code-archievture and grill-with-docs 2026-05-06 15:49:34 +00:00
Jun-te Kim
a37fd03202 added domna tech password 2026-04-27 11:59:53 +00:00
Jun-te Kim
bee57a56b5 address2uprn onboaridng poc 2026-04-21 20:24:26 +00:00
Jun-te Kim
119a800995 save latest changes and pulled from main 2026-04-20 15:59:11 +00:00
Khalim Conn-Kowlessar
a122d9447c resizing toolbar text 2026-04-20 08:21:55 +00:00
Jun-te Kim
b81a1aaf61 added trigger of sqs 2026-04-18 18:55:19 +00:00
Jun-te Kim
02e1b527b8 keep it minimal 2026-04-17 10:07:30 +00:00
Jun-te Kim
e0f1b4f871 dockerfile 2026-04-15 14:43:30 +00:00
Khalim Conn-Kowlessar
29ad7489c4 tweaking colours on EPC bar 2026-04-15 13:01:09 +00:00
Khalim Conn-Kowlessar
ab872d8a73 added missing tooltip files 2026-04-15 10:00:01 +00:00
Khalim Conn-Kowlessar
0c080595a4 added loading state to toolbar 2026-04-13 16:51:05 +00:00
Khalim Conn-Kowlessar
910198e847 tweaking layout 2026-04-13 11:33:43 +00:00
Khalim Conn-Kowlessar
6339614720 added missing files 2026-04-11 08:05:41 +00:00
Khalim Conn-Kowlessar
acd018daaf fixing build error
Some checks are pending
Next.js Build Check / build (push) Waiting to run
2026-04-10 22:52:16 +00:00
Khalim Conn-Kowlessar
f8ca195b83 trying to get the skeleton working 2026-04-10 22:35:32 +00:00
Khalim Conn-Kowlessar
2341741270 revamping the plan page 2026-04-10 21:54:26 +00:00
Khalim Conn-Kowlessar
f38f17cc1a modified toolbar
Some checks failed
Next.js Build Check / build (push) Has been cancelled
2026-04-09 12:22:20 +00:00
Khalim Conn-Kowlessar
c3e657847a delete solar analysis page and remove solar analysis from toolbar 2026-04-08 10:51:46 +00:00
Khalim Conn-Kowlessar
b9d5166e82 re-vamping ara ui 2026-04-08 10:29:14 +00:00
Daniel Roth
cbf2d1705b Add success toast 2026-03-03 12:23:17 +00:00
KhalimCK
7caada25ca
Merge pull request #172 from Hestia-Homes/new-reporting
New reporting
2026-01-28 18:49:36 +00:00
Khalim Conn-Kowlessar
bb30444316 fixing hydration & session bug 2026-01-28 13:52:24 +00:00
Jun-te Kim
408433190c show a demo to harry 2026-01-26 11:34:58 +00:00
1f8c6e0c5b button fix 2026-01-19 13:43:58 +00:00
5783851415 re run build 2026-01-19 13:36:50 +00:00
Khalim Conn-Kowlessar
bb141b759b handling already installed measures - updated ui and adding handling for installed measures 2026-01-07 22:17:45 +00:00
Khalim Conn-Kowlessar
a5bc1f87e4 implemented new ui 2025-12-08 23:25:49 +00:00
58c311f9f8 save new login screen 2025-12-08 10:03:40 +00:00
Khalim Conn-Kowlessar
5dd21d89c4 removed some unnecessary logging 2025-11-25 11:08:38 +00:00
Khalim Conn-Kowlessar
fc8373f9ea fixed scenario re-creationg every time bug 2025-11-25 11:06:34 +00:00
Khalim Conn-Kowlessar
e6f3737355 Refactored portfolio toolbar to allow straight down dropdown 2025-11-13 17:14:20 +00:00
Khalim Conn-Kowlessar
86d919d7df releasing new ui for abri projects 2025-11-05 17:12:18 +00:00
Khalim Conn-Kowlessar
e66719df5e upgraded ui 2025-11-04 20:59:00 +00:00
KhalimCK
040b13dd57
Merge pull request #113 from Hestia-Homes/feature/book-a-survey-with-information-of-contact
Feature/book a survey with information of contact
2025-11-03 19:13:17 +00:00
Khalim Conn-Kowlessar
87655f7d08 added the live project tracking and project proposal 2025-11-03 18:49:25 +00:00
3583b5ab53 see fidd 2025-11-03 16:17:49 +00:00
Khalim Conn-Kowlessar
25a32a5d1c merge fixed 2025-11-03 12:40:15 +00:00
b8caeca263 added the surveyor button changes 2025-11-03 10:23:54 +00:00
Khalim Conn-Kowlessar
03c6425fd7 project ui live 2025-10-31 23:18:21 +00:00
Khalim Conn-Kowlessar
031b5dacc1 Before Tailwind upgrade 2025-10-31 21:48:43 +00:00
Khalim Conn-Kowlessar
6a98a530ed functional display for project proposal ui 2025-10-31 19:07:22 +00:00
8016cc6f26 Merge branch 'main' into feature/abri_table 2025-10-31 12:53:17 +00:00
4d61224cf3 save 2025-10-31 12:52:37 +00:00
Khalim Conn-Kowlessar
ee253daf76 fixed slow loading of the properties data 2025-10-30 20:35:03 +00:00
276b23a900 renamed 2025-10-30 17:22:46 +00:00
Khalim Conn-Kowlessar
b6353cb2d2 added filtering + inspections to front end 2025-10-28 11:22:05 +00:00