fix: add Authorization header to all dashboard apiFetch calls; change Buy Credits/Buy Now buttons to BTN_ORANGE

This commit is contained in:
Tracewebstudio Dev 2026-04-22 01:32:43 +02:00
parent 6a4688c854
commit 35abb6e7aa
19 changed files with 184 additions and 32 deletions

View file

@ -38,10 +38,18 @@ interface ContactInfo {
} }
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: "include", credentials: "include",
headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -58,10 +58,18 @@ const EMPTY_FORM: JobFormState = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: "include", credentials: "include",
headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -14,10 +14,18 @@ type ApplicationItem = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -34,10 +34,18 @@ type CheckoutState = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: "include", credentials: "include",
headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }
@ -770,7 +778,7 @@ export default function CreditsPage(props: Props) {
</span> </span>
</p> </p>
</div> </div>
<button type="button" onClick={() => setActiveTab("buy")} style={BTN_PRIMARY}> <button type="button" onClick={() => setActiveTab("buy")} style={BTN_ORANGE}>
Buy Credits Buy Credits
</button> </button>
</div> </div>
@ -940,7 +948,7 @@ export default function CreditsPage(props: Props) {
type="button" type="button"
onClick={() => openCheckout(pkg)} onClick={() => openCheckout(pkg)}
style={{ style={{
...BTN_PRIMARY, ...BTN_ORANGE,
width: "100%", width: "100%",
"margin-top": "8px", "margin-top": "8px",
}} }}

View file

@ -23,10 +23,18 @@ type RequirementItem = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: "include", credentials: "include",
headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -18,10 +18,18 @@ type LeadRequestItem = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -18,10 +18,18 @@ type ExternalRoleItem = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -17,10 +17,18 @@ type Article = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: "include", credentials: "include",
headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -13,10 +13,18 @@ type ApplicationItem = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -33,10 +33,18 @@ type SavedJob = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: "include", credentials: "include",
headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -4,10 +4,18 @@ import { BTN_GHOST, BTN_ORANGE, CARD } from '~/components/DashboardShell';
const API = '/api/gateway'; const API = '/api/gateway';
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -17,10 +17,18 @@ type Metric = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -81,10 +81,18 @@ const EMPTY_PROFESSIONAL_FORM: ProfessionalPortfolioState = {
// ── Helpers ─────────────────────────────────────────────────────────────────── // ── Helpers ───────────────────────────────────────────────────────────────────
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -23,10 +23,18 @@ type MarketplaceItem = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: "include", credentials: "include",
headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -16,10 +16,18 @@ type LeadRequestItem = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -219,10 +219,18 @@ function getDocFields(roleKey: string) {
// ── Helpers ─────────────────────────────────────────────────────────────────── // ── Helpers ───────────────────────────────────────────────────────────────────
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: "include", credentials: "include",
headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -4,10 +4,18 @@ import { BTN_GHOST, BTN_ORANGE, BTN_PRIMARY, CARD, INPUT, LABEL } from '~/compon
const API = '/api/gateway'; const API = '/api/gateway';
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -11,10 +11,18 @@ type UserRoleItem = {
}; };
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }

View file

@ -9,10 +9,18 @@ import { CARD, BTN_ORANGE, BTN_GHOST } from '~/components/DashboardShell';
const API = '/api/gateway'; const API = '/api/gateway';
async function apiFetch(path: string, opts?: RequestInit) { async function apiFetch(path: string, opts?: RequestInit) {
const token =
typeof window !== "undefined"
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
: "";
return fetch(`${API}${path}`, { return fetch(`${API}${path}`, {
...opts, ...opts,
credentials: 'include', credentials: "include",
headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, headers: {
"Content-Type": "application/json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(opts?.headers ?? {}),
},
}); });
} }