add default org
This commit is contained in:
@@ -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('#')
|
||||
|
||||
@@ -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('#')
|
||||
|
||||
Reference in New Issue
Block a user