Commit Graph

65 Commits

Author SHA1 Message Date
cbb3e59878 update: update the not-selected address items in th address list 2026-04-27 08:15:10 +02:00
00dd63668b fix: fix address not appending to address list in account page after adding it 2026-04-26 13:16:14 +02:00
bd93989036 fix: all keybinds becoming unreactive after completing an order 2026-04-26 12:50:51 +02:00
4083495704 fix: fixed payment not going through if no address and card were saved 2026-04-26 12:21:16 +02:00
7bebdeebed fix: fixed card and address list having duplicate items, and a checkout flow infinate loop condition 2026-04-26 11:59:24 +02:00
e0ff8f5f76 update: update the FAQ section 2026-04-26 11:12:05 +02:00
011bf3a4ff fix: use theme.Base() for order card border so colors render over SSH
lipgloss.NewStyle() uses the default renderer which can't output colors
over SSH. Switching to m.theme.Base() uses the session renderer, fixing
BorderForeground. Also reverted to NormalBorder since color now works.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 22:39:36 +02:00
d51912917e fix: use DoubleBorder for selected order card
BorderForeground color wasn't rendering differently over SSH. Use
DoubleBorder (╔═╗║╚═╝) for selected vs NormalBorder (┌─┐│└─┘) for
unselected — visually distinct regardless of color support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 22:31:17 +02:00
c8a5f4806d fix: hardcode steel blue border and bold for selected order card
Use explicit #4682B4 with bold to ensure the selected border is
visually distinct on all terminal themes including gruvbox.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 22:24:31 +02:00
e2dc2854b7 fix: add 1-item scroll buffer and use highlight color for selected border
Scroll triggers when the next item would be off-screen, not when the
current item hits the edge. Selected border now uses highlight color
(steel blue) instead of accent (white) for visibility on all themes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 22:18:43 +02:00
f9885e2d5e fix: use fixed-height order cards and correct viewport height
Simplify order list cards to 2 content lines (matching reference) so
itemHeight is always 4. Remove extra margin/buffer from viewport height
calc since account is a viewport page with no margins.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 22:11:49 +02:00
34bb7a7c7f fix: correct scroll height estimates and improve order selection visibility
The scroll-to-item calculations used wrong item heights (7/5 instead of
9/7) and ignored the 5-line title header offset, causing the viewport to
under-scroll. Selected order cards now light up in accent color for
better visibility across terminal themes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 22:00:44 +02:00
79c8238f1b fix: scrolling stopped working in last commit. this change is made by claude so it just might break again 2026-04-25 21:48:33 +02:00
5c38c7e726 update scroll handling 2026-04-25 11:41:20 +02:00
4024cf4b40 fix: fixed the border on order history currently selected item not showing up for some terminal themes 2026-04-25 11:01:45 +02:00
c78f5eb12b refactor: remove putting ssh key in memory at all, just use it for auth
changed the ssh key to just do fingerprinting and not store it at all, and not be able to edit it either in the account page
2026-04-25 10:50:19 +02:00
c8af9cb551 change: change the proceed warning to red to make it easier to catch 2026-04-24 17:02:05 +02:00
d7b172843e resolve splash screen deadlock and auth 500 soft-deleted ssh keys
Auth handler used FirstOrCreate which couldn't see soft-deleted keys
  (GORM filters by deleted_at IS NULL) but also couldn't insert (unique
  index still covers deleted rows), returning 500 on every login after
  a key deletion. Use Unscoped lookup and restore soft-deleted keys.

  Splash screen also got permanently stuck when auth failed because
  splashViewInitCmd was never fired, leaving splash.dataReady false.
2026-04-24 16:51:19 +02:00
d66b41eed3 refactor: refactor the footer handling 2026-04-24 12:13:26 +02:00
6db7748d9f change the BuildAccountView inline sub-views to use 4 different files to make it better 2026-04-24 11:37:42 +02:00
abe11853f6 refactor: add helper functions for subtotal, cart empty, and cart item count 2026-04-24 10:29:15 +02:00
edc032d6d4 bug fixes: various small bug fixes and typos 2026-04-24 10:04:31 +02:00
53c1b5e254 update: removed stale errors
when encountering an error, the error would never be removed, i just reset the error msg in the switchPage function, this will have to be redone later to make error messages dissapear after a while even on the same page
2026-04-24 09:45:32 +02:00
1bc03822b1 security: remove SSH public key from TUI memory
replace SSHPublicKeyStr field on Model with a closure-based authCmd that
fires, the public key lives only in the goroutine stack not on the
long-lived Model struct

Prevents key material exposure in heap dumps if the process crashed
2026-04-24 09:39:26 +02:00
6006f9617d refactor: add dedicated *Switch() methods
added dedicated *Switch() methods (ShopSwitch, CartSwitc, AccountSwitch, ...) for page transitions and remove the catch-all resetPageState(). Each switch owns its pages zero-init, viewport setup, and async data fetching
2026-04-24 09:25:31 +02:00
1c3ebf789c refactor: update the flat model struct with nested structs 2026-04-24 08:57:04 +02:00
bef7f85bda rewrite: update the slice sort to use built-in lib sort 2026-04-19 14:15:14 +02:00
b92132474b various error checks and formatting 2026-04-14 15:26:36 +02:00
7882667e35 update: commented out unused country codes 2026-04-13 14:08:47 +02:00
a22ba382c2 feat: add ssh key management to account page 2026-04-13 13:33:19 +02:00
7cbefeae40 fix: some fixes 2026-04-12 12:35:05 +02:00
e11e708095 fix: shit was NOT working from last commit 2026-04-12 12:22:06 +02:00
6559c4dd8f fix and feature: made checkout page cleaner, and added card and address modification to account page
the checkout flow was a bit wonky because it would display the same info twice which looked weird and confusing. this is now changed to only show once and update one of the pages independantly.

