PageSourceSearch

https://tuforums.com/assets/CurationSchedulePage.C-uBdAVh.js

js tuforums.com collected 2026-10-02 00:58:26 UTC 19,041 bytes, 1 lines download raw bytes

vendor: 1,288 bytes, line 1
1import{u as ue,aP as he,a as q,r as G,E as ie,j as e,z as pe,A as me,f as _e,s as ge,I as fe,av as xe,e as ve,b as je,bD as C,c1 as ne,M as be,C as w,p as D,$ as ce}from"./index.C_jEAofg.js";import{r as o,d as ye,N as Ne}from"./reactRouter.C6cvQAHO.js";import{A as Se}from"./AccessDenied.Da_IVTEt.js";import{T as oe}from"./TrashIcon.BeVW0keM.js";import{f as Ce}from"./curationTypeUtils.UzM-6L0y.js";import{S as ke}from"./ScrollButton.BuRsjz3s.js";import"./BulkCreateCurationsConfirmPopup.La29Scy7.js";import{F as we}from"./FacetQueryBuilder.hyebA0HI.js";import{u as de,i as re}from"./i18n.BxWiIRpk.js";import"./recharts.DzmhKP_O.js";/* empty css                            */import"./Select.BO5et_f4.js";import"./communityTags.D2n_4RPi.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};i.SENTRY_RELEASE={id:"aec9389561908f1f1b5366362ca3b629220ab900"},i._sentryModuleMetadata=i._sentryModuleMetadata||{},i._sentryModuleMetadata[new i.Error().stack]=function(j){for(var b=1;b<arguments.length;b++){var h=arguments[b];if(h!=null)for(var d in h)h.hasOwnProperty(d)&&(j[d]=h[d])}return j}({},i._sentryModuleMetadata[new i.Error().stack],{"_sentryBundlerPluginAppKey:tuf-website":!0});var n=new i.Error().stack;
1n&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[n]="48e9baa7-d779-4169-b474-3b7f351ad67c",i._sentryDebugIdIdentifier="sentry-dbid-48e9baa7-d779-4169-b474-3b7f351ad67c")}catch{}})();function le(){return{mode:"advanced",groups:[{quantifier:"all",ids:[]}],betweenPairs:[],betweenGroups:"and",excludeIds:[]}}const Te=({isOpen:i,onClose:n,onCurationSelect:j,onSelectMultiple:b,excludeIds:h=[],multiSelect:d=!1})=>{const{t:c}=de(["components","common"]),{curationTypes:Y,difficultyDict:m}=ue(),[Z,_]=o.useState([]),[te,J]=o.useState(!1),[g,V]=o.useState(""),[y,T]=o.useState(le),[p,P]=o.useState(1),[U,X]=o.useState(1),[f,I]=o.useState(()=>new Map),E=10,ee=o.useCallback(async()=>{try{J(!0);const t=new URLSearchParams({page:p,limit:E,...g&&{search:g}}),v=he({curationTypes:y,combine:"and"});v&&t.append("facetQuery",v),h&&h.length>0&&h.forEach(L=>t.append("excludeIds",L));const u=await q.get(`${G.admin.curations.root()}?${t}`);_(u.data.curations),X(Math.ceil(u.data.total/E)||0)}catch(t){console.error("Failed to fetch curations:",t),ie.error(c("curationSelectionPopup.errors.fetchFailed"))}finally{J(!1)}},[p,g,y,h,c]);o.useEffect(()=>{i&&ee()},[i,ee]),o.useEffect(()=>{i||(V(""),T(le()),P(1),I(new Map))},[i]),o.useEffect(()=>{i&&I(new Map)},[i,y,g]);const ae=t=>{I(v=>{const u=new Map(v);return u.has(t.id)?u.delete(t.id):u.set(t.id,t),u})},M=t=>{if(d){ae(t);return}j(t)},A=()=>{if(!b)return;const t=[...f.values()];if(t.length===0){ie.error(c("curationSelectionPopup.errors.noneSelected"));return}b(t),n()},x=t=>{P(t)},k=t=>{V(xe(t)),P(1)};return i?e.jsxs(pe,{onClose:n,overlayClassName:"curation-selection-modal",panelClassName:"curation-selection-modal__content",when:i,children:[e.jsx(me,{variant:"floating",type:"button",className:"curation-selection-modal__close-button",onClick:n,"aria-label":c("buttons.close",{ns:"common"})}),e.jsxs("div",{className:"curation-selection-modal__header",children:[e.jsx("h2",{children:c("curationSelectionPopup.title")}),e.jsx("p",{children:c(d?"curationSelectionPopup.descriptionMulti":"curationSelectionPopup.description")})]}),e.jsx("div",{className:"curation-selection-modal__type-filters",children:e.jsx(we,{items:Y,value:y,onChange:t=>{T(t||le()),P(1)},title:c("curationSelectionPopup.filters.facetBuilderTitle")})}),e.jsx("div",{className:"curation-selection-modal__filters",children:e.jsxs("div",{className:"curation-selection-modal__filter-group curation-selection-modal__filter-group--full",children:[e.jsx("label",{children:c("curationSelectionPopup.filters.search")}),e.jsx("input",{type:"text",value:g,onChange:t=>k(t.target.value),placeholder:c("curationSelectionPopup.filters.searchPlaceholder"),className:"curation-selection-modal__search-input"})]})}),d&&e.jsx("div",{className:"curation-selection-modal__multi-hint",children:c("curationSelectionPopup.multiSelectHint")}),e.jsx("div",{className:"curation-selection-modal__list",children:te?e.jsx("div",{className:"curation-selection-modal__loading",children:c("curationSelectionPopup.loading")}):Z.length===0?e.jsx("div",{className:"curation-selection-modal__empty",children:c("curationSelectionPopup.empty")}):Z.map(t=>{var u,L,a;const v=f.has(t.id);return e.jsxs("div",{role:"button",tabIndex:0,className:`curation-selection-modal__item ${d&&v?"curation-selection-modal__item--selected":""}`,onClick:()=>M(t),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),M(t))},children:[d&&e.jsx("div",{className:"curation-selection-modal__item-check","aria-hidden":!0,children:e.jsx("input",{type:"checkbox",readOnly:!0,checked:v,tabIndex:-1,className:"curation-selection-modal__checkbox"})}),e.jsx("div",{className:"curation-selection-modal__item-preview",children:t.previewLink?e.jsx("img",{src:t.previewLink,alt:"",className:"curation-selection-modal__thumbnail"}):e.jsx("div",{className:"curation-selection-modal__no-thumbnail",children:"🎵"})}),e.jsxs("div",{className:"curation-selection-modal__item-details",children:[e.jsxs("div",{className:"curation-selection-modal__level-info",children:[e.jsx("h3",{className:"curation-selection-modal__level-title",children:((u=t.level)==null?void 0:u.song)||"Unknown Song"}),e.jsx("p",{className:"curation-selection-modal__level-artist",children:((L=t.level)==null?void 0:L.artist)||"Unknown Artist"}),e.jsxs("p",{className:"curation-selection-modal__level-creator",children:[c("curationSelectionPopup.creator"),": ",_e(t.level)||"Unknown"]})]}),e.jsxs("div",{className:"curation-selection-modal__curation-info",children:[e.jsx("div",{className:"curation-selection-modal__type-badges",children:(t.types||(t.type?[t.type]:[])).map(s=>e.jsx("div",{className:"curation-selection-modal__type-badge",style:{backgroundColor:`${s.color||"#606060"}80`,color:"#ffffff"},children:s.name},s.id))}),((a=t.level)==null?void 0:a.diffId)!=null&&m[t.level.diffId]&&e.jsxs("div",{className:"curation-selection-modal__difficulty",children:[e.jsx("img",{src:ge(m[t.level.diffId].icon,fe.MEDIUM),alt:m[t.level.diffId].name,className:"curation-selection-modal__difficulty-icon"}),e.jsx("span",{children:m[t.level.diffId].name})]}),e.jsx("div",{className:`curation-selection-modal__appearances ${t.weeklyAppearances>0?"curation-selection-modal__appearances--featured":""}`,children:t.weeklyAppearances>0?c("curationSelectionPopup.appearances.featured",{times:t.weeklyAppearances}):c("curationSelectionPopup.appearances.never")})]})]}),!d&&e.jsx("span",{className:"curation-selection-modal__select-btn",children:c("curationSelectionPopup.actions.select")})]},t.id)})}),d&&e.jsx("div",{className:"curation-selection-modal__multi-actions",children:e.jsx("button",{type:"button",className:"curation-selection-modal__confirm-multi-btn",onClick:A,disabled:f.size===0,children:c("curationSelectionPopup.actions.applySelected",{count:f.size})})}),U>1&&e.jsxs("div",{className:"curation-selection-modal__pagination",children:[e.jsxs("button",{type:"button",onClick:()=>x(p-1),disabled:p===1,className:"curation-selection-modal__page-btn",children:["← ",c("curationSelectionPopup.pagination.previous")]}),e.jsx("span",{className:"curation-selection-modal__page-info",children:c("curationSelectionPopup.pagination.pageInfo",{current:p,total:U})}),e.jsxs("button",{type:"button",onClick:()=>x(p+1),disabled:p===U,className:"curation-selection-modal__page-btn",children:[c("curationSelectionPopup.pagination.next")," ➔"]})]})]}):null},Be=()=>{const{user:i}=ve(),{t:n}=de("pages"),j=ye(),b=o.useMemo(()=>je({title:n("curationSchedule.meta.title"),description:n("curationSchedule.meta.description"),pathname:j.pathname,noindex:!0}
1),[n,j.pathname]),[h,d]=o.useState(!1),[c,Y]=o.useState(!1),[m,Z]=o.useState([]),[_,te]=o.useState(P(new Date)),[J,g]=o.useState(!1),[V,y]=o.useState({type:""}),T=o.useRef(null),p=o.useRef(null);function P(a){const s=a.getUTCDay(),l=a.getUTCDate()-s+(s===0?-6:1),r=new Date(a);return r.setUTCDate(l),r.setUTCHours(0,0,0,0),r}const U=a=>{var l,r;const s=new Date(a);return s.setUTCDate(a.getUTCDate()+6),s.setUTCHours(0,0,0,0),`${ce(a,(l=re)==null?void 0:l.language)} - ${ce(s,(r=re)==null?void 0:r.language)}`},X=a=>a?`${a}80`:"#60606080";o.useEffect(()=>{f()},[i,_]);const f=async()=>{var a,s;try{d(!0);const l=await q.get(`${G.admin.curations.root()}/schedules`,{params:{weekStart:_.toISOString().split("T")[0],includeUnavailable:"1"}});Z(l.data.schedules||[])}catch(l){C.error(((s=(a=l.response)==null?void 0:a.data)==null?void 0:s.error)||"Failed to fetch schedules")}finally{d(!1)}},I=a=>{const s=new Date(_);s.setUTCDate(_.getUTCDate()+a*7),s.setUTCHours(0,0,0,0),te(s)},E=a=>{y({type:a}),g(!0)},ee=async a=>{var s,l;try{await q.post(`${G.admin.curations.root()}/schedules`,{curationId:a.id,weekStart:_.toISOString().split("T")[0],listType:V.type}),C.success(n("curationSchedule.notifications.added")),f(),g(!1),y({type:""})}catch(r){C.error(((l=(s=r.response)==null?void 0:s.data)==null?void 0:l.error)||"Failed to add curation to schedule")}},ae=async a=>{var s,l;try{await q.delete(`${G.admin.curations.root()}/schedules/${a}`),C.success(n("curationSchedule.notifications.removed")),f()}catch(r){C.error(((l=(s=r.response)==null?void 0:s.data)==null?void 0:l.error)||"Failed to remove curation")}},M=async a=>{var s,l,r;try{Y(!0);const S=((s=(await q.post(`${G.admin.curations.schedules()}/fill`,{weekStart:_.toISOString().split("T")[0],halls:a})).data)==null?void 0:s.created)??0;S>0?C.success(n("curationSchedule.fill.notifications.filled",{added:S})):C(n("curationSchedule.fill.notifications.none")),f()}catch(N){C.error(((r=(l=N.response)==null?void 0:l.data)==null?void 0:r.error)||n("curationSchedule.fill.notifications.failed"))}finally{Y(!1)}},A=(a,s)=>{a.current&&a.current.scrollBy({left:s==="left"?-300:300,behavior:"smooth"})},x=a=>{var l;const s=(l=a==null?void 0:a.scheduledCuration)==null?void 0:l.level;return!s||s.isDeleted?"deleted":s.isHidden?"hidden":null},k=m.filter(a=>a.listType==="primary").slice(0,20),t=m.filter(a=>a.listType==="secondary").slice(0,20),v=a=>!a||!i?!1:ne(i,[D.SUPER_ADMIN,D.HEAD_CURATOR])?!0:(a.types||(a.type?[a.type]:[])).some(l=>l.abilities&&Ce(i.permissionFlags,l.abilities)),u=m.map(a=>{var s;return a.curationId||((s=a.curation)==null?void 0:s.id)}).filter(Boolean);return ne(i,[D.SUPER_ADMIN,D.HEAD_CURATOR])||m.some(a=>v(a.scheduledCuration))?e.jsxs("div",{className:"curation-schedule-page",children:[e.jsx(be,{...b}),e.jsxs("div",{className:"curation-schedule-page__content",children:[e.jsxs("div",{className:"curation-schedule-page__header",children:[e.jsxs("div",{className:"curation-schedule-page__header-top",children:[e.jsxs(Ne,{className:"curation-schedule-page__back-btn",to:"/admin/curations",title:n("curationSchedule.actions.backToCuration"),children:[e.jsx(w,{direction:"left"})," ",n("curationSchedule.actions.backToCuration")]}),e.jsx("h1",{children:n("curationSchedule.title")})]}),e.jsx("p",{children:n("curationSchedule.description")})]}),e.jsxs("div",{className:"curation-schedule-page__week-nav curation-schedule-page__panel",children:[e.jsxs("button",{className:"curation-schedule-page__week-btn",onClick:()=>I(-1),children:[e.jsx(w,{direction:"left"})," ",n("curationSchedule.previousWeek")]}),e.jsx("h2",{className:"curation-schedule-page__week-title",children:U(_)}),e.jsxs("button",{className:"curation-schedule-page__week-btn",onClick:()=>I(1),children:[n("curationSchedule.nextWeek")," ",e.jsx(w,{direction:"right"})]})]}),ne(i,[D.SUPER_ADMIN,D.HEAD_CURATOR])&&e.jsxs("div",{className:"curation-schedule-page__fill-bar curation-schedule-page__panel",children:[e.jsxs("div",{className:"curation-schedule-page__fill-text",children:[e.jsx("h3",{children:n("curationSchedule.fill.title")}),e.jsx("p",{children:n("curationSchedule.fill.description")})]}),e.jsxs("div",{className:"curation-schedule-page__fill-actions",children:[e.jsx("button",{className:"curation-schedule-page__fill-btn curation-schedule-page__fill-btn--primary",onClick:()=>
1M("primary"),disabled:c,children:n("curationSchedule.fill.legendary")}),e.jsx("button",{className:"curation-schedule-page__fill-btn curation-schedule-page__fill-btn--secondary",onClick:()=>M("secondary"),disabled:c,children:n("curationSchedule.fill.loved")}),e.jsx("button",{className:"curation-schedule-page__fill-btn curation-schedule-page__fill-btn--both",onClick:()=>M("both"),disabled:c,children:n("curationSchedule.fill.both")})]})]}),e.jsxs("div",{className:"curation-schedule-page__hall-section curation-schedule-page__panel",children:[e.jsxs("div",{className:"curation-schedule-page__hall-header",children:[e.jsxs("div",{className:"curation-schedule-page__hall-header-left",children:[e.jsx("h3",{children:n("curationSchedule.primaryHall.title")}),e.jsx("p",{children:n("curationSchedule.primaryHall.description")})]}),e.jsxs("span",{className:"curation-schedule-page__count",children:[k.length,"/20"]})]}),e.jsxs("div",{className:"curation-schedule-page__hall-container",children:[e.jsx("button",{className:"curation-schedule-page__scroll-btn curation-schedule-page__scroll-btn--left",onClick:()=>A(T,"left"),disabled:k.length===0,children:e.jsx(w,{direction:"left",size:24})}),e.jsx("div",{className:"curation-schedule-page__hall-scroll",ref:T,children:e.jsxs("div",{className:"curation-schedule-page__hall-list",children:[k.map((a,s)=>{var l,r,N,S,F,R,$,H,z,B,O,Q,W,K;return e.jsxs("div",{className:`curation-schedule-page__hall-item${x(a)?" curation-schedule-page__hall-item--unavailable":""}`,children:[e.jsx("div",{className:"curation-schedule-page__hall-position",children:s+1}),e.jsx("div",{className:"curation-schedule-page__hall-preview",children:(l=a.scheduledCuration)!=null&&l.previewLink?e.jsx("img",{src:a.scheduledCuration.previewLink,alt:"Level thumbnail",className:"curation-schedule-page__hall-thumbnail"}):e.jsx("div",{className:"curation-schedule-page__hall-no-thumbnail",children:"🎵"})}),e.jsxs("div",{className:"curation-schedule-page__hall-info",children:[e.jsx("h4",{children:((N=(r=a.scheduledCuration)==null?void 0:r.level)==null?void 0:N.song)||"Unknown Song"}),e.jsx("p",{children:((F=(S=a.scheduledCuration)==null?void 0:S.level)==null?void 0:F.artist)||"Unknown Artist"}),x(a)&&e.jsx("div",{className:"curation-schedule-page__hall-unavailable",children:n(`curationSchedule.unavailable.${x(a)}`)}),e.jsx("div",{className:"curation-schedule-page__hall-type",style:{backgroundColor:X(((H=($=(R=a.scheduledCuration)==null?void 0:R.types)==null?void 0:$[0])==null?void 0:H.color)??((B=(z=a.scheduledCuration)==null?void 0:z.type)==null?void 0:B.color))},children:(Q=(O=a.scheduledCuration)==null?void 0:O.types)!=null&&Q.length?a.scheduledCuration.types.map(se=>se.name).join(", "):((K=(W=a.scheduledCuration)==null?void 0:W.type)==null?void 0:K.name)||"Unknown Type"})]}),e.jsx("div",{className:"curation-schedule-page__hall-actions",children:e.jsx("button",{onClick:()=>ae(a.id),className:"curation-schedule-page__remove-btn",title:n("curationSchedule.actions.remove"),children:e.jsx(oe,{})})})]},a.id)}),k.length<20&&e.jsxs("button",{className:"curation-schedule-page__add-slot",onClick:()=>E("primary"),children:[e.jsx("div",{className:"curation-schedule-page__add-icon",children:"+"}),e.jsx("span",{children:n("curationSchedule.actions.addCuration")})]})]})}),e.jsx("button",{className:"curation-schedule-page__scroll-btn curation-schedule-page__scroll-btn--right",onClick:()=>A(T,"right"),disabled:k.length===0,children:e.jsx(w,{direction:"right",size:24})})]})]}),e.jsxs("div",{className:"curation-schedule-page__hall-section curation-schedule-page__panel",children:[e.jsxs("div",{className:"curation-schedule-page__hall-header",children:[e.jsxs("div",{className:"curation-schedule-page__hall-header-left",children:[e.jsx("h3",{children:n("curationSchedule.secondaryHall.title")}),e.jsx("p",{children:n("curationSchedule.secondaryHall.description")})]}),e.jsxs("span",{className:"curation-schedule-page__count",children:[t.length,"/20"]})]}),e.jsxs("div",{className:"curation-schedule-page__hall-container",children:[e.jsx("button",{className:"curation-schedule-page__scroll-btn curation-schedule-page__scroll-btn--left",onClick:()=>A(p,"left"),disabled:t.length===0,children:e.jsx(w,{direction:"left",size:24})}),e.jsx("div",{className:"curation-schedule-page__hall-scroll",ref:p,children:e.jsxs("div",{className:"curation-schedule-page__hall-list",children:[t.map((a,s)=>{var l,r,N,S,F,R,$,H,z,B,O,Q,W,K;return e.jsxs("div",{className:`curation-schedule-page__hall-item${x(a)?" curation-schedule-page__hall-item--unavailable":""}`,children:[e.jsx("div",{className:"curation-schedule-page__hall-position",children:s+1}),e.jsx("div",{className:"curation-schedule-page__hall-preview",children:(l=a.scheduledCuration)!=null&&l.previewLink?e.jsx("img",{src:a.scheduledCuration.previewLink,alt:"Level thumbnail",className:"curation-schedule-page__hall-thumbnail"}):e.jsx("div",{className:"curation-schedule-page__hall-no-thumbn
1ail",children:"🎵"})}),e.jsxs("div",{className:"curation-schedule-page__hall-info",children:[e.jsx("h4",{children:((N=(r=a.scheduledCuration)==null?void 0:r.level)==null?void 0:N.song)||"Unknown Song"}),e.jsx("p",{children:((F=(S=a.scheduledCuration)==null?void 0:S.level)==null?void 0:F.artist)||"Unknown Artist"}),x(a)&&e.jsx("div",{className:"curation-schedule-page__hall-unavailable",children:n(`curationSchedule.unavailable.${x(a)}`)}),e.jsx("div",{className:"curation-schedule-page__hall-type",style:{backgroundColor:X(((H=($=(R=a.scheduledCuration)==null?void 0:R.types)==null?void 0:$[0])==null?void 0:H.color)??((B=(z=a.scheduledCuration)==null?void 0:z.type)==null?void 0:B.color))},children:(Q=(O=a.scheduledCuration)==null?void 0:O.types)!=null&&Q.length?a.scheduledCuration.types.map(se=>se.name).join(", "):((K=(W=a.scheduledCuration)==null?void 0:W.type)==null?void 0:K.name)||"Unknown Type"})]}),e.jsx("div",{className:"curation-schedule-page__hall-actions",children:e.jsx("button",{onClick:()=>ae(a.id),className:"curation-schedule-page__remove-btn",title:n("curationSchedule.actions.remove"),children:e.jsx(oe,{})})})]},a.id)}),t.length<20&&e.jsxs("button",{className:"curation-schedule-page__add-slot",onClick:()=>E("secondary"),children:[e.jsx("div",{className:"curation-schedule-page__add-icon",children:"+"}),e.jsx("span",{children:n("curationSchedule.actions.addCuration")})]})]})}),e.jsx("button",{className:"curation-schedule-page__scroll-btn curation-schedule-page__scroll-btn--right",onClick:()=>A(p,"right"),disabled:t.length===0,children:e.jsx(w,{direction:"right",size:24})})]})]}),h&&e.jsx("div",{className:"curation-schedule-page__loading curation-schedule-page__panel",children:n("curationSchedule.loading")})]}),e.jsx(Te,{isOpen:J,onClose:()=>{g(!1),y({type:""})},onCurationSelect:ee,excludeIds:u}),e.jsx(ke,{})]}):e.jsx(Se,{})};export{Be as default};

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.