Add API_BASE and update track fetch
cgen-6d22f09563674e92837ccc9fe4e9af9f
This commit is contained in:
parent
25152b6513
commit
7c85b114b6
7 changed files with 31 additions and 13 deletions
|
|
@ -20,6 +20,9 @@ import {
|
|||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
|
||||
// API Base URL for fetch requests
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || "";
|
||||
import { aethexToast } from "@/lib/aethex-toast";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
|
|
@ -105,7 +108,7 @@ export default function AdminMentorshipManager() {
|
|||
params.set("available", String(availableOnly));
|
||||
if (expertiseQueryParam) params.set("expertise", expertiseQueryParam);
|
||||
if (mentorQ.trim()) params.set("q", mentorQ.trim());
|
||||
const resp = await fetch(`/api/mentors?${params.toString()}`);
|
||||
const resp = await fetch(`${API_BASE}/api/mentors?${params.toString()}`);
|
||||
if (!resp.ok) throw new Error(await resp.text().catch(() => "Failed"));
|
||||
const data = await resp.json();
|
||||
setMentors(Array.isArray(data) ? data : []);
|
||||
|
|
@ -127,7 +130,7 @@ export default function AdminMentorshipManager() {
|
|||
params.set("limit", "100");
|
||||
if (statusFilter !== "all") params.set("status", statusFilter);
|
||||
const resp = await fetch(
|
||||
`/api/mentorship/requests/all?${params.toString()}`,
|
||||
`${API_BASE}/api/mentorship/requests/all?${params.toString()}`,
|
||||
);
|
||||
if (!resp.ok) throw new Error(await resp.text().catch(() => "Failed"));
|
||||
const data = await resp.json();
|
||||
|
|
@ -179,7 +182,7 @@ export default function AdminMentorshipManager() {
|
|||
hourly_rate:
|
||||
typeof merged.hourly_rate === "number" ? merged.hourly_rate : null,
|
||||
};
|
||||
const resp = await fetch("/api/mentors/apply", {
|
||||
const resp = await fetch(`${API_BASE}/api/mentors/apply`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ import { User, Calendar } from "lucide-react";
|
|||
import { blogSeedPosts } from "@/data/blogSeed";
|
||||
import FourOhFourPage from "./404";
|
||||
|
||||
// API Base URL for fetch requests
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || "";
|
||||
|
||||
export default function BlogPost() {
|
||||
const { slug } = useParams<{ slug: string }>();
|
||||
const [post, setPost] = useState<any | null>(null);
|
||||
|
|
@ -25,7 +28,7 @@ export default function BlogPost() {
|
|||
try {
|
||||
if (!slug) return;
|
||||
// Primary: try server API
|
||||
let res = await fetch(`/api/blog/${encodeURIComponent(slug)}`);
|
||||
let res = await fetch(`${API_BASE}/api/blog/${encodeURIComponent(slug)}`);
|
||||
let data: any = null;
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ export default function Onboarding() {
|
|||
} as any;
|
||||
|
||||
// Ensure profile via server (uses service role)
|
||||
const ensureResp = await fetch(`/api/profile/ensure`, {
|
||||
const ensureResp = await fetch(`${API_BASE}/api/profile/ensure`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ id: user.id, profile: payload }),
|
||||
|
|
@ -361,7 +361,7 @@ export default function Onboarding() {
|
|||
|
||||
// Create creator profile if they provided primary arm
|
||||
const creatorProfilePromise = data.creatorProfile.primaryArm
|
||||
? fetch(`/api/creators`, {
|
||||
? fetch(`${API_BASE}/api/creators`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
|
|
@ -380,7 +380,7 @@ export default function Onboarding() {
|
|||
|
||||
Promise.allSettled([
|
||||
interests.length
|
||||
? fetch(`/api/interests`, {
|
||||
? fetch(`${API_BASE}/api/interests`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ user_id: user.id, interests }),
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ import {
|
|||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
|
||||
// API Base URL for fetch requests
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || "";
|
||||
import { Star, Mail, Music, Zap, Clock } from "lucide-react";
|
||||
|
||||
interface Artist {
|
||||
|
|
@ -51,7 +54,7 @@ export default function ArtistProfile() {
|
|||
if (!userId) return;
|
||||
|
||||
try {
|
||||
const res = await fetch(`/api/ethos/artists?id=${userId}`);
|
||||
const res = await fetch(`${API_BASE}/api/ethos/artists?id=${userId}`);
|
||||
const data = await res.json();
|
||||
setArtist(data);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ import { useAuth } from "@/contexts/AuthContext";
|
|||
import { useAethexToast } from "@/hooks/use-aethex-toast";
|
||||
import { CheckCircle2, Clock, FileText, AlertCircle } from "lucide-react";
|
||||
|
||||
// API Base URL for fetch requests
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || "";
|
||||
|
||||
interface LicensingAgreement {
|
||||
id: string;
|
||||
track_id: string;
|
||||
|
|
@ -59,7 +62,7 @@ export default function LicensingDashboard() {
|
|||
try {
|
||||
const status = activeTab === "all" ? "all" : activeTab;
|
||||
const res = await fetch(
|
||||
`/api/ethos/licensing-agreements?status=${status}`,
|
||||
`${API_BASE}/api/ethos/licensing-agreements?status=${status}`,
|
||||
{
|
||||
headers: { "x-user-id": user.id },
|
||||
},
|
||||
|
|
@ -81,7 +84,7 @@ export default function LicensingDashboard() {
|
|||
|
||||
const handleApprove = async (id: string) => {
|
||||
try {
|
||||
const res = await fetch(`/api/ethos/licensing-agreements?id=${id}`, {
|
||||
const res = await fetch(`${API_BASE}/api/ethos/licensing-agreements?id=${id}`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"x-user-id": user!.id,
|
||||
|
|
@ -113,7 +116,7 @@ export default function LicensingDashboard() {
|
|||
if (!confirm("Delete this agreement?")) return;
|
||||
|
||||
try {
|
||||
await fetch(`/api/ethos/licensing-agreements?id=${id}`, {
|
||||
await fetch(`${API_BASE}/api/ethos/licensing-agreements?id=${id}`, {
|
||||
method: "DELETE",
|
||||
headers: { "x-user-id": user!.id },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ import {
|
|||
} from "@/components/ui/select";
|
||||
import { Music, Download, Radio, Search, Filter } from "lucide-react";
|
||||
|
||||
// API Base URL for fetch requests
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || "";
|
||||
|
||||
interface Track {
|
||||
id: string;
|
||||
user_id: string;
|
||||
|
|
@ -69,7 +72,7 @@ export default function TrackLibrary() {
|
|||
if (selectedGenre !== "All Genres") params.append("genre", selectedGenre);
|
||||
if (licenseFilter !== "all") params.append("licenseType", licenseFilter);
|
||||
|
||||
const res = await fetch(`/api/ethos/tracks?${params}`);
|
||||
const res = await fetch(`${API_BASE}/api/ethos/tracks?${params}`);
|
||||
const { data } = await res.json();
|
||||
|
||||
let sorted = [...data];
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ import {
|
|||
} from "lucide-react";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
||||
// API Base URL for fetch requests
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || "";
|
||||
|
||||
interface Course {
|
||||
id: string;
|
||||
slug: string;
|
||||
|
|
@ -69,7 +72,7 @@ export default function FoundationCurriculum() {
|
|||
if (selectedCategory) params.set("category", selectedCategory);
|
||||
if (selectedDifficulty) params.set("difficulty", selectedDifficulty);
|
||||
|
||||
const response = await fetch(`/api/foundation/courses?${params}`);
|
||||
const response = await fetch(`${API_BASE}/api/foundation/courses?${params}`);
|
||||
if (!response.ok) throw new Error("Failed to fetch courses");
|
||||
|
||||
let data = await response.json();
|
||||
|
|
|
|||
Loading…
Reference in a new issue