From 8288ccfd85480055a1918ecb1c19f0a9a185a039 Mon Sep 17 00:00:00 2001 From: dani Date: Tue, 31 Dec 2024 18:08:00 -0500 Subject: [PATCH 1/7] Nest language config options inside configurationOptionsSlice hotfix/wrap-configurations-on-slice-store --- src/store/store.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/store/store.js b/src/store/store.js index 4d02615..dbfb5a1 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -56,10 +56,12 @@ const tasksSlice = (set, get) => ({ resetWorkedHoursHistory: () => resetWorkedHoursHistory(set) }) -const languageSlice = (set) => ({ - current: localStorage.getItem("currentLanguage") || "english", - setCurrent: (language) => setCurrent(set, language), - text: () => text +const configurationOptionsSlice = () => ({ + language: (set) => ({ + current: localStorage.getItem("currentLanguage") || "english", + setCurrent: (language) => setCurrent(set, language), + text: () => text + }) }) export const Store = create(devtools((set, get) => ({ @@ -67,5 +69,5 @@ export const Store = create(devtools((set, get) => ({ weekly: todoWeeklySlice(set, get), monthly: todoMonthlySlice(set, get), tasks: tasksSlice(set, get), - language: languageSlice(set) + configs: configurationOptionsSlice() }))) \ No newline at end of file From 0139780a73999f9ff85706ce7e101efcb8ecf80d Mon Sep 17 00:00:00 2001 From: dani Date: Tue, 31 Dec 2024 18:27:25 -0500 Subject: [PATCH 2/7] Replace reference of store.language for store.configs.language() hotfix/wrap-configurations-on-slice-store --- src/doing/Clock.jsx | 2 +- src/doing/Doing.jsx | 2 +- src/doing/Footer.jsx | 8 ++++---- src/doing/Quote.jsx | 2 +- src/done/Done.jsx | 2 +- src/store/store.js | 4 ++-- src/todo/Todos.jsx | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/doing/Clock.jsx b/src/doing/Clock.jsx index 7cf5245..1389f51 100644 --- a/src/doing/Clock.jsx +++ b/src/doing/Clock.jsx @@ -5,7 +5,7 @@ import './Clock.css' export const Clock = () => { const store = Store() - const text = store.language.current === "english" ? store.language.text().english : store.language.text().spanish + const text = store.configs.language().current === "english" ? store.configs.language().text().english : store.configs.language().text().spanish const countdownRef = useRef(null) const audioStart = new Audio('/start.mp3') const audioAlarm = new Audio('/clock_alarm.mp3') diff --git a/src/doing/Doing.jsx b/src/doing/Doing.jsx index 3526e6c..049af58 100644 --- a/src/doing/Doing.jsx +++ b/src/doing/Doing.jsx @@ -5,7 +5,7 @@ import { Footer } from './Footer.jsx' export const Doing = () => { const store = Store() - const text = store.language.current === "english" ? store.language.text().english : store.language.text().spanish + const text = store.configs.language().current === "english" ? store.configs.language().text().english : store.configs.language().text().spanish return (
diff --git a/src/doing/Footer.jsx b/src/doing/Footer.jsx index 8082dbb..772d010 100644 --- a/src/doing/Footer.jsx +++ b/src/doing/Footer.jsx @@ -9,7 +9,7 @@ export const Footer = () => { const [show3, setShow3] = useState(false) // "CONFIRM OR CANCEL" RESETING DIALOG (show or hide) const [show4, setShow4] = useState(true) // "RESET TOTAL WORKED HOURS" BUTTON (show or hide) // catch english or spanish json texts, this change when the user clicks on change language buttons - const text = store.language.current === "english" ? store.language.text().english : store.language.text().spanish + const text = store.configs.language().current === "english" ? store.configs.language().text().english : store.configs.language().text().spanish const infoBtn = () => (setShow1(!show1), setShow2(false), setShow3(false), setShow4(true)) const settingsBtn = () => (setShow2(!show2), setShow1(false), setShow3(false), setShow4(true)) @@ -19,7 +19,7 @@ export const Footer = () => { useEffect(() => localStorage.setItem("infoVisibility", show1), [show1]) useEffect(() => localStorage.setItem("settingsVisibility", show2), [show2]) - useEffect(() => localStorage.setItem("currentLanguage", store.language.current), [store.language]) + useEffect(() => localStorage.setItem("currentLanguage", store.configs.language().current), [store.configs.language()]) return (
@@ -48,8 +48,8 @@ export const Footer = () => {
{text.doing.footer.settings.language.message} - - + +
{text.doing.footer.settings.theme.message} diff --git a/src/doing/Quote.jsx b/src/doing/Quote.jsx index 591e33f..e8a9593 100644 --- a/src/doing/Quote.jsx +++ b/src/doing/Quote.jsx @@ -19,7 +19,7 @@ export const Quote = () => { maxLength: 70, } }) - if (store.language.current === "spanish") await translateQuote(response.data.content) + if (store.configs.language().current === "spanish") await translateQuote(response.data.content) else setQuote(response.data.content) setAuthor(response.data.author) } diff --git a/src/done/Done.jsx b/src/done/Done.jsx index 4a38b5f..5023363 100644 --- a/src/done/Done.jsx +++ b/src/done/Done.jsx @@ -4,7 +4,7 @@ import './Done.css' export const Done = () => { const store = Store() - const text = store.language.current === "english" ? store.language.text().english : store.language.text().spanish + const text = store.configs.language().current === "english" ? store.configs.language().text().english : store.configs.language().text().spanish const [input, setInput] = useState("") const [showModal, setShowModal] = useState("hide") const [showFooter, setShowFooter] = useState("") diff --git a/src/store/store.js b/src/store/store.js index dbfb5a1..3545e6b 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -56,7 +56,7 @@ const tasksSlice = (set, get) => ({ resetWorkedHoursHistory: () => resetWorkedHoursHistory(set) }) -const configurationOptionsSlice = () => ({ +const configurationOptionsSlice = (set) => ({ language: (set) => ({ current: localStorage.getItem("currentLanguage") || "english", setCurrent: (language) => setCurrent(set, language), @@ -69,5 +69,5 @@ export const Store = create(devtools((set, get) => ({ weekly: todoWeeklySlice(set, get), monthly: todoMonthlySlice(set, get), tasks: tasksSlice(set, get), - configs: configurationOptionsSlice() + configs: configurationOptionsSlice(set) }))) \ No newline at end of file diff --git a/src/todo/Todos.jsx b/src/todo/Todos.jsx index eb8d843..8c16d57 100644 --- a/src/todo/Todos.jsx +++ b/src/todo/Todos.jsx @@ -3,10 +3,10 @@ import { Todo } from './Todo.jsx' export const Todos = () => { const store = Store() - const title = store.language.current === "english" + const title = store.configs.language().current === "english" ? ["Daily Goals", "Weekly Goals", "Monthly Goals"] : ["Objetivos Diarios", "Objetivos Semanales", "Objetivos Mensuales"] - const text = store.language.current === "english" ? store.language.text().english : store.language.text().spanish + const text = store.configs.language().current === "english" ? store.configs.language().text().english : store.configs.language.text().spanish return (

{text.todo.title}

From 7edf817c68e1c72f150e98a0fa3695433e3e910e Mon Sep 17 00:00:00 2001 From: dani Date: Wed, 1 Jan 2025 13:06:31 -0500 Subject: [PATCH 3/7] Change language() for language:{} on option slice in store hotfix/wrap-configurations-on-slice-store --- src/store/language.js | 9 ++++++--- src/store/store.js | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/store/language.js b/src/store/language.js index 73967f1..cb82798 100644 --- a/src/store/language.js +++ b/src/store/language.js @@ -146,9 +146,12 @@ export const text = { } export const setCurrent = (set, language) => set(state => ({ - language: { - ...state.language, - current: language + configs: { + ...state.configs, + language: { + ...state.configs.language, + current: language + } } }), false, 'language/setCurrent') diff --git a/src/store/store.js b/src/store/store.js index 3545e6b..fd07c49 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -57,11 +57,11 @@ const tasksSlice = (set, get) => ({ }) const configurationOptionsSlice = (set) => ({ - language: (set) => ({ + language: { current: localStorage.getItem("currentLanguage") || "english", setCurrent: (language) => setCurrent(set, language), text: () => text - }) + } }) export const Store = create(devtools((set, get) => ({ From 3ca0f2fb7e939ed5016180c12ce27e456a03cede Mon Sep 17 00:00:00 2001 From: dani Date: Wed, 1 Jan 2025 13:08:14 -0500 Subject: [PATCH 4/7] Update all components that use the store value configs/language hotfix/wrap-configurations-on-slice-store --- src/doing/Clock.jsx | 2 +- src/doing/Doing.jsx | 2 +- src/doing/Footer.jsx | 8 ++++---- src/doing/Quote.jsx | 2 +- src/done/Done.jsx | 2 +- src/todo/Todos.jsx | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/doing/Clock.jsx b/src/doing/Clock.jsx index 1389f51..6aa2aed 100644 --- a/src/doing/Clock.jsx +++ b/src/doing/Clock.jsx @@ -5,7 +5,7 @@ import './Clock.css' export const Clock = () => { const store = Store() - const text = store.configs.language().current === "english" ? store.configs.language().text().english : store.configs.language().text().spanish + const text = store.configs.language.current === "english" ? store.configs.language.text().english : store.configs.language.text().spanish const countdownRef = useRef(null) const audioStart = new Audio('/start.mp3') const audioAlarm = new Audio('/clock_alarm.mp3') diff --git a/src/doing/Doing.jsx b/src/doing/Doing.jsx index 049af58..712ed57 100644 --- a/src/doing/Doing.jsx +++ b/src/doing/Doing.jsx @@ -5,7 +5,7 @@ import { Footer } from './Footer.jsx' export const Doing = () => { const store = Store() - const text = store.configs.language().current === "english" ? store.configs.language().text().english : store.configs.language().text().spanish + const text = store.configs.language.current === "english" ? store.configs.language.text().english : store.configs.language.text().spanish return (
diff --git a/src/doing/Footer.jsx b/src/doing/Footer.jsx index 772d010..371cf28 100644 --- a/src/doing/Footer.jsx +++ b/src/doing/Footer.jsx @@ -9,7 +9,7 @@ export const Footer = () => { const [show3, setShow3] = useState(false) // "CONFIRM OR CANCEL" RESETING DIALOG (show or hide) const [show4, setShow4] = useState(true) // "RESET TOTAL WORKED HOURS" BUTTON (show or hide) // catch english or spanish json texts, this change when the user clicks on change language buttons - const text = store.configs.language().current === "english" ? store.configs.language().text().english : store.configs.language().text().spanish + const text = store.configs.language.current === "english" ? store.configs.language.text().english : store.configs.language.text().spanish const infoBtn = () => (setShow1(!show1), setShow2(false), setShow3(false), setShow4(true)) const settingsBtn = () => (setShow2(!show2), setShow1(false), setShow3(false), setShow4(true)) @@ -19,7 +19,7 @@ export const Footer = () => { useEffect(() => localStorage.setItem("infoVisibility", show1), [show1]) useEffect(() => localStorage.setItem("settingsVisibility", show2), [show2]) - useEffect(() => localStorage.setItem("currentLanguage", store.configs.language().current), [store.configs.language()]) + useEffect(() => localStorage.setItem("currentLanguage", store.configs.language.current), [store.configs.language]) return (
@@ -48,8 +48,8 @@ export const Footer = () => {
{text.doing.footer.settings.language.message} - - + +
{text.doing.footer.settings.theme.message} diff --git a/src/doing/Quote.jsx b/src/doing/Quote.jsx index e8a9593..3a04bde 100644 --- a/src/doing/Quote.jsx +++ b/src/doing/Quote.jsx @@ -19,7 +19,7 @@ export const Quote = () => { maxLength: 70, } }) - if (store.configs.language().current === "spanish") await translateQuote(response.data.content) + if (store.configs.language.current === "spanish") await translateQuote(response.data.content) else setQuote(response.data.content) setAuthor(response.data.author) } diff --git a/src/done/Done.jsx b/src/done/Done.jsx index 5023363..22d6df1 100644 --- a/src/done/Done.jsx +++ b/src/done/Done.jsx @@ -4,7 +4,7 @@ import './Done.css' export const Done = () => { const store = Store() - const text = store.configs.language().current === "english" ? store.configs.language().text().english : store.configs.language().text().spanish + const text = store.configs.language.current === "english" ? store.configs.language.text().english : store.configs.language.text().spanish const [input, setInput] = useState("") const [showModal, setShowModal] = useState("hide") const [showFooter, setShowFooter] = useState("") diff --git a/src/todo/Todos.jsx b/src/todo/Todos.jsx index 8c16d57..95ec439 100644 --- a/src/todo/Todos.jsx +++ b/src/todo/Todos.jsx @@ -3,10 +3,10 @@ import { Todo } from './Todo.jsx' export const Todos = () => { const store = Store() - const title = store.configs.language().current === "english" + const title = store.configs.language.current === "english" ? ["Daily Goals", "Weekly Goals", "Monthly Goals"] : ["Objetivos Diarios", "Objetivos Semanales", "Objetivos Mensuales"] - const text = store.configs.language().current === "english" ? store.configs.language().text().english : store.configs.language.text().spanish + const text = store.configs.language.current === "english" ? store.configs.language.text().english : store.configs.language.text().spanish return (

{text.todo.title}

From 152efb3722f59bdd287eacc1d731feb51b8afffc Mon Sep 17 00:00:00 2001 From: dani Date: Wed, 1 Jan 2025 13:49:27 -0500 Subject: [PATCH 5/7] Create TODO code for commonTasks on configs slice hotfix/wrap-configurations-on-slice-store --- src/store/store.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/store/store.js b/src/store/store.js index fd07c49..e037344 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -61,6 +61,11 @@ const configurationOptionsSlice = (set) => ({ current: localStorage.getItem("currentLanguage") || "english", setCurrent: (language) => setCurrent(set, language), text: () => text + }, + commonTasks: { + // currents: [], + // add: ()=>(), + // remove: ()=>() } }) From 061ef7581d9202344f8773f93c3ec69802e8d1d4 Mon Sep 17 00:00:00 2001 From: dani Date: Wed, 1 Jan 2025 13:50:46 -0500 Subject: [PATCH 6/7] Fix typo error hotfix/wrap-configurations-on-slice-store --- src/doing/Footer.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doing/Footer.jsx b/src/doing/Footer.jsx index 371cf28..9855c61 100644 --- a/src/doing/Footer.jsx +++ b/src/doing/Footer.jsx @@ -58,7 +58,7 @@ export const Footer = () => {
{text.doing.footer.settings.commonTasks.message} - LEARN x_____CODE x_____AdivLY x + LEARN x_____CODE x_____APPLY x
From b9b0298f7e7750f88f9f2c528481840c35e0036b Mon Sep 17 00:00:00 2001 From: dani Date: Wed, 1 Jan 2025 13:53:13 -0500 Subject: [PATCH 7/7] Change action name of set current language on store hotfix/wrap-configurations-on-slice-store --- src/store/language.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/language.js b/src/store/language.js index cb82798..5081e96 100644 --- a/src/store/language.js +++ b/src/store/language.js @@ -153,5 +153,5 @@ export const setCurrent = (set, language) => set(state => ({ current: language } } -}), false, 'language/setCurrent') +}), false, 'configs/language/setCurrent')