PageSourceSearch

https://skillihire.com/assets/InstructorDashboard-CDuGakvz.js

js skillihire.com collected 2026-10-02 01:43:48 UTC 14,998 bytes, 1 lines download raw bytes

1import{Z as k,O as H,s as $,j as e,L as B,K as D,o as O,T as Y,C as d,f as m,ar as I,as as P,at as E,a8 as V,a9 as G,aa as z,aw as R,i as K,r as W,g as f,B as b,z as C,k as M,e as T}from"./index-DMpD5zQ4.js";import{u as J}from"./useInstructor-C9Kmvfeq.js";import{u as Q,I as X}from"./CourseMessaging-CM7kU6vn.js";import{T as Z,a as q,b as L,c as g,d as ee,e as N}from"./table-C7-St2aw.js";import{C as se}from"./credit-card-BcpbAeHM.js";import{a as te}from"./useVideoCallRequests-yTgjQD7f.js";import{B as v}from"./badge-bMO3_tW7.js";import{V as U}from"./video-DteP5QmJ.js";import{T as ae,a as re,b as _,c as F}from"./tabs-ZII6aAIe.js";import{P as A}from"./plus-BPK3OS2-.js";import{C as le}from"./chart-column-D09L9wue.js";import{W as ne}from"./wallet-BE9kZID_.js";import{S as ie}from"./square-pen-EZvLgx82.js";import"./textarea-BmqJYY1S.js";import"./scroll-area-CoAEOFg9.js";import"./index-BgKL7wpb.js";import"./shield-BAaFniQN.js";import"./triangle-alert-DXo7if2c.js";import"./send-BcKsSsSq.js";const ce=.029,de=.3,oe=.3;function xe(l,a){const r=l*ce+de*a,t=Math.max(l-r,0),n=t*oe,o=t-n;return{stripeFees:r,netAfterStripe:t,platformFee:n,instructorNet:o}}function me(){const{user:l}=k();return H({queryKey:["instructor-earnings",l==null?void 0:l.id],queryFn:async()=>{if(!l)throw new Error("Not authenticated");const{data:a,error:r}=await $.from("courses").select("id, title").eq("instructor_id",l.id);if(r)throw r;if(!(a!=null&&a.length))return{totalGross:0,totalStripeFees:0,totalPlatformFees:0,totalNet:0,totalTransactions:0,courseEarnings:[]};const t=a.map(i=>i.id),{data:n,error:o}=await $.from("enrollments").select("course_id, payment_amount").in("course_id",t).eq("payment_status","completed");if(o)throw o;const u=new Map;for(const i of n||[]){const c=u.get(i.course_id)||{gross:0,count:0};c.gross+=Number(i.payment_amount)||0,c.count+=1,u.set(i.course_id,c)}let h=0,w=0,p=0,s=0,x=0;const y=a.map(i=>{const c=u.get(i.id)||{gross:0,count:0},j=xe(c.gross,c.count);return h+=c.gross,w+=j.stripeFees,p+=j.platformFee,s+=j.instructorNet,x+=c.count,{courseId:i.id,courseTitle:i.title,grossRevenue:c.gross,transactionCount:c.count,...j}}).filter(i=>i.transactionCount>0);return{totalGross:h,totalStripeFees:w,totalPlatformFees:p,totalNet:s,totalTransactions:x,courseEarnings:y}},enabled:!!l})}function ue(){const{data:l,isLoading:a}=me();if(a)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(B,{className:"h-8 w-8 animate-spin text-primary"})});if(!l)return null;const r=[{label:"Gross Revenue",value:l.totalGross,icon:D,color:"text-green-500",bg:"bg-green-500/10"},{label:"Stripe Fees (2.9% + $0.30)",value:l.totalStripeFees,icon:se,color:"text-red-500",bg:"bg-red-500/10"},{label:"Platform Fee (30%)",value:l.totalPlatformFees,icon:O,color:"text-orange-500",bg:"bg-orange-500/10"},{label:"Your Net Earnings",value:l.totalNet,icon:Y,color:"text-primary",bg:"bg-primary/10"}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:r.map(t=>e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`p-3 rounded-full ${t.bg}`,children:e.jsx(t.icon,{className:`w-6 h-6 ${t.color}`})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["$",t.value.toFixed(2)]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.label})]})]})})},t.label))}),e.jsxs(d,{children:[e.jsxs(I,{children:[e.jsx(P,{children:"Per-Course Breakdown"}),e.jsx(E,{children:"Fee structure: Stripe (2.9% + $0.30/txn) → 30% platform fee on remainder → your net earnings"})]}),e.jsx(m,{children:l.courseEarnings.length===0?e.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"No earnings yet. Revenue will appear here once students enroll in your paid courses."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Z,{children:[e.jsx(q,{children:e.jsxs(L,{children:[e.jsx(g,{children:"Course"}),e.jsx(g,{className:"text-right",children:"Students"}),e.jsx(g,{className:"text-right",children:"Gross"}),e.jsx(g,{className:"text-right",children:"Stripe Fees"}),e.jsx(g,{className:"text-right",children:"Platform Fee"}),e.jsx(g,{className:"text-right",children:"Your Net"})]})}),e.jsx(ee,{children:l.courseEarnings.map(t=>e.jsxs(L,{children:[e.jsx(N,{className:"font-medium max-w-[200px] truncate",children:t.courseTitle}),e.jsx(N,{className:"text-right",children:t.transactionCount}),e.jsxs(N,{className:"text-right",children:["$",t.grossRevenue.toFixed(2)]}),e.jsxs(N,{className:"text-right text-red-500",children:["-$",t.stripeFees.toFixed(2)]}),e.jsxs(N,{className:"text-right text-orange-500",children:["-$",t.platformFee.toFixed(2)]}),e.jsxs(N,{className:"text-right font-semibold text-primary",children:["$",t.instructorNet.toFixed(2)]})]},t.courseId))})]})})})]})]})}const he={pending:"secondary",approved:"default",rejected:"destructive",completed:"outline"};function je(){const{data:l,isLoading:a}=te("instructor");return a?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(B,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs(d,{children:[e.jsxs(I,{children:[e.jsx(P,{children:"Video Call Requests"}),e.jsx(E,{children:"Requests from students for one-on-one video lessons (managed by admin)"})]}),e.jsx(m,{children:l!=null&&l.length?e.jsx("div",{className:"space-y-4",children:l.map(r=>{var t,n,o,u,h;return e.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[e.jsxs(V,{className:"h-10 w-10",children:[e.jsx(G,{src:((t=r.student)==null?void 0:t.avatar_url)||void 0}),e.jsx(z,{children:((o=(n=r.student)==null?void 0:n.full_name)==null?void 0:o[0])||"S"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"font-medium",children:((u=r.student)==null?void 0:u.full_name)||"Student"}),e.jsx(v,{variant:he[r.status]||"secondary",className:"capitalize",children:r.status}),e.jsxs(v,{variant:"outline",children:["$",Number(r.fee_amount).toFixed(2)]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Course: ",(h=r.course)==null?void 0:h.title]}),e.jsx("p",{className:"text-sm mt-1",children:r.reason}),r.scheduled_at&&e.jsxs("p",{className:"text-sm text-primary mt-1",children:["Scheduled: ",R(new Date(r.scheduled_at),"PPp")]}),r.meeting_url&&r.status==="approved"&&e.jsxs("a",{href:r.meeting_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary hover:underline mt-1",children:[e.jsx(K,{className:"h-3 w-3"})," Join Meeting"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:R(new Date(r.created_at),"PP")})]})]},r.id)})}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(U,{className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"No video call requests yet"})]})})]})}function Le(){const{user:l}=k(),{data:a,isLoading:r}=J(),{data:t}=Q(),[n,o]=W.useState(null);if(!l)return e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Please log in to access the instructor dashboard"}),e.jsx(f,{to:"/login",children:e.jsx(b,{children:"Log In"})})]});const u=(a==null?void 0:a.length)||0,h=(a==null?void 0:a.filter(s=>s.is_published).length)||0,w=(a==null?void 0:a.reduce((s,x)=>s+(x.enrollments_count||0),0))||0,p=(t==null?void 0:t.reduce((s,x)=>s+x.unreadCount,0))||0;return e.jsxs("div",{className:"container mx-auto px-4 pt-20 pb-8 md:pt-24",children:[e.jsxs("div",{className:"flex justify-between items-center mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Instructor Dashboard"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your courses and communicate with students"})]}
1),e.jsx(f,{to:"/instructor/courses/new",children:e.jsxs(b,{children:[e.jsx(A,{className:"w-4 h-4 mr-2"}),"Create Course"]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(C,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:u}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Courses"})]})]})})}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-green-500/10",children:e.jsx(le,{className:"w-6 h-6 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:h}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Published"})]})]})})}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-blue-500/10",children:e.jsx(M,{className:"w-6 h-6 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:w}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Students"})]})]})})}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-orange-500/10",children:e.jsx(T,{className:"w-6 h-6 text-orange-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:p}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Unread Messages"})]})]})})})]}),e.jsxs(ae,{defaultValue:"courses",children:[e.jsxs(re,{className:"mb-4",children:[e.jsxs(_,{value:"courses",className:"gap-1",children:[e.jsx(C,{className:"h-4 w-4"}),"Courses"]}),e.jsxs(_,{value:"messages",className:"gap-1",children:[e.jsx(T,{className:"h-4 w-4"}),"Messages",p>0&&e.jsx(v,{variant:"destructive",className:"ml-1 h-5 px-1.5 text-xs",children:p})]}),e.jsxs(_,{value:"earnings",className:"gap-1",children:[e.jsx(ne,{className:"h-4 w-4"}),"Earnings"]}),e.jsxs(_,{value:"video-calls",className:"gap-1",children:[e.jsx(U,{className:"h-4 w-4"}),"Video Calls"]})]}),e.jsx(F,{value:"courses",children:e.jsxs(d,{children:[e.jsxs(I,{children:[e.jsx(P,{children:"Your Courses"}),e.jsx(E,{children:"Manage and edit your course content"})]}),e.jsx(m,{children:r?e.jsx("div",{className:"text-center py-8",children:"Loading courses..."}):a!=null&&a.length?e.jsx("div",{className:"space-y-4",children:a.map(s=>e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsx("div",{className:"w-24 h-16 rounded-md bg-muted overflow-hidden flex-shrink-0",children:s.thumbnail_url?e.jsx("img",{src:s.thumbnail_url,alt:s.title,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(C,{className:"w-6 h-6 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold truncate",children:s.title}),e.jsx(v,{variant:s.is_published?"default":"secondary",children:s.is_published?"Published":"Draft"})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(M,{className:"w-4 h-4"}),s.enrollments_count," students"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"w-4 h-4"}),"$",s.price]}),e.jsx("span",{className:"capitalize",children:s.level})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{to:`/instructor/courses/${s.id}/edit`,children:e.jsxs(b,{variant:"outline",size:"sm",children:[e.jsx(ie,{className:"w-4 h-4 mr-1"}),"Edit"]})}),e.jsx(f,{to:`/course/${s.slug}`,children:e.jsx(b,{variant:"ghost",size:"sm",children:"Preview"})})]})]},s.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(C,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No courses yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first course to get started"}
1),e.jsx(f,{to:"/instructor/courses/new",children:e.jsxs(b,{children:[e.jsx(A,{className:"w-4 h-4 mr-2"}),"Create Course"]})})]})})]})}),e.jsx(F,{value:"messages",children:e.jsxs("div",{className:"grid lg:grid-cols-3 gap-4",children:[e.jsxs(d,{className:"lg:col-span-1",children:[e.jsx(I,{className:"pb-3",children:e.jsx(P,{className:"text-lg",children:"Conversations"})}),e.jsx(m,{className:"p-0",children:t!=null&&t.length?e.jsx("div",{className:"divide-y max-h-[600px] overflow-auto",children:t.map(s=>{var x,y,i,c;return e.jsx("button",{className:`w-full p-3 text-left hover:bg-muted/50 transition-colors ${(n==null?void 0:n.studentId)===s.studentId&&(n==null?void 0:n.courseId)===s.courseId?"bg-muted":""}`,onClick:()=>{var j,S;return o({courseId:s.courseId,studentId:s.studentId,studentName:((j=s.studentProfile)==null?void 0:j.full_name)||"Student",studentAvatar:(S=s.studentProfile)==null?void 0:S.avatar_url,courseTitle:s.courseTitle})},children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(V,{className:"h-9 w-9",children:[e.jsx(G,{src:((x=s.studentProfile)==null?void 0:x.avatar_url)||void 0}),e.jsx(z,{className:"text-xs",children:((i=(y=s.studentProfile)==null?void 0:y.full_name)==null?void 0:i[0])||"S"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((c=s.studentProfile)==null?void 0:c.full_name)||"Student"}),s.unreadCount>0&&e.jsx(v,{variant:"destructive",className:"h-5 px-1.5 text-xs",children:s.unreadCount})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.courseTitle}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:s.lastMessage})]})]})},`${s.courseId}-${s.studentId}`)})}):e.jsxs("div",{className:"text-center py-8 px-4 text-muted-foreground",children:[e.jsx(T,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No messages yet"})]})})]}),e.jsx(d,{className:"lg:col-span-2 min-h-[500px]",children:n?e.jsx(X,{courseId:n.courseId,studentId:n.studentId,studentName:n.studentName,studentAvatar:n.studentAvatar,courseTitle:n.courseTitle}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(T,{className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"Select a conversation to view messages"})]})})})]})}),e.jsx(F,{value:"earnings",children:e.jsx(ue,{})}),e.jsx(F,{value:"video-calls",children:e.jsx(je,{})})]})]})}export{Le as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.