PageSourceSearch

https://app.sortly.com/scripts/user_preferences-Dn5--E4l_bundle.js

js sortly.com collected 2026-09-24 08:50:35 UTC 9,802 bytes, 57 lines download raw bytes

1import{bL as x,bK as Z,cl as g,r as m,j as e,bQ as O,aE as B,dd as U,cn as N,ac as G,b7 as H,de as Q,R as q}from"./vendor-ct_YKIP6_bundle.js";import{aj as K,ac as Y,C as J,a3 as y}from"./slackIntegration-mZcBTumD_bundle.js";import{cW as P,F as d,d as X,A as S,H as _,T as f,l as b,ah as T,aa as A,ac as v,aq as ee,sP as k,sQ as te,sR as se,aj as re,sS as ne,t as F,h as z,a as ae,dw as ie,G as V,c1 as oe,a8 as E,a4 as L,an as le,bW as ce}from"./registration-BfOA5mCx_bundle.js";import{a as $}from"./moment-DyvZl3Ud_bundle.js";import{S as ue}from"./index-XK-459JR_bundle.js";import{Z as I,iF as de,iG as pe}from"./index-BiagCLbs_bundle.js";import"./datadog-DxmyjtSX_bundle.js";import"./sentry-DLDmuXKN_bundle.js";import"./manage-team-DdoqA3xP_bundle.js";import"./list-dUheq_Ar_bundle.js";import"./stripe-BA7RN6Z4_bundle.js";import"./speedboat-vendor-DBIVks5t_bundle.js";const me=x.div`
2  display: flex;
3  flex-direction: column;
4  padding-top: 10px;
5  padding-bottom: 22px;
6`,D=x(d)`
7  margin-right: 24px;
8  min-width: 142px;
9
10  ${t=>t.$cancel&&Z`
11      padding: 0;
12    `}
13`,he=x(d)`
14  margin-top: 24px;
15`;x.form`
16  width: auto;
17  border-radius: 8px;
18  box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.07);
19  background-color: ${({theme:t})=>t.bg.white};
20
21  ${P.phone`
22    width: 448px;
23  `}
24`;x.div`
25  padding: 15px 32px 24px;
26  margin-top: 15px;
27
28  border-top: 1px solid ${({theme:t})=>t.delimiter.neutral100};
29
30  ${P.phone`
31    display: grid;
32    grid-template-columns: 152px;
33    justify-content: end;
34  `}
35`;x.div`
36  display: grid;
37  padding: 24px 32px;
38
39  grid-template-rows: repeat(3, 1fr);
40  grid-row-gap: 10px;
41
42  background-color: ${({theme:t})=>t.delimiter.neutral100};
43
44  ${P.phone`
45    grid-template-rows: auto;
46    grid-template-columns: repeat(3, 118px);
47    grid-column-gap: 15px;
48  `}
49`;const ge=x(d)`
50  padding-bottom: 32px;
51  padding-top: ${t=>!t.$isFirstSection&&"32px"};
52  border-bottom: 1px solid ${({theme:t})=>t.delimiter.neutral200};
53`,R=x(d)`
54  max-width: 527px;
55  margin-right: 34px;
56`,fe=(t={})=>{const{t:r}=g(),{initialValues:n}=t,i=X(),c=m.useCallback(a=>{i({type:S.SAVE_USER_PREFERENCES_REQUEST,payload:{values:a,initialValues:n}}),i({type:S.HIDE_MODAL})},[i,n]);return{showConfirmationModal:m.useCallback(a=>{i({type:S.SHOW_MODAL,payload:{component:"NodeActionModal",isDefaultHeadingHidden:!0,showCrossBtn:!1,autoWidth:!0,data:{customMaxWidth:"464px",buttonsAlign:"flex-end",submitButton:"Confirm changes",submitButtonStyleType:"danger",buttonOffsetType:"medium",question:e.jsxs(me,{children:[e.jsx(_,{outside:!0,bottom:16,children:e.jsx(f,{enormousSize:!0,fontBold:!0,children:r("user_preferences.save_preferences_modal.title")})}),e.jsx(f,{mediumSize:!0,smallLineHeight:!0,children:r("user_preferences.save_preferences_modal.subtitle")})]}),cancelHandler:()=>i({type:S.HIDE_MODAL}),submitHandler:()=>c(a)}}})},[i,c])}},xe=t=>{const{t:r}=g(),{control:n,register:i,watch:c,setValue:u}=t,a=m.useContext(O),o=c("timeZoneAuto"),s=b(p=>B(["settings","timeZones"],p)),l=m.useMemo(()=>{if(!o)return null;const p=$.tz.guess(!0);for(let h=0;h<s.length;h++)if(s[h].value===p)return{matchFound:!0,...s[h]};return{matchFound:!1,label:`UTC ${$.tz(p).format("Z")}`,value:p}},[o,s]);return m.useEffect(()=>{o&&l.matchFound&&u("timeZone",{label:l.label,value:l.value})},[u,o,l]),e.jsxs(d,{justifyContent:"flex-start",children:[e.jsx(R,{fullWidth:!0,children:e.jsx(T,{control:n,"data-testid":"timezone-dropdown",isDisabled:o,label:r("user_preferences.timezone.title"),name:"timeZone",options:s,wrapperStyles:{color:a.text.neutral700}})}),e.jsx(d,{alignItems:"center",children:e.jsx(_,{bottom:16,children:e.jsx(A,{...i("timeZoneAuto"),checkboxType:"switcher","data-testid":"auto-timezone-toggle",label:r("user_preferences.timezone.auto")})})})]})},be=()=>{const{t}=g(),{featureFlags:r}=v(),n=ee(),[i,c]=m.useState(!1),u=m.useMemo(()=>k.map(a=>({label:te[a],value:a})),[]);return r?.enableLanguageSelection?e.jsx(d,{justifyContent:"flex-start",children:e.jsx(R,{fullWidth:!0,children:e.jsx(T,{"data-testid":"language-dropdown",isPartOfForm:!1,label:t("user_preferences.language.title"),name:"language",options:u,isDisabled:i,value:u.find(a=>a.value===n),onChange:a=>{const o=k.find(s=>s===a?.value);!o||o===n||i||(c(!0),se(o).then(s=>{c(!1),s||re({type:"error",message:t("user_preferences.language.switch_failed")})}
56))}})})}):null},je=[{get label(){return F("customer_content.ascending")},value:"ascending"},{get label(){return F("customer_content.descending")},value:"descending"}],ye=t=>{const{t:r}=g(),{control:n,register:i,getValues:c}=t,u=m.useContext(O),{isCustomRoleWithHiddenPrice:a}=I();return e.jsxs(d,{justifyContent:"flex-start",children:[e.jsx(R,{fullWidth:!0,children:e.jsx(T,{control:n,"data-testid":"sorting-preference",label:r("user_preferences.sorting.label"),name:"sortingPreference",options:ne(a),value:c("sortingPreference"),wrapperStyles:{color:u.text.neutral700}})}),e.jsx(d,{column:!0,children:je.map(({label:o,value:s},l)=>e.jsx(de,{...i("sortingDirection"),"data-testid":`${s}-option`,label:o,labelColor:u.text.neutral700,value:s},`${s}-${l}`))})]})},Se=({fieldName:t,label:r,description:n,testId:i,type:c,origin:u,register:a,control:o})=>{const{t:s}=g(),l=N({control:o,name:t})===!0,p=s(l?"common.on":"common.off"),h=a(t);return e.jsxs(d,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(d,{column:!0,children:[e.jsx(f,{medium:!0,mediumSize:!0,neutral700:!0,children:r}),e.jsx(f,{largeSmallSize:!0,neutral400:!0,children:n})]}),e.jsx(d,{children:e.jsx(A,{...h,checkboxType:"switcher","data-testid":i,label:p,onChange:j=>{h.onChange(j),V.toggleEmailPreferences({origin:u,type:c,id:t,visible:j.target.checked})}})})]})},_e=({register:t,control:r})=>{const{t:n}=g(),{featureFlags:i}=v(),[c]=U(),u=c.get("origin")||"settings",{applicationPermissions:a}=z(),{planFeatures:o}=ae(),s=a.purchaseOrders?.manage&&o.purchaseOrdersEnabled,l=ie([{element:{fieldName:"notificationsAllowedEmail",label:n("user_preferences.alert.alerts"),description:n("user_preferences.alert.email_description"),testId:"alert-preferences-toggle",type:"alerts"},include:!0},{element:{fieldName:"purchaseOrderEmailsEnabled",label:n("user_preferences.alert.purchase_orders"),description:n("user_preferences.alert.purchase_orders_description"),testId:"purchase-orders-preferences-toggle",type:"purchase_orders"},include:i?.enablePoEmailPreferences&&s},{element:{fieldName:"threadMentionEmailEnabled",label:n("user_preferences.alert.threads"),description:n("user_preferences.alert.threads_description"),testId:"threads-preferences-toggle",type:"threads"},include:!0}]);return e.jsx(d,{column:!0,gap:24,children:l.map(p=>e.jsx(Se,{...p,origin:u,register:t,control:r},p.fieldName))})},we=t=>{const{t:r}=g(),{register:n,watch:i}=t,c=G(!0,i("sendWeeklyReports")),u=r(c?"common.on":"common.off"),a=b(oe),o=H(!1,["features","weeklyReports"],a),{isTeamMemberRoleCustomRoleLimitedRole:s}=z();return!o||s?null:e.jsx(_,{top:24,children:e.jsxs(d,{alignItems:"center",justifyContent:"space-between",children:[e.jsxs(d,{column:!0,children:[e.jsx(f,{medium:!0,mediumSize:!0,neutral700:!0,children:r("user_preferences.weekly_reports.title")}),e.jsx(f,{largeSmallSize:!0,neutral400:!0,children:r("user_preferences.weekly_reports.description")})]}),e.jsx(d,{children:e.jsx(A,{...n("sendWeeklyReports"),checkboxType:"switcher","data-testid":"weekly-reports-toggle",label:u})})]})})},M=t=>e.jsxs(ge,{column:!0,$isFirstSection:t.isFirstSection,children:[e.jsx(_,{bottom:24,children:e.jsx(f,{neutral700:!0,noLetterSpacing:!0,size:"20px",children:t.title})}),t.children]}),Ce=t=>{const{t:r}=g(),n=b(C=>H(!1,["spinner","saveUserPreferences"],C)),{userTheme:i,toggleUserTheme:c}=m.useContext(pe),{featureFlags:u}=v(),a=C=>{C.preventDefault(),c()},{handleSubmit:o,control:s,register:l,watch:p,setValue:h,getValues:j,formState:{isDirty:W},reset:w}=Q({defaultValues:t.initialValues});return q.useEffect(()=>{w(t.initialValues)},[w,t.initialValues]),e.jsx(K,{$minWidth:800,onSubmit:o(t.onSubmit),children:e.jsxs(Y,{children:[e.jsxs(M,{isFirstSection:!0,title:r("user_preferences.general_section"),children:[e.jsx(xe,{control:s,register:l,setValue:h,watch:p}),e.jsx(be,{}),e.jsx(ye,{control:s,getValues:j,register:l})]}),e.jsxs(M,{title:r("user_preferences.alert.title"),children:[e.jsx(_e,{control:s,register:l}),e.jsx(we,{register:l,watch:p})]}),e.jsxs(he,{children:[e.jsx(D,{children:e.jsx(E,{"data-testid":"submit-button",disabled:!W||n,disableStyleType:"transparent",offsetType:"clear",showSpinner:n,styleType:"brandCTA",type:"submit",children:r("common.save_changes")}
56)}),e.jsx(L,{when:W,children:e.jsx(D,{$cancel:!0,children:e.jsx(E,{"data-testid":"cancel-button",disableStyleType:"transparent",offsetType:"clear",styleType:"userCancel",type:"button",onClick:()=>w(t.initialValues),children:r("common.discard")})})})]}),e.jsx(L,{when:u?.enableDarkModeSupport,children:e.jsxs(E,{onClick:a,children:["Toggle Theme - ",i]})})]})})},Me=()=>{const{t}=g(),[r]=U(),n=r.get("origin")||"settings";le({enterEvent:()=>V.viewUserPreferences({origin:n})});const i=b(l=>l.currentUser?.user?.roles?.[0]),c=b(l=>l.settings),u=b(l=>l.currentUser?.user?.roles?.[0]?.notificationPreferences),{isCustomRoleWithHiddenPrice:a}=I(),o=m.useMemo(()=>ce(i,c,a,u),[i,c,a,u]),{showConfirmationModal:s}=fe({initialValues:o});return e.jsx(J,{$greyBg:!0,children:e.jsxs(d,{style:{flex:1},children:[e.jsx(ue,{active:"user_preferences"}),e.jsxs(y.RightColumn,{children:[e.jsx(y.DefaultHeader,{innerDelimiter:!0,offsets:{pt:32},children:e.jsx(y.HeaderContent,{left:0,maxWidth:800,right:0,children:e.jsx(f,{as:"h1",children:t("user_preferences.headline")})})}),e.jsx(y.Body,{left:0,maxWidth:800,right:0,children:e.jsx(Ce,{initialValues:o,onSubmit:s})})]})]})})};export{Me as default};
57//# sourceMappingURL=user_preferences-Dn5--E4l_bundle.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.