Files
sm-bm-plugin/public/assets/ProfileView-BwrFxcKQ.js

2 lines
11 KiB
JavaScript

import{d as I,u as O,ad as W,al as A,av as J,q,o as H,a as U,ar as Z,c as l,i as R,b as o,h as D,t as r,f as d,w as b,v as k,e as s,F as T,E as K,p as M,r as c,aw as Q,n,ax as X}from"./index-C7vQR2oS.js";import{_ as Y}from"./PageHead.vue_vue_type_script_setup_true_lang-CU_q4BB6.js";import{f as V}from"./forms-DnXJFe2z.js";import{o as ee}from"./oauth-zzthF4BZ.js";const oe={class:"card","aria-labelledby":"dane-h"},se={key:0,class:"notice error",role:"alert",style:{"margin-bottom":"12px"}},te={key:1,class:"notice",role:"status",style:{"margin-bottom":"12px"}},ae={class:"grid-2"},le={class:"field"},ne={key:0,class:"error-text"},ie={class:"field"},re={key:0,class:"error-text"},de={class:"field"},ue={key:0,class:"error-text"},pe=["disabled"],me={id:"wybor",class:"card section","aria-labelledby":"wybor-h"},ce={key:0,class:"skeleton"},ye={key:1,class:"muted"},we={class:"eyebrow",style:{padding:"0","margin-bottom":"6px"}},be=["name","value","checked","onChange"],ke={key:0,class:"muted small",style:{margin:"4px 0 0"}},fe=["onClick"],ve={id:"kalendarz",class:"card section","aria-labelledby":"kalendarz-h"},ze={key:0,class:"notice error",role:"alert",style:{margin:"12px 0"}},ge={key:1,class:"skeleton",style:{"margin-top":"12px"}},_e={key:2,style:{"margin-top":"12px"}},he=["disabled"],xe={class:"field",style:{"margin-top":"12px"}},je={style:{display:"flex",gap:"8px"}},Pe=["value"],Ce={key:0,class:"muted small",style:{margin:"0"}},Ue={class:"check"},Te=["checked","disabled"],Ve={class:"check"},Ne=["checked","disabled"],Ze={class:"btn-row",style:{"margin-top":"12px"}},De=["disabled"],Ke=["disabled"],Me={key:0,class:"card section","aria-labelledby":"microsoft-h"},Fe=["disabled"],Be={class:"card section","aria-labelledby":"haslo-h"},Ge={key:0,class:"notice error",role:"alert",style:{"margin-bottom":"12px"}},Le={key:1,class:"notice",role:"status",style:{"margin-bottom":"12px"}},Se={class:"field"},Ee={key:0,class:"error-text"},$e={class:"field"},Ie={key:0,class:"error-text"},Oe={class:"field"},We=["disabled"],Ae={class:"section"},Ye=I({__name:"ProfileView",setup(Je){const f=O(),v=W(),z=A(),a=J(),x=q(),j=c(!1),g=c(!1);H(()=>{v.loadCourses(),a.load(),U.oauthProviders().then(i=>j.value=i.providers.some(e=>e.name==="microsoft")).catch(()=>j.value=!1)});async function F(){g.value=!0;try{const{link_ticket:i}=await U.oauthLinkTicket();window.location.assign(ee("microsoft",{action:"link",linkTicket:i,returnTo:"/profil"}))}catch(i){x.show(V(i).message||"Nie udało się połączyć konta Microsoft."),g.value=!1}}const N=c(null);async function B(){const i=a.feed?.url;i&&(await Q(i)?x.show("Skopiowano link do schowka."):(N.value?.select(),x.show("Nie udało się skopiować. Link jest zaznaczony: skopiuj go ręcznie.")))}function G(){window.confirm("Wygenerować nowy link? Stary przestanie działać i kalendarze, które go subskrybują, trzeba będzie dodać od nowa.")&&a.rotate()}function L(){window.confirm("Usunąć link do kalendarza? Kalendarze, które go subskrybują, przestaną się aktualizować.")&&a.remove()}function S(i){return new Date(i).toLocaleString("pl-PL",{day:"numeric",month:"long",hour:"2-digit",minute:"2-digit"})}const m=Z({name:f.user?.name??"",surname:f.user?.surname??"",email:f.user?.email??""}),_=c(!1),u=c(null),P=c(!1);async function E(){_.value=!0,u.value=null,P.value=!1;try{await f.updateProfile({name:m.name.trim(),surname:m.surname.trim(),email:m.email.trim()}),P.value=!0}catch(i){u.value=V(i)}finally{_.value=!1}}const p=Z({current_password:"",password:"",password_confirmation:""}),h=c(!1),y=c(null),C=c(!1);async function $(){h.value=!0,y.value=null,C.value=!1;try{await U.changePassword({...p}),C.value=!0,Object.assign(p,{current_password:"",password:"",password_confirmation:""})}catch(i){y.value=V(i)}finally{h.value=!1}}return(i,e)=>(n(),l("div",null,[R(Y,{eyebrow:"Konto",title:"Profil"}),o("section",oe,[e[14]||(e[14]=o("h2",{id:"dane-h",style:{"margin-bottom":"12px"}},"Dane",-1)),o("form",{onSubmit:D(E,["prevent"]),novalidate:""},[u.value?.message?(n(),l("p",se,r(u.value.message),1)):d("",!0),P.value?(n(),l("p",te,"Zapisano.")):d("",!0),o("div",ae,[o("div",le,[e[11]||(e[11]=o("label",{for:"p-name"},"Imię",-1)),b(o("input",{id:"p-name","onUpdate:modelValue":e[0]||(e[0]=t=>m.name=t),type:"text",autocomplete:"given-name"},null,512),[[k,m.name]]),u.value?.fields.name?(n(),l("p",ne,r(u.value.fields.name),1)):d("",!0)]),o("div",ie,[e[12]||(e[12]=o("label",{for:"p-surname"},"Nazwisko",-1)),b(o("input",{id:"p-surname","onUpdate:modelValue":e[1]||(e[1]=t=>m.surname=t),type:"text",autocomplete:"family-name"},null,512),[[k,m.surname]]),u.value?.fields.surname?(n(),l("p",re,r(u.value.fields.surname),1)):d("",!0)])]),o("div",de,[e[13]||(e[13]=o("label",{for:"p-email"},"Adres e-mail",-1)),b(o("input",{id:"p-email","onUpdate:modelValue":e[2]||(e[2]=t=>m.email=t),type:"email",autocomplete:"email",inputmode:"email"},null,512),[[k,m.email]]),u.value?.fields.email?(n(),l("p",ue,r(u.value.fields.email),1)):d("",!0)]),o("button",{class:"btn primary",type:"submit",disabled:_.value},r(_.value?"Zapisywanie…":"Zapisz dane"),9,pe)],32)]),o("section",me,[e[15]||(e[15]=o("h2",{id:"wybor-h",style:{"margin-bottom":"6px"}},"Przedmioty do wyboru",-1)),e[16]||(e[16]=o("p",{class:"muted small"},"Z każdej grupy wybierasz jeden przedmiot. Pozostałe znikną z planu, pulpitu i list (można je pokazać przełącznikiem „Pokaż wszystkie”). Wybór zapamiętuje to urządzenie.",-1)),s(v).loaded.courses?s(v).electiveGroups.length?d("",!0):(n(),l("p",ye,"Nie ma teraz przedmiotów do wyboru.")):(n(),l("div",ce)),(n(!0),l(T,null,K(s(v).electiveGroups,t=>(n(),l("fieldset",{key:t.code,style:{border:"0",padding:"0",margin:"14px 0 0"}},[o("legend",we,r(s(X)(t.code)),1),(n(!0),l(T,null,K(t.options,w=>(n(),l("label",{key:w,class:"check"},[o("input",{type:"radio",name:`g-${t.code}`,value:w,checked:s(z).choices[t.code]===w,onChange:qe=>s(z).choose(t.code,w)},null,40,be),o("span",null,r(w),1)]))),128)),s(z).choices[t.code]?(n(),l("button",{key:1,class:"linkish small",type:"button",onClick:w=>s(z).choose(t.code,null)},"Wyczyść wybór",8,fe)):(n(),l("p",ke,"Jeszcze nie wybrano. Do tego czasu widać wszystkie alternatywy."))]))),128))]),o("section",ve,[e[23]||(e[23]=o("h2",{id:"kalendarz-h",style:{"margin-bottom":"6px"}},"Kalendarz Google / telefon",-1)),e[24]||(e[24]=o("p",{class:"muted small"}," Prywatny link do planu zajęć w formacie iCalendar. Dodaj go w Kalendarzu Google albo w telefonie, a zajęcia pojawią się obok Twoich wydarzeń. Plan uwzględnia przedmioty do wyboru wybrane wyżej. ",-1)),s(a).error?(n(),l("p",ze,r(s(a).error),1)):d("",!0),s(a).feed===void 0&&(s(a).loading||!s(a).error)?(n(),l("div",ge)):s(a).feed?(n(),l(T,{key:3},[o("div",xe,[e[17]||(e[17]=o("label",{for:"cal-url"},"Twój link (nie udostępniaj go)",-1)),o("div",je,[o("input",{id:"cal-url",ref_key:"urlInput",ref:N,class:"mono",type:"text",readonly:"",value:s(a).feed.url,style:{"font-size":"14px","min-width":"0"},onFocus:e[4]||(e[4]=t=>t.target.select())},null,40,Pe),o("button",{class:"btn",type:"button",onClick:B},"Kopiuj")]),s(a).feed.last_fetched_at?(n(),l("p",Ce,"Ostatnio pobrany przez kalendarz: "+r(S(s(a).feed.last_fetched_at))+".",1)):d("",!0)]),o("label",Ue,[o("input",{type:"checkbox",checked:s(a).feed.include_meetings,disabled:s(a).busy,onChange:e[5]||(e[5]=t=>s(a).save({include_meetings:t.target.checked}))},null,40,Te),e[18]||(e[18]=o("span",null,"Zjazdy jako wydarzenia całodniowe",-1))]),o("label",Ve,[o("input",{type:"checkbox",checked:s(a).feed.include_deadlines,disabled:s(a).busy,onChange:e[6]||(e[6]=t=>s(a).save({include_deadlines:t.target.checked}))},null,40,Ne),e[19]||(e[19]=o("span",null,"Terminy z terminarza",-1))]),o("div",Ze,[o("button",{class:"btn small ghost",type:"button",disabled:s(a).busy,onClick:G},"Wygeneruj nowy link",8,De),o("button",{class:"btn small miss",type:"button",disabled:s(a).busy,onClick:L},"Usuń link",8,Ke)]),e[20]||(e[20]=o("h3",{class:"eyebrow",style:{margin:"18px 0 6px"}},"Jak dodać",-1)),e[21]||(e[21]=o("ol",{class:"small",style:{margin:"0","padding-left":"20px",display:"grid",gap:"6px"}},[o("li",null,[o("b",null,"Kalendarz Google"),M(" (na komputerze, calendar.google.com): po lewej przy „Inne kalendarze” kliknij „+”, wybierz „Z adresu URL”, wklej link i kliknij „Dodaj kalendarz”. Na telefonie z Androidem kalendarz pojawi się sam po synchronizacji konta Google. ")]),o("li",null,[o("b",null,"iPhone / iPad"),M(": Ustawienia → Kalendarz → Konta → Dodaj konto → Inne → Dodaj subskrybowany kalendarz, wklej link i zapisz. ")])],-1)),e[22]||(e[22]=o("p",{class:"muted small",style:{margin:"10px 0 0"}}," Google odświeża subskrybowane kalendarze co kilka godzin, nie od razu: zmiana planu albo wyboru przedmiotów pojawi się w kalendarzu z opóźnieniem. ",-1))],64)):(n(),l("div",_e,[o("button",{class:"btn primary",type:"button",disabled:s(a).busy,onClick:e[3]||(e[3]=t=>s(a).create())},r(s(a).busy?"Tworzenie…":"Utwórz link do kalendarza"),9,he)]))]),j.value?(n(),l("section",Me,[e[25]||(e[25]=o("h2",{id:"microsoft-h",style:{"margin-bottom":"6px"}},"Konto Microsoft 365",-1)),e[26]||(e[26]=o("p",{class:"muted small"}," Połącz konto uczelniane Microsoft 365, aby logować się przyciskiem „Zaloguj przez Microsoft 365”. ",-1)),o("button",{class:"btn",type:"button",style:{"margin-top":"12px"},disabled:g.value,onClick:F},r(g.value?"Przekierowanie…":"Połącz konto Microsoft"),9,Fe)])):d("",!0),o("section",Be,[e[30]||(e[30]=o("h2",{id:"haslo-h",style:{"margin-bottom":"12px"}},"Zmiana hasła",-1)),o("form",{onSubmit:D($,["prevent"]),novalidate:""},[y.value?.message?(n(),l("p",Ge,r(y.value.message),1)):d("",!0),C.value?(n(),l("p",Le,"Hasło zostało zmienione.")):d("",!0),o("div",Se,[e[27]||(e[27]=o("label",{for:"pw-current"},"Obecne hasło",-1)),b(o("input",{id:"pw-current","onUpdate:modelValue":e[7]||(e[7]=t=>p.current_password=t),type:"password",autocomplete:"current-password"},null,512),[[k,p.current_password]]),y.value?.fields.current_password?(n(),l("p",Ee,r(y.value.fields.current_password),1)):d("",!0)]),o("div",$e,[e[28]||(e[28]=o("label",{for:"pw-new"},"Nowe hasło (min. 8 znaków)",-1)),b(o("input",{id:"pw-new","onUpdate:modelValue":e[8]||(e[8]=t=>p.password=t),type:"password",autocomplete:"new-password"},null,512),[[k,p.password]]),y.value?.fields.password?(n(),l("p",Ie,r(y.value.fields.password),1)):d("",!0)]),o("div",Oe,[e[29]||(e[29]=o("label",{for:"pw-confirm"},"Powtórz nowe hasło",-1)),b(o("input",{id:"pw-confirm","onUpdate:modelValue":e[9]||(e[9]=t=>p.password_confirmation=t),type:"password",autocomplete:"new-password"},null,512),[[k,p.password_confirmation]])]),o("button",{class:"btn primary",type:"submit",disabled:h.value||!p.current_password||!p.password},r(h.value?"Zapisywanie…":"Zmień hasło"),9,We)],32)]),o("section",Ae,[o("button",{class:"btn miss",type:"button",onClick:e[10]||(e[10]=t=>s(f).logout())},"Wyloguj się")])]))}});export{Ye as default};