feat: umožnění automatického přepnutí na volbu "Budu objednávat" při přidání se k objednávce
CI / Generate TypeScript types (push) Successful in 16s
CI / Server unit tests (push) Successful in 29s
CI / Build server (push) Successful in 31s
CI / Build client (push) Successful in 42s
CI / Playwright E2E tests (push) Successful in 2m16s
CI / Build and push Docker image (push) Successful in 1m11s
CI / Notify (push) Successful in 3s
CI / Generate TypeScript types (push) Successful in 16s
CI / Server unit tests (push) Successful in 29s
CI / Build server (push) Successful in 31s
CI / Build client (push) Successful in 42s
CI / Playwright E2E tests (push) Successful in 2m16s
CI / Build and push Docker image (push) Successful in 1m11s
CI / Notify (push) Successful in 3s
This commit is contained in:
4 files changed
+66
-4
No files matched your search
@@ -8,6 +8,7 @@ const ACCENT_HUE_KEY = 'accent_hue';
|
||||
const LEGACY_COLOR_THEME_KEY = 'color_theme';
|
||||
const STYLE_THEME_KEY = 'style_theme';
|
||||
const SHOW_BUTTERFLIES_KEY = 'show_butterflies';
|
||||
const AUTO_ORDER_CHOICE_KEY = 'auto_order_choice';
|
||||
|
||||
export type ThemePreference = 'system' | 'light' | 'dark';
|
||||
|
||||
@@ -32,6 +33,7 @@ export type SettingsContextProps = {
|
||||
effectiveDark: boolean,
|
||||
styleTheme: StyleTheme,
|
||||
showButterflies: boolean,
|
||||
autoOrderChoice: boolean,
|
||||
setBankAccountNumber: (accountNumber?: string) => void,
|
||||
setBankAccountHolderName: (holderName?: string) => void,
|
||||
setHideSoupsOption: (hideSoups?: boolean) => void,
|
||||
@@ -39,6 +41,7 @@ export type SettingsContextProps = {
|
||||
setAccentHue: (hue: number) => void,
|
||||
setStyleTheme: (theme: StyleTheme) => void,
|
||||
setShowButterflies: (show: boolean) => void,
|
||||
setAutoOrderChoice: (enabled: boolean) => void,
|
||||
}
|
||||
|
||||
type ContextProps = {
|
||||
@@ -90,6 +93,15 @@ function getInitialShowButterflies(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
function getInitialAutoOrderChoice(): boolean {
|
||||
try {
|
||||
return localStorage.getItem(AUTO_ORDER_CHOICE_KEY) === 'true';
|
||||
} catch {
|
||||
// localStorage nedostupný
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getInitialAccentHue(): number {
|
||||
try {
|
||||
const saved = localStorage.getItem(ACCENT_HUE_KEY);
|
||||
@@ -158,6 +170,7 @@ function useProvideSettings(): SettingsContextProps {
|
||||
const [accentHue, setHue] = useState<number>(getInitialAccentHue);
|
||||
const [styleTheme, setStyle] = useState<StyleTheme>(getInitialStyleTheme);
|
||||
const [showButterflies, setShowButterfliesState] = useState<boolean>(getInitialShowButterflies);
|
||||
const [autoOrderChoice, setAutoOrderChoiceState] = useState<boolean>(getInitialAutoOrderChoice);
|
||||
const [effectiveDark, setEffectiveDark] = useState<boolean>(() => {
|
||||
try {
|
||||
const pref = localStorage.getItem(THEME_KEY) as ThemePreference | null;
|
||||
@@ -235,6 +248,10 @@ function useProvideSettings(): SettingsContextProps {
|
||||
localStorage.setItem(SHOW_BUTTERFLIES_KEY, showButterflies ? 'true' : 'false');
|
||||
}, [showButterflies]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem(AUTO_ORDER_CHOICE_KEY, autoOrderChoice ? 'true' : 'false');
|
||||
}, [autoOrderChoice]);
|
||||
|
||||
// Aplikuje accent barvy při změně hue nebo přepnutí světlý/tmavý.
|
||||
// Tematické styly (Umamusume, My Little Pony, Hell Girl, K-ON!, Bocchi the Rock!) mají vlastní pevnou paletu, accent barvu proto uplatňuje jen jednoduchý styl.
|
||||
useEffect(() => {
|
||||
@@ -274,6 +291,10 @@ function useProvideSettings(): SettingsContextProps {
|
||||
setShowButterfliesState(show);
|
||||
}
|
||||
|
||||
function setAutoOrderChoice(enabled: boolean) {
|
||||
setAutoOrderChoiceState(enabled);
|
||||
}
|
||||
|
||||
return {
|
||||
bankAccount,
|
||||
holderName,
|
||||
@@ -290,5 +311,7 @@ function useProvideSettings(): SettingsContextProps {
|
||||
setStyleTheme,
|
||||
showButterflies,
|
||||
setShowButterflies,
|
||||
autoOrderChoice,
|
||||
setAutoOrderChoice,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user