PageSourceSearch

https://www.skillihire.com/assets/CreateCourse-DULfgX3v.js

js skillihire.com collected 2026-09-24 14:53:40 UTC 6,059 bytes, 1 lines download raw bytes

1import{Y as L,Z as S,r as g,j as e,e as p,B as m,am as T,C as U,ap as I,aq as P,ar as $,d as A,I as l,a0 as v,a1 as C,a2 as y,a3 as _,a4 as c,L as b}from"./index-C6--jTPa.js";import{a as q,b as B}from"./useInstructor-BVULZHND.js";import{b as R}from"./useCourses-e5J4S7B_.js";import{T as V}from"./textarea-CMbBoEE6.js";import{L as i}from"./label-CdYthYdK.js";import{U as k}from"./upload-BNVwKLn1.js";function J(){const f=L(),{user:x}=S(),{data:o}=R(),d=q(),[a,r]=g.useState({title:"",slug:"",description:"",short_description:"",price:0,discounted_price:void 0,level:"beginner",duration_hours:0,category_id:"",thumbnail_url:"",preview_video_url:""}),[u,j]=g.useState(!1);if(!x)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 create courses"}),e.jsx(p,{to:"/login",children:e.jsx(m,{children:"Log In"})})]});const N=s=>{const t=s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");r({...a,title:s,slug:t})},w=async s=>{var n;const t=(n=s.target.files)==null?void 0:n[0];if(t){j(!0);try{const h=`thumbnails/${x.id}/${Date.now()}-${t.name}`,D=await B(t,h);r({...a,thumbnail_url:D})}catch(h){console.error("Upload failed:",h)}finally{j(!1)}}},F=async s=>{s.preventDefault();const t={...a,category_id:a.category_id||void 0,discounted_price:a.discounted_price||void 0},n=await d.mutateAsync(t);f(`/instructor/courses/${n.id}/edit`)};return e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-3xl",children:[e.jsxs(p,{to:"/instructor",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(T,{className:"w-4 h-4 mr-2"}),"Back to Dashboard"]}),e.jsxs(U,{children:[e.jsxs(I,{children:[e.jsx(P,{children:"Create New Course"}),e.jsx($,{children:"Fill in the basic details to create your course. You can add modules and lessons after creation."})]}),e.jsx(A,{children:e.jsxs("form",{onSubmit:F,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"title",children:"Course Title *"}),e.jsx(l,{id:"title",value:a.title,onChange:s=>N(s.target.value),placeholder:"e.g., Complete Python Bootcamp",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"slug",children:"URL Slug *"}),e.jsx(l,{id:"slug",value:a.slug,onChange:s=>r({...a,slug:s.target.value}),placeholder:"complete-python-bootcamp",required:!0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will be used in the course URL: /course/",a.slug||"your-slug"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"short_description",children:"Short Description"}),e.jsx(l,{id:"short_description",value:a.short_description,onChange:s=>r({...a,short_description:s.target.value}),placeholder:"A brief overview of the course"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"description",children:"Full Description *"}),e.jsx(V,{id:"description",value:a.description,onChange:s=>r({...a,description:s.target.value}),placeholder:"Detailed description of what students will learn...",rows:5,required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"category",children:"Category"}),e.jsxs(v,{value:a.category_id,onValueChange:s=>r({...a,category_id:s}),children:[e.jsx(C,{children:e.jsx(y,{placeholder:"Select category"})}),e.jsx(_,{children:o==null?void 0:o.map(s=>e.jsx(c,{value:s.id,children:s.name},s.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"level",children:"Level"}),e.jsxs(v,{value:a.level,onValueChange:s=>r({...a,level:s}),children:[e.jsx(C,{children:e.jsx(y,{})}),e.jsxs(_,{children:[e.jsx(c,{value:"beginner",children:"Beginner"}),e.jsx(c,{value:"intermediate",children:"Intermediate"}),e.jsx(c,{value:"advanced",children:"Advanced"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"price",children:"Price ($) *"}),e.jsx(l,{id:"price",type:"number",min:"0",step:"0.01",value:a.price,onChange:s=>r({...a,price:parseFloat(s.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"discounted_price",children:"Discounted Price ($)"}),e.jsx(l,{id:"discounted_price",type:"number",min:"0",step:"0.01",value:a.discounted_price||"",onChange:s=>r({...a,discounted_price:s.target.value?parseFloat(s.target.value):void 0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"duration_hours",children:"Duration (hours)"}),e.jsx(l,{id:"duration_hours",type:"number",min:"0",value:a.duration_hours,onChange:s=>r({...a,duration_hours:parseInt(s.target.value)||0})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Thumbnail Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[a.thumbnail_url&&e.jsx("img",{src:a.thumbnail_url,alt:"Thumbn
1ail preview",className:"w-24 h-16 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border rounded-md hover:bg-muted transition-colors",children:[u?e.jsx(b,{className:"w-4 h-4 animate-spin"}):e.jsx(k,{className:"w-4 h-4"}),e.jsx("span",{children:u?"Uploading...":"Upload Image"})]}),e.jsx("input",{type:"file",accept:"image/*",onChange:w,className:"hidden",disabled:u})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"preview_video_url",children:"Preview Video URL"}),e.jsx(l,{id:"preview_video_url",value:a.preview_video_url,onChange:s=>r({...a,preview_video_url:s.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex gap-4 pt-4",children:[e.jsx(m,{type:"submit",disabled:d.isPending,children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):"Create Course"}),e.jsx(p,{to:"/instructor",children:e.jsx(m,{type:"button",variant:"outline",children:"Cancel"})})]})]})})]})]})}export{J 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.