import{r as p,i as C,R as L,d as o,F as U,j as e}from"./react.6693569e.js";import{u as y,s as b,a as w}from"./index.ab3d776b.js";/* empty css               *//* empty css              */import{u as P,U as I}from"./ColorPicker.0ba20714.js";import{AppContext as O}from"./App.4008d6a0.js";import{E as j,N as E}from"./NoteModal.bf2c96db.js";import{F as g,m as k,B as N,k as R,I as V,U as A,P as G,aR as q}from"./antd.e57bc55d.js";/* empty css              */import"./index.0a6cc9fb.js";import"./index.f92af1bb.js";const D="_signUpSettings_ee3kx_1",z="_bar_ee3kx_11",M="_btnGroup_ee3kx_21",T="_header_ee3kx_24",H="_content_ee3kx_29",$="_form_ee3kx_34",J="_upload_ee3kx_43",K="_uploadBtn_ee3kx_46",Q="_title_ee3kx_56",W="_tip_ee3kx_66",X="_fileList_ee3kx_70",Y="_file_ee3kx_70",Z="_name_ee3kx_81",ee="_removeBtn_ee3kx_85",s={signUpSettings:D,bar:z,btnGroup:M,header:T,content:H,form:$,upload:J,uploadBtn:K,title:Q,tip:W,fileList:X,file:Y,name:Z,removeBtn:ee},te={labelCol:{span:24},wrapperCol:{span:24}},se=async t=>{const n=new FormData;return n.append("file",t),(await w.uploadApi.uploadFile(n)).url},ie=({value:t=[],onChange:n})=>{const{T:m}=y();return o("div",{children:[e(A,{className:s.upload,fileList:t,showUploadList:!1,customRequest:()=>{},onChange:i=>{const d=Array.isArray(i)?i:i==null?void 0:i.fileList;n(d)},children:o("div",{className:s.uploadBtn,children:[o("div",{className:s.title,children:[e(I,{}),e("span",{children:m("settings.signup.editingNote.upload")})]}),e("div",{className:s.tip,children:m("settings.signup.editingNote.tip")})]})}),e("div",{className:s.fileList,children:t.map(i=>o("div",{className:s.file,children:[e(G,{}),e("span",{className:s.name,children:i.name}),e(q,{className:s.removeBtn,onClick:()=>{const d=t.findIndex(h=>i===h);t.splice(d,1),n([...t])}})]},i.uid))})]})},fe=()=>{const{T:t}=y(),{setLoading:n}=p.exports.useContext(O),m=C(),[i,d]=p.exports.useState(!1),[h,F]=p.exports.useState({}),[r]=g.useForm(),u=P(()=>b.settingsStore.signup),[x,v]=p.exports.useState(void 0);p.exports.useEffect(()=>{var f;const a=((f=u.note)==null?void 0:f.params)||{},l={title:a.title,content:a.content,files:(a.files||[]).map((_,c)=>({uid:c,name:_.name,status:"done",url:_.src}))};v(l)},[u]),p.exports.useEffect(()=>{r.resetFields()},[x,r]);const S=L.useCallback(async()=>{await r.validateFields();const a=r.getFieldsValue();try{n(!0);const l={title:a.title,content:a.content,files:[]},f=a.files;for(let c of f)if(c.originFileObj){const B=await se(c.originFileObj);l.files.push({name:c.name,src:B})}else l.files.push({name:c.name,src:c.url});const _={...u,note:{...u.note,params:l}};await b.settingsStore.patchSettings({signup:_}),k.success(t("settings.signup.editingNote.success"))}catch(l){console.error(l),k.error(t("settings.signup.editingNote.error"))}finally{n(!1)}},[r,n,u]);return o(U,{children:[o("div",{className:s.signUpSettings,children:[o("div",{className:s.bar,children:[e(N,{type:"text",icon:e(R,{}),style:{paddingLeft:0,paddingRight:0},onClick:()=>m.push("/settings/signup"),children:t("settings.signup.editingNote.goBack")}),o("div",{className:s.btnGroup,children:[e(N,{type:"primary",size:"small",onClick:S,children:t("settings.signup.editingNote.save")}),e(N,{type:"primary",size:"small",ghost:!0,onClick:()=>{F(r.getFieldsValue()),d(!0)},children:t("settings.signup.editingNote.preview")})]})]}),e("div",{className:s.header,children:t("settings.signup.editingNote.header")}),e("div",{className:s.content,children:e("div",{className:s.form,children:o(g,{...te,colon:!0,form:r,initialValues:x,children:[e(g.Item,{label:t("settings.signup.editingNote.title"),name:"title",rules:[{required:!0,message:t("settings.signup.editingNote.rules.title")}],children:e(V,{})}),e(g.Item,{label:t("settings.signup.editingNote.content"),name:"content",rules:[{required:!0,message:t("settings.signup.editingNote.rules.content")}],children:e(j,{})}),e(g.Item,{label:t("settings.signup.editingNote.files"),name:"files",children:e(ie,{})})]})})})]}),e(E,{visible:i,form:h,isPreview:!0,onVisibleChange:a=>d(a)})]})};export{fe as default};
