diff --git a/api/blog/[slug].ts b/api/blog/[slug].ts index b33c29a2..4547e7c2 100644 --- a/api/blog/[slug].ts +++ b/api/blog/[slug].ts @@ -36,7 +36,8 @@ interface GhostApiResponse { async function fetchFromGhost(slug: string): Promise { const ghostUrl = process.env.GHOST_API_URL || process.env.VITE_GHOST_API_URL; - const ghostKey = process.env.GHOST_CONTENT_API_KEY || process.env.VITE_GHOST_CONTENT_API_KEY; + const ghostKey = + process.env.GHOST_CONTENT_API_KEY || process.env.VITE_GHOST_CONTENT_API_KEY; if (!ghostUrl || !ghostKey) { return null; diff --git a/api/blog/index.ts b/api/blog/index.ts index c0a0880e..b591ee8b 100644 --- a/api/blog/index.ts +++ b/api/blog/index.ts @@ -36,7 +36,8 @@ interface GhostApiResponse { async function fetchFromGhost(limit: number = 50): Promise { const ghostUrl = process.env.GHOST_API_URL || process.env.VITE_GHOST_API_URL; - const ghostKey = process.env.GHOST_CONTENT_API_KEY || process.env.VITE_GHOST_CONTENT_API_KEY; + const ghostKey = + process.env.GHOST_CONTENT_API_KEY || process.env.VITE_GHOST_CONTENT_API_KEY; if (!ghostUrl || !ghostKey) { return []; diff --git a/api/blog/publish.ts b/api/blog/publish.ts index 61c26438..c8d1e1e8 100644 --- a/api/blog/publish.ts +++ b/api/blog/publish.ts @@ -1,5 +1,8 @@ import { createClient } from "@supabase/supabase-js"; -import { publishPostToGhost, updatePostInGhost } from "../../server/ghost-admin-api"; +import { + publishPostToGhost, + updatePostInGhost, +} from "../../server/ghost-admin-api"; const supabaseUrl = process.env.SUPABASE_URL || ""; const supabaseServiceRole = process.env.SUPABASE_SERVICE_ROLE || ""; @@ -42,7 +45,9 @@ export default async function handler(req: any, res: any) { // Check if user is admin or staff const isAuthorized = await isUserAdminOrStaff(userId); if (!isAuthorized) { - return res.status(403).json({ error: "Forbidden: Admin/Staff access required" }); + return res + .status(403) + .json({ error: "Forbidden: Admin/Staff access required" }); } const { diff --git a/api/corp/analytics/summary.ts b/api/corp/analytics/summary.ts index 201fef30..6dbc8848 100644 --- a/api/corp/analytics/summary.ts +++ b/api/corp/analytics/summary.ts @@ -55,7 +55,11 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { const overdue = (invoices || []) .filter((i: any) => i.status === "overdue") - .reduce((sum: number, i: any) => sum + ((i.amount_due || 0) - (i.amount_paid || 0)), 0); + .reduce( + (sum: number, i: any) => + sum + ((i.amount_due || 0) - (i.amount_paid || 0)), + 0, + ); const activeContracts = (contracts || []).filter( (c: any) => c.status === "active", @@ -120,12 +124,14 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { pending_invoices: (invoices || []).filter( (i: any) => i.status === "pending" || i.status === "sent", ).length, - overdue_invoices: (invoices || []).filter((i: any) => i.status === "overdue") - .length, + overdue_invoices: (invoices || []).filter( + (i: any) => i.status === "overdue", + ).length, }, health: { payment_rate: Math.round((totalPaid / totalInvoiced) * 100) || 0, - contract_completion_rate: completedContracts / (activeContracts + completedContracts) || 0, + contract_completion_rate: + completedContracts / (activeContracts + completedContracts) || 0, cash_flow_status: outstanding > totalInvoiced * 0.5 ? "at_risk" : "healthy", }, diff --git a/api/corp/contracts/manage.ts b/api/corp/contracts/manage.ts index d0fed3c4..82990ced 100644 --- a/api/corp/contracts/manage.ts +++ b/api/corp/contracts/manage.ts @@ -148,7 +148,9 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { .single(); if (!contract) { - return res.status(403).json({ error: "Contract not found or unauthorized" }); + return res + .status(403) + .json({ error: "Contract not found or unauthorized" }); } const updateData: any = {}; diff --git a/api/corp/invoices/manage.ts b/api/corp/invoices/manage.ts index 6950d4d5..526d0ba7 100644 --- a/api/corp/invoices/manage.ts +++ b/api/corp/invoices/manage.ts @@ -23,14 +23,8 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { try { if (req.method === "POST") { // Create new invoice - const { - description, - issue_date, - due_date, - items, - notes, - currency, - } = req.body; + const { description, issue_date, due_date, items, notes, currency } = + req.body; if (!due_date || !items || items.length === 0) { return res.status(400).json({ @@ -39,7 +33,10 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { } // Calculate total from items - const amountDue = items.reduce((sum: number, item: any) => sum + (item.amount || 0), 0); + const amountDue = items.reduce( + (sum: number, item: any) => sum + (item.amount || 0), + 0, + ); // Generate invoice number const { count } = await admin @@ -118,7 +115,9 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { .single(); if (verifyError || !invoice) { - return res.status(403).json({ error: "Invoice not found or unauthorized" }); + return res + .status(403) + .json({ error: "Invoice not found or unauthorized" }); } const updateData: any = {}; diff --git a/api/corp/team/manage.ts b/api/corp/team/manage.ts index f4bacc68..5093f554 100644 --- a/api/corp/team/manage.ts +++ b/api/corp/team/manage.ts @@ -107,7 +107,9 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { .single(); if (verifyError || !member) { - return res.status(403).json({ error: "Member not found or unauthorized" }); + return res + .status(403) + .json({ error: "Member not found or unauthorized" }); } const updateData: any = {}; @@ -155,7 +157,9 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { .single(); if (!member) { - return res.status(403).json({ error: "Member not found or unauthorized" }); + return res + .status(403) + .json({ error: "Member not found or unauthorized" }); } const { error: deleteError } = await admin diff --git a/api/nexus/payments/confirm-payment.ts b/api/nexus/payments/confirm-payment.ts index 971a81bf..4e593e01 100644 --- a/api/nexus/payments/confirm-payment.ts +++ b/api/nexus/payments/confirm-payment.ts @@ -56,7 +56,9 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { .single(); if (contractError || !contract) { - return res.status(403).json({ error: "Contract not found or unauthorized" }); + return res + .status(403) + .json({ error: "Contract not found or unauthorized" }); } // Update contract status to active @@ -99,7 +101,8 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { .eq("user_id", contract.creator_id) .single(); - const newEarnings = (creatorProfile?.total_earnings || 0) + contract.creator_payout_amount; + const newEarnings = + (creatorProfile?.total_earnings || 0) + contract.creator_payout_amount; await admin .from("nexus_creator_profiles") diff --git a/api/nexus/payments/create-intent.ts b/api/nexus/payments/create-intent.ts index 5007c084..5656c3af 100644 --- a/api/nexus/payments/create-intent.ts +++ b/api/nexus/payments/create-intent.ts @@ -49,7 +49,9 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { if (oppError || !opportunity || opportunity.posted_by !== user.id) { return res .status(403) - .json({ error: "Not authorized to post contracts for this opportunity" }); + .json({ + error: "Not authorized to post contracts for this opportunity", + }); } // Verify the creator has applied diff --git a/api/nexus/payments/payout-setup.ts b/api/nexus/payments/payout-setup.ts index 5d934e0e..1caf9d0f 100644 --- a/api/nexus/payments/payout-setup.ts +++ b/api/nexus/payments/payout-setup.ts @@ -103,7 +103,8 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { if (!account.charges_enabled || !account.payouts_enabled) { return res.status(400).json({ - error: "Account setup not complete. Please complete all required steps.", + error: + "Account setup not complete. Please complete all required steps.", chargesEnabled: account.charges_enabled, payoutsEnabled: account.payouts_enabled, }); diff --git a/api/nexus/payments/webhook.ts b/api/nexus/payments/webhook.ts index adc506c5..0164e385 100644 --- a/api/nexus/payments/webhook.ts +++ b/api/nexus/payments/webhook.ts @@ -19,14 +19,19 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { try { if (!sig || !webhookSecret) { - return res.status(400).json({ error: "Missing webhook signature or secret" }); + return res + .status(400) + .json({ error: "Missing webhook signature or secret" }); } - const body = typeof req.body === "string" ? req.body : JSON.stringify(req.body); + const body = + typeof req.body === "string" ? req.body : JSON.stringify(req.body); event = stripe.webhooks.constructEvent(body, sig, webhookSecret); } catch (error: any) { console.error("Webhook signature verification failed:", error.message); - return res.status(400).json({ error: "Webhook signature verification failed" }); + return res + .status(400) + .json({ error: "Webhook signature verification failed" }); } try { @@ -60,18 +65,16 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { .single(); if (!existingPayment) { - await admin - .from("nexus_payments") - .insert({ - contract_id: contract.id, - amount: contract.total_amount, - creator_payout: contract.creator_payout_amount, - aethex_commission: contract.aethex_commission_amount, - payment_method: "stripe", - payment_status: "completed", - payment_date: new Date().toISOString(), - stripe_payment_intent_id: paymentIntent.id, - }); + await admin.from("nexus_payments").insert({ + contract_id: contract.id, + amount: contract.total_amount, + creator_payout: contract.creator_payout_amount, + aethex_commission: contract.aethex_commission_amount, + payment_method: "stripe", + payment_status: "completed", + payment_date: new Date().toISOString(), + stripe_payment_intent_id: paymentIntent.id, + }); } // Update creator earnings @@ -82,7 +85,8 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { .single(); const newEarnings = - (creatorProfile?.total_earnings || 0) + contract.creator_payout_amount; + (creatorProfile?.total_earnings || 0) + + contract.creator_payout_amount; await admin .from("nexus_creator_profiles") @@ -123,17 +127,15 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { .eq("id", contract.id); // Create failed payment record - await admin - .from("nexus_payments") - .insert({ - contract_id: contract.id, - amount: contract.total_amount, - creator_payout: 0, - aethex_commission: 0, - payment_method: "stripe", - payment_status: "failed", - stripe_payment_intent_id: paymentIntent.id, - }); + await admin.from("nexus_payments").insert({ + contract_id: contract.id, + amount: contract.total_amount, + creator_payout: 0, + aethex_commission: 0, + payment_method: "stripe", + payment_status: "failed", + stripe_payment_intent_id: paymentIntent.id, + }); } break; } diff --git a/client/components/admin/AdminBlogEditor.tsx b/client/components/admin/AdminBlogEditor.tsx index 3bda7195..21d46c79 100644 --- a/client/components/admin/AdminBlogEditor.tsx +++ b/client/components/admin/AdminBlogEditor.tsx @@ -2,7 +2,13 @@ import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { useAethexToast } from "@/hooks/use-aethex-toast"; import { Loader2, X } from "lucide-react"; @@ -28,7 +34,9 @@ const BlogEditor = ({ onPublish, initialData }: BlogEditorProps) => { const [excerpt, setExcerpt] = useState(initialData?.excerpt || ""); const [html, setHtml] = useState(initialData?.html || ""); const [slug, setSlug] = useState(initialData?.slug || ""); - const [featureImage, setFeatureImage] = useState(initialData?.feature_image || ""); + const [featureImage, setFeatureImage] = useState( + initialData?.feature_image || "", + ); const [tags, setTags] = useState(initialData?.tags || []); const [tagInput, setTagInput] = useState(""); const [metaTitle, setMetaTitle] = useState(initialData?.meta_title || ""); @@ -139,7 +147,8 @@ const BlogEditor = ({ onPublish, initialData }: BlogEditorProps) => { /> {!slug && title && (

- Auto-slug: {autoSlug} + Auto-slug:{" "} + {autoSlug}

)} @@ -173,7 +182,9 @@ const BlogEditor = ({ onPublish, initialData }: BlogEditorProps) => { setTagInput(e.target.value)} - onKeyPress={(e) => e.key === "Enter" && (e.preventDefault(), addTag())} + onKeyPress={(e) => + e.key === "Enter" && (e.preventDefault(), addTag()) + } placeholder="Add tag and press Enter" className="border-border/50" /> @@ -238,7 +249,7 @@ const BlogEditor = ({ onPublish, initialData }: BlogEditorProps) => {