Now added the possibility to modify card and address list in the account page and not in the checkout flow
2026-04-12 12:11:04 +02:00
157a752540 fix: added user verification to continue checkout after adding card
when the user added their card it would instantly complete the order. this could be unwanted so now i have added an extra input requirement to confirm the payment after adding the card
2026-04-11 20:03:17 +02:00
77a044e11d bruh 2026-04-11 11:37:11 +02:00
ac04676abb adding catppuccin theme 2026-04-11 11:05:16 +02:00
53e443e93d updating 2026-04-09 19:31:55 +02:00
639b75578e theme system 2026-04-09 17:39:59 +02:00
062242e346 feat: add browser-based card collection via Stripe Checkout Session
adds a /pay/{token} redirect endpoint that generates a short URL
pointing to a stripe checkout sessions in setup mode. The TUI shows a QR
code and URL on the payment page so users can add a card via the browser
instead of entering raw card data over SSH.

the checkout.session.completed webhook saves the card to the database.
the TUI polls GET /api/v1/cards every second and auto-proceeds to
confirmation once the new card is detected.

also adds a dev.sh startup script that runs all four required processes.
(SSH server, API server, Stripe CLI listener, ngrok) in a single
terminal
2026-04-08 01:03:43 +02:00
6094e05b6f feat: shorten checkout URLs via in-memory redirect for smaller QR codes
Stripe checkout URLs are too long to produce a scannable QR code in a
terminal. Add an in-memory token→URL store and a /pay/{token} redirect
endpoint so the TUI shows a short URL (e.g. localhost:8080/pay/a3f1c2b4)
that fits in a QR. APP_URL config controls the base URL (defaults to
API_URL). Revert to returning sess.URL directly in CollectCard if this
approach needs to be abandoned.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 21:55:52 +02:00
a4d5a1559a fix: resoce cart persistance, quantity increment and post-order state bugs
Three bugs fixed, two of them from the last commit, one of them has been
long living.

- the cart query in the ViewInit handler used user_id on cart_items, but
that column does not exist, cart_items links to carts via cart_id. Fixed
by first finding the users cart and then querying items by cart_id,
which is how the reso of the cart handlers already do it.

- GetViewInit was missing the json.Decode call entirely. so the response
body was never parsed. This meant m.User was never set, blocking all
cart syncs and address saves, and the cart always loaded empty.

- after a successful order, the cart was never cleared locally even
though the server deleted the cart items. this meant that the user had
to quit and ssh back in to see the cart update. fixed by clreaing
m.Cart, m.CartCursor and m.ShippingInfo in the CheckoutResultMsg success
handler
2026-03-27 12:21:58 +01:00
296c052fa7 refactor: move SSH auth and initial data loading to splash screen
previously main.go handled auth directly, it connected to the database,
ran migrations, created a JWT manager and SSHAuthService, and
authenticated the SSH key before the TUI even started. this commit rips
all of that out

Auth now happens inside the TUI during the splash screen via
splashAuthCmd, which calls the /auth/token endpoint. if no user exists
or the fingerprint it auto-creates one using the SSH public ke, so there
is no longer a separate registartion flow. The token and user com back
in the response.

once authed splashViewInitCmd fires a single /view/init request that
loads everything needed to start the app, products, cart, addresses,
cards, and orders, before switching to the shop page

on the model side, User/*models.user and gossh.PublicKey were replaced
with plain Fingerprint and SSHPublicKeyStr strings, and NewModelWithAuth
was updated too
2026-03-27 12:18:05 +01:00
4eeb3eda9a feat: added a splash page 2026-03-26 18:34:19 +01:00
4bd4dfabd2 fix: deleting addresses didnt work. oops 2026-03-26 18:01:57 +01:00
3ff4aa9d50 fix: rewrote the huge 700+ line update call with modularized calls 2026-03-26 17:47:56 +01:00
93b257a612 fix: store coffee prices as int cents to prevent rounding errors
prices stored as float64 could lead to rounding errors when converting to cents for stripe (19.99 * 100 = 1998.99... truncating to 1998). canged Coffee.Price to int, storing cents directly. Updated the seed data, fallback products, API handlers, and all TUI display code to be in sync with this change.
2026-03-26 09:09:20 +01:00
d5cb4259f5 fix: prevent charge-without-order by creating order before charging
When paying the application charges the card and then sends a payment
record to the database after, in a situation where something goes wrong
between those two steps, we could potentially end up where a users card
was charged but no record on what is was charged for. The fix is to
re-order ConvertCart to write a pending order record before calling
Stripe, this way a DB record always exists if anything fails
mid-operation. This implementation uses an idempotency key keyed to the
order ID to prevent double-charges on retry. Wraps the post-charge DB
updates in a transaction so marking paid andd clearing the cart are
atomic. Adds OrderStatusFailed and a CRITICAL log for the unrecoverable
case. Includes a checkout flow doc with test cards and reconcilation
steps.
2026-03-25 20:13:51 +01:00
1a49360191 feat: throw out the boolean navigation with page routing
replaced ViewingCart/ViewingAccount booleans and CheckoutStep int with a
single 'page' type and a SwitchPage() method, this is just almost
copying the reference implementation (terminalDotShop)'s routing
pattern. Adds inCartFlow(), chechoutStep(), and buildPageContent()
helpers to clean up those huge if/else chains in views, footer, header,
and breadcrumds. code is looking a lot better now!
2026-03-25 15:11:33 +01:00
93cc69d028 just updating the branch with current changes 2026-03-25 08:57:27 +01:00
c7fa292730 update: addeds some extra text in the account page and making some updates for the future for the setting default addresses and cards 2026-03-24 21:29:22 +01:00