import{e as k,i as B,r as c,j as s,C,f as y}from"./index-sga-FecS.js";import{u as P,f as l}from"./DefaultLayout-R679muSx.js";import{b as x,a as i}from"./index.esm-7CdJvro0.js";import{C as v}from"./CAlert-UiIGbbv-.js";import{C as p,a}from"./CRow-BaMSc2yS.js";import{C as t,a as n}from"./CCardBody-e8lVonr1.js";import{C as o}from"./CCardHeader-B7SoQ3bq.js";import"./university-logo-full-HPG0vyLU.js";import"./cil-user-Dlmw-Gem.js";function I(){const{t:e,i18n:N}=k(),j=B(),{user:d,loading:b,error:S}=P(),[r,w]=c.useState(null),[A,E]=c.useState(null),[z,_]=c.useState(!0),[f,g]=c.useState(null),u=N.language==="ar"?"/ar":"/en",R=async()=>{try{_(!0);const h=await y.get(`${u}/api/students/student-profile/`);w(h.data);try{const m=await y.get(`${u}/api/students/dashboard-stats/`);E(m.data)}catch(m){console.log("Stats not available yet:",m)}g(null)}catch(h){console.error("Error loading student data:",h),g(e("error_loading_profile"))}finally{_(!1)}};return c.useEffect(()=>{d?.role==="student"&&R()},[d,u]),b?s.jsxs(x,{fluid:!0,className:"py-4",children:[s.jsx(C,{size:"sm"})," ",e("loading")]}):S||!d||d.role!=="student"?s.jsx(x,{fluid:!0,className:"py-4",children:s.jsx(v,{color:"warning",children:e("not_authorized")})}):s.jsxs(x,{fluid:!0,className:"py-4",children:[s.jsx(p,{className:"mb-4",children:s.jsxs(a,{children:[s.jsx("h2",{children:e("student_dashboard_title")}),s.jsx("p",{className:"text-medium-emphasis",children:e("student_dashboard_welcome",{name:r?.full_name_ar||d.username})})]})}),z&&s.jsx(C,{size:"sm"}),f&&s.jsx(v,{color:"danger",className:"mb-3",children:f}),r&&s.jsxs(s.Fragment,{children:[s.jsxs(p,{className:"mb-4",children:[s.jsx(a,{md:3,children:s.jsxs(t,{children:[s.jsx(o,{children:e("student_status")}),s.jsx(n,{children:s.jsx(l,{color:r.status==="Active"?"success":"warning",children:r.status_display})})]})}),s.jsx(a,{md:3,children:s.jsxs(t,{children:[s.jsx(o,{children:e("academic_level")}),s.jsx(n,{children:s.jsx("h4",{children:r.academic_level})})]})}),s.jsx(a,{md:3,children:s.jsxs(t,{children:[s.jsx(o,{children:e("current_semester")}),s.jsx(n,{children:s.jsx("h5",{children:r.current_academic_semester?.name_ar})})]})}),s.jsx(a,{md:3,children:s.jsxs(t,{children:[s.jsx(o,{children:e("department")}),s.jsx(n,{children:s.jsx("h5",{children:r.department_name_ar})})]})})]}),s.jsxs(p,{className:"mb-4",children:[s.jsx(a,{md:6,children:s.jsxs(t,{children:[s.jsx(o,{children:e("documents_status")}),s.jsxs(n,{children:[s.jsxs("div",{className:"d-flex flex-wrap gap-2",children:[s.jsxs(l,{color:r.id_card_uploaded?"success":"secondary",children:[e("doc_id_card")," ",r.id_card_uploaded?e("yes"):e("no")]}),s.jsxs(l,{color:r.high_school_cert_uploaded?"success":"secondary",children:[e("doc_high_school")," ",r.high_school_cert_uploaded?e("yes"):e("no")]}),s.jsxs(l,{color:r.personal_photo_uploaded?"success":"secondary",children:[e("doc_personal_photo")," ",r.personal_photo_uploaded?e("yes"):e("no")]}),s.jsxs(l,{color:r.documents_approved?"success":"danger",children:[e("documents_approved")," ",r.documents_approved?e("yes"):e("no")]})]}),!r.documents_approved&&s.jsx(i,{size:"sm",color:"primary",className:"mt-2",onClick:()=>j("/student/complete-registration"),children:e("complete_registration")})]})]})}),s.jsx(a,{md:6,children:s.jsxs(t,{children:[s.jsx(o,{children:e("quick_actions")}),s.jsx(n,{children:s.jsxs("div",{className:"d-grid gap-2",children:[s.jsx(i,{color:"primary",onClick:()=>j("/student/profile"),children:e("view_profile")}),s.jsx(i,{color:"info",variant:"outline",children:e("register_semester")}),s.jsx(i,{color:"secondary",variant:"outline",children:e("view_courses")})]})})]})})]})]})]})}export{I as default};
