lms/public/build/assets/assignment-submission-form-Cp0WFuyh.js
2025-12-15 12:26:23 +01:00

2 lines
2.9 KiB
JavaScript

import{r as i,b as S,j as e}from"./vendor-BKmmeuxg.js";import{C as _}from"./chunked-uploader-input-D0XPVOTS.js";import{I as l}from"./input-error-LaPr_4wd.js";import{L as v}from"./loading-button-BnTVAMJ7.js";import{B as F}from"./button-BpNwv2aE.js";import{I as U}from"./input-DM0goJrn.js";import{L as n}from"./label-HmIcv5Yx.js";import{S as N,a as C,b as I,c as L,d as h}from"./select-CD9o3HN1.js";import{T as E}from"./textarea-CyndvowL.js";import"./index-D9-QKOod.js";import"./utils-DxSsnXxD.js";import"./index-WW_1X1qx.js";const V=({assignment:c,setDialogOpen:x})=>{const[m,a]=i.useState(!1),[f,u]=i.useState(!1),{data:s,setData:r,post:j,processing:p,errors:o,reset:y,clearErrors:g}=S({course_assignment_id:c.id,attachment_type:"url",attachment_path:"",comment:""}),b=async t=>{if(t.preventDefault(),s.attachment_type==="url"){d();return}a(!0)},d=()=>{g(),j(route("assignment.submission.store"),{preserveScroll:!0,onSuccess:()=>{y(),a(!1),x(!1)},onError:()=>{a(!1)}})};return i.useEffect(()=>{s.attachment_path&&f&&(d(),u(!1))},[s.attachment_path]),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(n,{children:"Submission Type *"}),e.jsxs(N,{required:!0,name:"attachment_type",value:s.attachment_type,onValueChange:t=>r("attachment_type",t),children:[e.jsx(C,{className:"w-full",children:e.jsx(I,{placeholder:"Select Submission Type"})}),e.jsxs(L,{children:[e.jsx(h,{value:"url",children:"URL Link"}),e.jsx(h,{value:"file",children:"Upload File"})]})]}),e.jsx(l,{message:o.attachment_type})]}),s.attachment_type==="url"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"url",children:"URL Link *"}),e.jsx(U,{id:"url",type:"url",placeholder:"Enter URL here...",value:s.attachment_path,onChange:t=>r("attachment_path",t.target.value),required:!0}),e.jsx(l,{message:o.attachment_path}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Share your GitHub repository, Google Drive, or any public URL"})]}),s.attachment_type==="file"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"file",children:"Upload File *"}),e.jsx(_,{isSubmit:m,courseId:c.course_id,filetype:"document",delayUpload:!0,onFileUploaded:t=>{u(!0),r("attachment_path",t.file_url)},onError:t=>{a(!1)},onCancelUpload:()=>{a(!1)}}),e.jsx(l,{message:o.attachment_path}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Formats: .JPEG, .PNG, .DOC, .PDF, .ZIP (Max: 10MB)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"comment",children:"Comment (Optional)"}),e.jsx(E,{id:"comment",placeholder:"Add any notes or comments about your submission...",value:s.comment,onChange:t=>r("comment",t.target.value),rows:4}),e.jsx(l,{message:o.comment})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-3",children:[e.jsx(F,{type:"button",variant:"outline",disabled:p||m,children:"Cancel"}),e.jsx(v,{type:"submit",className:"gap-2",loading:p||m,children:"Submit Assignment"})]})]})};export{V as default};