Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2921e21
fix signout error
ArnavK-09 Nov 15, 2025
bd1e545
Merge remote-tracking branch 'origin/main' into fsfsfs344344
ArnavK-09 Nov 15, 2025
efdb64d
refactor: replace Avatar component with GithubAvatarWithFallback in u…
ArnavK-09 Nov 15, 2025
95afaf6
Merge remote-tracking branch 'origin/main' into fsfsfs344344
ArnavK-09 Nov 15, 2025
48306a5
feat: add optional tscircuit_handle parameter to account retrieval
ArnavK-09 Nov 15, 2025
cd82129
Merge remote-tracking branch 'origin/main' into fsfsfs344344
ArnavK-09 Nov 15, 2025
3711a60
Discard changes to src/pages/user-profile.tsx
ArnavK-09 Nov 15, 2025
6fc4277
Merge remote-tracking branch 'origin/main' into fsfsfs344344
ArnavK-09 Nov 15, 2025
dda1b74
Merge branch 'fsfsfs344344' of https://github.com/tscircuit/tscircuit…
ArnavK-09 Nov 15, 2025
60c97e1
style: dashboard layout for org account newbie
ArnavK-09 Nov 15, 2025
eb8dd64
Merge remote-tracking branch 'origin/main' into fsfsfs344344
ArnavK-09 Nov 15, 2025
dbdc96d
fix prod tscircuit dialog
ArnavK-09 Nov 15, 2025
7c87bf4
Merge remote-tracking branch 'origin/main' into fsfsfs344344
ArnavK-09 Nov 15, 2025
10202ed
refactor: update organization creation form to use 'handle' instead o…
ArnavK-09 Nov 15, 2025
e593ee3
Merge remote-tracking branch 'origin/main' into fsfsfs344344
ArnavK-09 Nov 15, 2025
f0fc42d
refactor: update organization creation form to use 'handle' instead o…
ArnavK-09 Nov 15, 2025
07b4bc4
f
ArnavK-09 Nov 15, 2025
2ed6dce
Merge remote-tracking branch 'origin/main' into fsfsfs344344
ArnavK-09 Nov 15, 2025
3430461
prevent double dialog on editor if tscirucit not set
ArnavK-09 Nov 15, 2025
a2caa55
Merge remote-tracking branch 'origin/main' into fsfsfs344344
ArnavK-09 Nov 15, 2025
92f45d6
refactor: update organization filtering t
ArnavK-09 Nov 15, 2025
aaafe86
f
ArnavK-09 Nov 15, 2025
beae730
Update fake-snippets-api/routes/api/orgs/list.ts
ArnavK-09 Nov 15, 2025
3326960
f
ArnavK-09 Nov 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bun-tests/fake-snippets-api/routes/orgs/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test("GET /api/orgs/list - should return user's organizations when un-authentica
const { axios, seed } = await getTestServer()

const listResponse = await axios.post("/api/orgs/list", {
github_handle: seed.account2.github_username,
tscircuit_handle: seed.account2.tscircuit_handle,
})

expect(listResponse.status).toBe(200)
Expand Down
13 changes: 12 additions & 1 deletion fake-snippets-api/lib/db/db-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1709,19 +1709,30 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
getOrgs: (
filters?: {
owner_account_id?: string
account_id?: string
github_handle?: string
tscircuit_handle?: string
name?: string
},
auth?: { account_id?: string },
) => {
console.log(filters)
let orgs = get().organizations
if (filters?.owner_account_id) {
orgs = orgs.filter(
(org) => org.owner_account_id === filters.owner_account_id,
)
}
if (filters?.account_id) {
orgs = orgs.filter((org) => {
const isMemberViaOrgAccounts = get().orgAccounts.some(
(oa) =>
oa.org_id === org.org_id && oa.account_id === filters.account_id,
)
const isPersonalOrg =
org.is_personal_org && org.owner_account_id === filters.account_id
return isMemberViaOrgAccounts || isPersonalOrg
})
}
if (filters?.github_handle) {
orgs = orgs.filter((org) => {
const account = get().accounts.find(
Expand Down
13 changes: 7 additions & 6 deletions fake-snippets-api/routes/api/orgs/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@ export default withRouteSpec({
methods: ["GET", "POST"],
auth: "optional_session",
commonParams: z.object({
github_handle: z.string().optional(),
account_id: z.string().optional(),
tscircuit_handle: z.string().optional(),
}),
jsonResponse: z.object({
ok: z.boolean(),
orgs: z.array(publicOrgSchema),
}),
})(async (req, ctx) => {
const { github_handle, tscircuit_handle } = req.commonParams
if (!ctx.auth && (!github_handle || !tscircuit_handle)) {
const { account_id, tscircuit_handle } = req.commonParams
if (!ctx.auth && (!account_id || !tscircuit_handle)) {
return ctx.error(400, {
error_code: "invalid_request",
message: "You must provide filtering parameters",
message:
"You must provide either account_id or tscircuit_handle when not authenticated",
})
}

const orgs = ctx.db.getOrgs(
{
github_handle,
account_id: account_id,
tscircuit_handle,
...(!github_handle && !tscircuit_handle
...(!account_id && !tscircuit_handle
? { owner_account_id: ctx.auth?.account_id }
: {}),
},
Expand Down
9 changes: 0 additions & 9 deletions src/components/dialogs/new-package-save-prompt-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ export const NewPackageSavePromptDialog = ({
error: orgsError,
} = useListUserOrgs()

const isOwnerPersonalOrg = useMemo(() => {
if (!selectedOrgId) return false
const selectedOrg = organizations?.find((x) => x.org_id === selectedOrgId)
return (
selectedOrg?.is_personal_org &&
selectedOrg?.owner_account_id == session?.account_id
)
}, [selectedOrgId, organizations, session?.github_username])

const normalizedPackageName = useMemo(() => {
if (!packageName.trim()) return ""
return normalizeName(packageName)
Expand Down
13 changes: 8 additions & 5 deletions src/hooks/use-list-user-orgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@ import { useAxios } from "@/hooks/use-axios"
import type { PublicOrgSchema } from "fake-snippets-api/lib/db/schema"
import { useGlobalStore } from "./use-global-store"

export const useListUserOrgs = (githubHandle?: string) => {
export const useListUserOrgs = (tscircuit_handle?: string) => {
const axios = useAxios()
const session = useGlobalStore((s) => s.session)
const github_handle = githubHandle || session?.github_username

return useQuery<PublicOrgSchema[], Error & { status: number }>(
["orgs", "list", github_handle],
["orgs", "list", tscircuit_handle || session?.account_id],
async () => {
const { data } = await axios.get("/orgs/list", {
...(github_handle && { params: { github_handle } }),
params: tscircuit_handle
? { tscircuit_handle }
: session?.account_id
? { account_id: session.account_id }
: {},
})
return data.orgs
},
{
retry: false,
refetchOnWindowFocus: false,
enabled: Boolean(github_handle),
enabled: Boolean(tscircuit_handle || session?.account_id),
},
)
}