@q3assets/auth 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q3assets/auth",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "exports": {
5
5
  ".": "./src/index.ts",
6
6
  "./login": "./src/login.tsx",
@@ -36,14 +36,20 @@ export function AdminPanel({ supabase, onClose, apiBase = "/api/admin/users" }:
36
36
  }
37
37
 
38
38
  async function loadUsers() {
39
- const headers = await getAuthHeader()
40
- const res = await fetch(apiBase, { headers })
41
- const data = await res.json()
42
- if (res.ok) {
39
+ try {
40
+ const headers = await getAuthHeader()
41
+ const res = await fetch(apiBase, { headers })
42
+ if (!res.ok) {
43
+ const text = await res.text()
44
+ try { setError(JSON.parse(text).error || `HTTP ${res.status}`) } catch { setError(`HTTP ${res.status}: ${text.slice(0, 200)}`) }
45
+ setLoading(false)
46
+ return
47
+ }
48
+ const data = await res.json()
43
49
  setUsers(data.users)
44
50
  setError("")
45
- } else {
46
- setError(data.error || "Failed to load users")
51
+ } catch (err: any) {
52
+ setError(err.message || "Failed to load users")
47
53
  }
48
54
  setLoading(false)
49
55
  }