From 35abb6e7aa267fbb70e4681c811f55a188e2f540 Mon Sep 17 00:00:00 2001 From: Tracewebstudio Dev Date: Wed, 22 Apr 2026 01:32:43 +0200 Subject: [PATCH] fix: add Authorization header to all dashboard apiFetch calls; change Buy Credits/Buy Now buttons to BTN_ORANGE --- .../dashboard/CompanyApplicationsPage.tsx | 10 +++++++++- src/components/dashboard/CompanyJobsPage.tsx | 10 +++++++++- .../dashboard/CompanyShortlistedCandidatesPage.tsx | 12 ++++++++++-- src/components/dashboard/CreditsPage.tsx | 14 +++++++++++--- .../dashboard/CustomerRequirementsPage.tsx | 10 +++++++++- src/components/dashboard/CustomerResponsesPage.tsx | 12 ++++++++++-- src/components/dashboard/ExploreServicesPage.tsx | 12 ++++++++++-- .../dashboard/HelpCenterDashboardPage.tsx | 10 +++++++++- .../dashboard/JobSeekerApplicationsPage.tsx | 12 ++++++++++-- src/components/dashboard/JobSeekerJobsPage.tsx | 10 +++++++++- src/components/dashboard/LogoutPage.tsx | 12 ++++++++++-- src/components/dashboard/MyDashboardPage.tsx | 12 ++++++++++-- src/components/dashboard/PortfolioPage.tsx | 12 ++++++++++-- src/components/dashboard/ProfessionalLeadsPage.tsx | 10 +++++++++- .../dashboard/ProfessionalResponsesPage.tsx | 12 ++++++++++-- src/components/dashboard/ProfilePage.tsx | 10 +++++++++- src/components/dashboard/SettingsPage.tsx | 12 ++++++++++-- src/components/dashboard/SwitchServicesPage.tsx | 12 ++++++++++-- .../dashboard/VerificationStatusPage.tsx | 12 ++++++++++-- 19 files changed, 184 insertions(+), 32 deletions(-) diff --git a/src/components/dashboard/CompanyApplicationsPage.tsx b/src/components/dashboard/CompanyApplicationsPage.tsx index a0a1ff9..ec78e18 100644 --- a/src/components/dashboard/CompanyApplicationsPage.tsx +++ b/src/components/dashboard/CompanyApplicationsPage.tsx @@ -38,10 +38,18 @@ interface ContactInfo { } async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, credentials: "include", - headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/CompanyJobsPage.tsx b/src/components/dashboard/CompanyJobsPage.tsx index 258d64b..0692aaa 100644 --- a/src/components/dashboard/CompanyJobsPage.tsx +++ b/src/components/dashboard/CompanyJobsPage.tsx @@ -58,10 +58,18 @@ const EMPTY_FORM: JobFormState = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, credentials: "include", - headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/CompanyShortlistedCandidatesPage.tsx b/src/components/dashboard/CompanyShortlistedCandidatesPage.tsx index c7a494a..b969f93 100644 --- a/src/components/dashboard/CompanyShortlistedCandidatesPage.tsx +++ b/src/components/dashboard/CompanyShortlistedCandidatesPage.tsx @@ -14,10 +14,18 @@ type ApplicationItem = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/CreditsPage.tsx b/src/components/dashboard/CreditsPage.tsx index 78de671..96af5dc 100644 --- a/src/components/dashboard/CreditsPage.tsx +++ b/src/components/dashboard/CreditsPage.tsx @@ -34,10 +34,18 @@ type CheckoutState = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, 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) {

- @@ -940,7 +948,7 @@ export default function CreditsPage(props: Props) { type="button" onClick={() => openCheckout(pkg)} style={{ - ...BTN_PRIMARY, + ...BTN_ORANGE, width: "100%", "margin-top": "8px", }} diff --git a/src/components/dashboard/CustomerRequirementsPage.tsx b/src/components/dashboard/CustomerRequirementsPage.tsx index c4138c2..49723fe 100644 --- a/src/components/dashboard/CustomerRequirementsPage.tsx +++ b/src/components/dashboard/CustomerRequirementsPage.tsx @@ -23,10 +23,18 @@ type RequirementItem = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, credentials: "include", - headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/CustomerResponsesPage.tsx b/src/components/dashboard/CustomerResponsesPage.tsx index 21513f6..b5259af 100644 --- a/src/components/dashboard/CustomerResponsesPage.tsx +++ b/src/components/dashboard/CustomerResponsesPage.tsx @@ -18,10 +18,18 @@ type LeadRequestItem = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/ExploreServicesPage.tsx b/src/components/dashboard/ExploreServicesPage.tsx index b48199e..8adcb72 100644 --- a/src/components/dashboard/ExploreServicesPage.tsx +++ b/src/components/dashboard/ExploreServicesPage.tsx @@ -18,10 +18,18 @@ type ExternalRoleItem = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/HelpCenterDashboardPage.tsx b/src/components/dashboard/HelpCenterDashboardPage.tsx index 19cd4e3..9734a8f 100644 --- a/src/components/dashboard/HelpCenterDashboardPage.tsx +++ b/src/components/dashboard/HelpCenterDashboardPage.tsx @@ -17,10 +17,18 @@ type Article = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, credentials: "include", - headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/JobSeekerApplicationsPage.tsx b/src/components/dashboard/JobSeekerApplicationsPage.tsx index 065d986..9f6ada2 100644 --- a/src/components/dashboard/JobSeekerApplicationsPage.tsx +++ b/src/components/dashboard/JobSeekerApplicationsPage.tsx @@ -13,10 +13,18 @@ type ApplicationItem = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/JobSeekerJobsPage.tsx b/src/components/dashboard/JobSeekerJobsPage.tsx index 7bf5f04..26f6588 100644 --- a/src/components/dashboard/JobSeekerJobsPage.tsx +++ b/src/components/dashboard/JobSeekerJobsPage.tsx @@ -33,10 +33,18 @@ type SavedJob = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, credentials: "include", - headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/LogoutPage.tsx b/src/components/dashboard/LogoutPage.tsx index b08ed5f..c321f3e 100644 --- a/src/components/dashboard/LogoutPage.tsx +++ b/src/components/dashboard/LogoutPage.tsx @@ -4,10 +4,18 @@ import { BTN_GHOST, BTN_ORANGE, CARD } from '~/components/DashboardShell'; const API = '/api/gateway'; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/MyDashboardPage.tsx b/src/components/dashboard/MyDashboardPage.tsx index e64ad20..f3bf826 100644 --- a/src/components/dashboard/MyDashboardPage.tsx +++ b/src/components/dashboard/MyDashboardPage.tsx @@ -17,10 +17,18 @@ type Metric = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/PortfolioPage.tsx b/src/components/dashboard/PortfolioPage.tsx index 3d2a3a3..d6f92a4 100644 --- a/src/components/dashboard/PortfolioPage.tsx +++ b/src/components/dashboard/PortfolioPage.tsx @@ -81,10 +81,18 @@ const EMPTY_PROFESSIONAL_FORM: ProfessionalPortfolioState = { // ── Helpers ─────────────────────────────────────────────────────────────────── async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/ProfessionalLeadsPage.tsx b/src/components/dashboard/ProfessionalLeadsPage.tsx index a67718c..6e5a6da 100644 --- a/src/components/dashboard/ProfessionalLeadsPage.tsx +++ b/src/components/dashboard/ProfessionalLeadsPage.tsx @@ -23,10 +23,18 @@ type MarketplaceItem = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, credentials: "include", - headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/ProfessionalResponsesPage.tsx b/src/components/dashboard/ProfessionalResponsesPage.tsx index 11176f6..7b592b5 100644 --- a/src/components/dashboard/ProfessionalResponsesPage.tsx +++ b/src/components/dashboard/ProfessionalResponsesPage.tsx @@ -16,10 +16,18 @@ type LeadRequestItem = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/ProfilePage.tsx b/src/components/dashboard/ProfilePage.tsx index c6cab21..58d84ac 100644 --- a/src/components/dashboard/ProfilePage.tsx +++ b/src/components/dashboard/ProfilePage.tsx @@ -219,10 +219,18 @@ function getDocFields(roleKey: string) { // ── Helpers ─────────────────────────────────────────────────────────────────── async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, credentials: "include", - headers: { "Content-Type": "application/json", ...(opts?.headers ?? {}) }, + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/SettingsPage.tsx b/src/components/dashboard/SettingsPage.tsx index 02543b7..81a79a3 100644 --- a/src/components/dashboard/SettingsPage.tsx +++ b/src/components/dashboard/SettingsPage.tsx @@ -4,10 +4,18 @@ import { BTN_GHOST, BTN_ORANGE, BTN_PRIMARY, CARD, INPUT, LABEL } from '~/compon const API = '/api/gateway'; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/SwitchServicesPage.tsx b/src/components/dashboard/SwitchServicesPage.tsx index 7d4f36e..663cdcd 100644 --- a/src/components/dashboard/SwitchServicesPage.tsx +++ b/src/components/dashboard/SwitchServicesPage.tsx @@ -11,10 +11,18 @@ type UserRoleItem = { }; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); } diff --git a/src/components/dashboard/VerificationStatusPage.tsx b/src/components/dashboard/VerificationStatusPage.tsx index 462db37..1059be6 100644 --- a/src/components/dashboard/VerificationStatusPage.tsx +++ b/src/components/dashboard/VerificationStatusPage.tsx @@ -9,10 +9,18 @@ import { CARD, BTN_ORANGE, BTN_GHOST } from '~/components/DashboardShell'; const API = '/api/gateway'; async function apiFetch(path: string, opts?: RequestInit) { + const token = + typeof window !== "undefined" + ? window.sessionStorage.getItem("nxtgauge_access_token") || "" + : ""; return fetch(`${API}${path}`, { ...opts, - credentials: 'include', - headers: { 'Content-Type': 'application/json', ...(opts?.headers ?? {}) }, + credentials: "include", + headers: { + "Content-Type": "application/json", + ...(token ? { Authorization: `Bearer ${token}` } : {}), + ...(opts?.headers ?? {}), + }, }); }