PageSourceSearch

https://www.chinesetrack.com/current/assets/LearningPreferencesPage-BYPjY-PG.js

js chinesetrack.com collected 2026-10-02 15:16:53 UTC 10,131 bytes, 2 lines download raw bytes

1import{bg as g,r as m,j as e,z as b,J as y,a as j,bh as v}from"./index-BkeBWTNd.js";import{C as N}from"./chevron-left-C2emqPdi.js";const w=({initialValues:s,onSave:o})=>{const n=g(s),[r,x]=m.useState(n.learn_characters??!0),[a,c]=m.useState(n.character_script??"traditional"),[t,l]=m.useState(n.writing_practice??!1),[i,u]=m.useState(n.require_pronunciation_for_completion??!0);m.useEffect(()=>{const d=g(s);x(d.learn_characters??!0),c(d.character_script??"traditional"),l(d.writing_practice??!1),u(d.require_pronunciation_for_completion??!0)},[s]),m.useEffect(()=>{const d=setTimeout(()=>{const h={learn_characters:r,...r&&{character_script:a},writing_practice:r?t:!1,require_pronunciation_for_completion:i,completedSurvey:n.completedSurvey??!1,learningMode:r?t?"charactersReadWrite":"charactersRead":"pinyinOnly",scriptVariant:r?a:null,requirePronunciationForCompletion:i};o(h)},300);return()=>clearTimeout(d)},[r,a,t,i,n.completedSurvey,o]);const p=()=>r?`${a==="simplified"?"Simplified":"Traditional"} characters, ${t?"reading and writing":"reading only"}`:"Pinyin only mode";return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-1",children:"Script & Writing"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Choose whether to learn Chinese characters and how to study them."})]}),e.jsx("div",{className:"bg-white rounded-xl border-2 border-gray-200 p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-sm font-semibold text-gray-900 block mb-1",children:"Learn Chinese characters"}),e.jsx("p",{className:"text-xs text-gray-600",children:"When off, you'll focus on pinyin, pronunciation, and speaking only."})]}),e.jsx("button",{type:"button",onClick:()=>x(!r),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-orange-500 focus:ring-offset-2 ${r?"bg-orange-500":"bg-gray-300"}`,role:"switch","aria-checked":r,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${r?"translate-x-6":"translate-x-1"}`})})]})}),r&&e.jsxs("div",{className:"space-y-4 pl-4 border-l-2 border-orange-200",children:[e.jsxs("div",{className:"bg-white rounded-xl border-2 border-gray-200 p-4",children:[e.jsx("label",{className:"text-sm font-semibold text-gray-900 block mb-3",children:"Character type"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("button",{type:"button",onClick:()=>c("simplified"),className:`flex-1 rounded-lg border-2 px-4 py-3 text-left transition ${a==="simplified"?"border-orange-500 bg-orange-50":"border-gray-200 bg-white hover:border-orange-300"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center ${a==="simplified"?"border-orange-500":"border-gray-300"}`,children:a==="simplified"&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-orange-500"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900",children:"Simplified characters"}),e.jsx("div",{className:"text-xs text-gray-600",children:"Commonly used in Mainland China and Singapore"})]})]})}),e.jsx("button",{type:"button",onClick:()=>c("traditional"),className:`flex-1 rounded-lg border-2 px-4 py-3 text-left transition ${a==="traditional"?"border-orange-500 bg-orange-50":"border-gray-200 bg-white hover:border-orange-300"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center ${a==="traditional"?"border-orange-500":"border-gray-300"}`,children:a==="traditional"&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-orange-500"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900",children:"Traditional characters"}),e.jsx("div",{className:"text-xs text-gray-600",children:"Commonly used in Taiwan and Hong Kong"})]})]})})]})]}),e.jsx("div",{className:"bg-white rounded-xl border-2 border-gray-200 p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-sm font-semibold text-gray-900 block mb-1",children:"Include writing practice"}),e.jsx("p",{className:"text-xs text-gray-600",children:"When off, you'll focus on reading characters, not writing them."})]}),e.jsx("button",{type:"button",onClick:()=>l(!t),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-orange-500 focus:ring-offset-2 ${t?"bg-orange-500":"bg-gray-300"}`,role:"switch","aria-checked":t,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${t?"translate-x-6":"translate-x-1"}`})})]})})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-1",children:"Pronunciation"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Control whether pronunciation practice is required for lesson completion."})]}),e.jsx("div",{className:"bg-white rounded-xl border-2 border-gray-200 p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-sm font-semibold text-gray-900 block mb-1",children:"Require pronunciation practice for lesson completion"}),e.jsx("p",{className:"text-xs text-gray-600",children:"When off, pronunciation practice is optional and won't block lesson completion."})]}),e.jsx("button",{type:"button",onClick:()=>u(!i),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-orange-500 focus:ring-offset-2 ${i?"bg-orange-500":"bg-gray-300"}`,role:"switch","aria-checked":i,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i?"translate-x-6":"translate-x-1"}`})})]})})]}),e.jsx("div",{className:"bg-orange-50 border-2 border-orange-200 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-orange-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-semibold text-orange-900 mb-1",children:"Current learning mode"}),e.jsx("p",{className:"text-sm text-orange-800",children:p()})]})]})})]})};function C(){const s=window.location.hash||"",o=window.location.pathname,n=window.location.search;if(s.startsWith("#/")){const r=s.substring(1);return n?`${r}${n}`:r}return n?`${o}${n}`:o}function S(s,o=1){const n=s?.returnTo;if(n&&!n.includes("/learning-preferences"))return n;try{const r=sessionStorage.getItem("ct_pref_returnTo");
1if(r&&!r.includes("/learning-preferences"))return r}catch{}return`/course-outline/level/${o}`}function f(){try{const s=C();s.includes("/learning-preferences")||sessionStorage.setItem("ct_pref_returnTo",s)}catch{}}function k(){try{sessionStorage.removeItem("ct_pref_returnTo")}catch{}}const $=()=>{const{prefs:s,savePrefs:o}=b(),n=y(),x=j().state;m.useEffect(()=>{if(!x?.returnTo)try{const t=sessionStorage.getItem("ct_pref_returnTo");(!t||t.includes("/learning-preferences"))&&f()}catch{f()}},[x]);const a=t=>{const l=window.localStorage.getItem("ctPrefsDebug")==="1";l&&(console.log("[LearningPrefsPage] handleSave: received from settings:",t),console.log("[LearningPrefsPage] handleSave: calling savePrefs"));const i={...t,completedSurvey:t.completedSurvey??s?.completedSurvey??!1};o(i),l&&console.log("[LearningPrefsPage] handleSave: savePrefs called")},c=()=>{let t=S(x);const l=s&&(s.learn_characters===!1||s.learningMode==="pinyinOnly")?"pinyin":v(s)==="simplified"?"simplified":"traditional";if(t.includes("course-outline")){const i=t.replace(/[?&]mode=[^&]*/g,"").replace(/&$/,"").replace(/\?$/,""),u=i.includes("?")?"&":"?";t=`${i}${u}mode=${l}`}k(),n(t)};return e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 py-8 flex-1 pb-24 sm:pb-8",children:[e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-2 text-sm font-medium text-gray-700 hover:text-gray-900 mb-4 transition-colors sm:hidden",children:[e.jsx(N,{className:"w-4 h-4"}),"Back"]}),e.jsx("h1",{className:"mb-2 text-2xl font-semibold text-gray-900",children:"Learning preferences"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Customize how you want Chinese Track to guide you. Changes are saved automatically."})]}),e.jsx("button",{type:"button",onClick:c,className:"hidden sm:flex items-center rounded-lg bg-orange-500 px-6 py-2.5 text-sm font-semibold text-white hover:bg-orange-600 shadow-sm transition-all duration-200 whitespace-nowrap",children:"Done"})]})}),e.jsx("div",{className:"rounded-2xl border border-gray-200 bg-gray-50 shadow-sm p-4 sm:p-6",children:e.jsx(w,{initialValues:s,onSave:a})})]}),e.jsx("div",{className:"fixed bottom-0 left-0 right-0 bg-white border-t border-gray-200 shadow-lg sm:hidden z-50",children:e.jsx("div",{className:"max-w-3xl mx-auto px-4 py-4",children:e.jsx("button",{type:"button",onClick:c,className:"w-full rounded-lg bg-orange-500 px-6 py-3 text-base font-semibold text-white hover:bg-orange-600 shadow-sm transition-all duration-200",children:"Return to course"})})})]})};export{$ as LearningPreferencesPage};
2//# sourceMappingURL=LearningPreferencesPage-BYPjY-PG.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.