add default org

This commit is contained in:
2026-01-20 14:39:57 -03:00
parent d88c84146c
commit b3e60aea65
11 changed files with 65 additions and 17 deletions

View File

@@ -548,7 +548,7 @@ function PaymentAttemptsMenu({
<EllipsisIcon />
</Button>
</PopoverTrigger>
<PopoverContent align="end" className="w-76">
<PopoverContent align="end" className="w-82">
<div className="p-2 space-y-1.5">
{payment_attempts.map(({ sk, brand, last4, status }, index) => {
const [, , created_at] = sk.split('#')

View File

@@ -8,6 +8,11 @@ import { request as req } from '@repo/util/request'
export const middleware: Route.MiddlewareFunction[] = [authMiddleware]
type Response = {
items: { sk: string }[]
preferred_org_id?: string
}
export async function loader({ context, request }: Route.ActionArgs) {
const user = context.get(userContext)!
@@ -21,8 +26,10 @@ export async function loader({ context, request }: Route.ActionArgs) {
throw new Response(await r.text(), { status: r.status })
}
const { items = [] } = (await r.json()) as { items: { sk: string }[] }
const [{ sk } = {}] = items
const { items = [], preferred_org_id } = (await r.json()) as Response
const { sk } = preferred_org_id
? (items.find((item) => item.sk.includes(preferred_org_id)) ?? items[0])
: items[0]
if (sk) {
const [_, id] = sk.split('#')