UNPKG

@getontime/cli

Version:
3 lines (2 loc) 2.27 kB
import{h as w,ad as I,j as e}from"./vendor-q6fv0YT2.js";import{d as v,bS as c,Y as S,a9 as u,B as m,$ as T,ae as _,af as C,ag as D,ah as O,ai as B}from"./index-B81u4hxi.js";import{I as M}from"./useWindowTitle-Bpmo_HzW.js";import{M as F}from"./Modal-BKx0PDGT.js";import"./SwatchPicker-Cm5Eicvv.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new s.Error().stack;a&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[a]="7fd9cea8-0643-4e7a-b8d1-20f96e168cc8",s._sentryDebugIdIdentifier="sentry-dbid-7fd9cea8-0643-4e7a-b8d1-20f96e168cc8")}catch{}})();function K({isOpen:s,onClose:a}){const{userTranslation:i,postUserTranslation:f}=v(),h=w.useMemo(()=>{const t={};return Object.keys(c).forEach(r=>{t[l(r)]=i[r]||""}),t},[i]),{handleSubmit:p,register:b,reset:g,formState:{isSubmitting:d,isDirty:x,errors:n,isValid:j},setError:y}=I({defaultValues:h,resetOptions:{keepDirtyValues:!0},mode:"onChange"}),E=async t=>{try{const r={};Object.keys(t).forEach(o=>{r[L(o)]=t[o]}),await f(r),g(t)}catch(r){y("root",{message:B(r)})}};return e.jsx(F,{title:"Edit custom translations",isOpen:s,onClose:a,showCloseButton:!0,showBackdrop:!0,bodyElements:e.jsxs(T,{as:"form",onSubmit:p(E),id:"custom-translations-form",children:[e.jsxs(M,{children:["Provide custom translations for the public views of Ontime. ",e.jsx("br",{}),'You will need to activate this in the settings by selecting "Custom" as the views language.']}),e.jsx(_,{children:Object.entries(c).map(([t,r])=>{var o;return e.jsxs(C,{children:[e.jsx(D,{title:r,description:"",error:(o=n[l(t)])==null?void 0:o.message}),e.jsx(O,{maxLength:150,...b(l(t),{required:"This field is required"}),placeholder:r})]},t)})})]}),footerElements:e.jsxs("div",{children:[(n==null?void 0:n.root)&&e.jsx(S,{children:n.root.message}),e.jsx(u,{align:"apart",children:e.jsxs(u,{children:[e.jsx(m,{size:"large",onClick:a,children:"Cancel"}),e.jsx(m,{variant:"primary",size:"large",type:"submit",form:"custom-translations-form",disabled:d||!x||!j,loading:d,children:"Save changes"})]})})]})})}function l(s){return s.replace(".","_")}function L(s){return s.replace("_",".")}export{K as default}; //# sourceMappingURL=CustomTranslationModal-DiQbmcgD.js.map