Podpora víkendů
This commit is contained in:
parent
d59e439588
commit
ec1cbf332b
@ -93,6 +93,7 @@ function App() {
|
|||||||
<>
|
<>
|
||||||
<Header />
|
<Header />
|
||||||
<div className='wrapper'>
|
<div className='wrapper'>
|
||||||
|
{data.isWeekend ? <h4>Užívejte víkend :)</h4> : <>
|
||||||
<Alert variant={'primary'}>
|
<Alert variant={'primary'}>
|
||||||
Tvé zobrazované jméno je {auth.login}. Změnu můžeš provést v local storage prohlížeče.<br />
|
Tvé zobrazované jméno je {auth.login}. Změnu můžeš provést v local storage prohlížeče.<br />
|
||||||
<small>Pro gamer move: Změň si své jméno na cizí. Můžeš pak libovolně měnit jejich volbu.</small>
|
<small>Pro gamer move: Změň si své jméno na cizí. Můžeš pak libovolně měnit jejich volbu.</small>
|
||||||
@ -138,6 +139,7 @@ function App() {
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</>}
|
||||||
{/* {!pizzaDayExists &&
|
{/* {!pizzaDayExists &&
|
||||||
<div>
|
<div>
|
||||||
<p>Pro dnešní den není aktuálně založen Pizza day.</p>
|
<p>Pro dnešní den není aktuálně založen Pizza day.</p>
|
||||||
|
@ -19,6 +19,7 @@ export interface Choices {
|
|||||||
|
|
||||||
export interface ClientData {
|
export interface ClientData {
|
||||||
date: string, // dnešní datum pro zobrazení
|
date: string, // dnešní datum pro zobrazení
|
||||||
|
isWeekend: boolean, // příznak zda je dnešní den víkend
|
||||||
choices: Choices, // seznam voleb
|
choices: Choices, // seznam voleb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ClientData, Locations } from "./types";
|
import { ClientData, Locations } from "./types";
|
||||||
import { db } from "./database";
|
import { db } from "./database";
|
||||||
import { getTodayString } from "./utils";
|
import { getHumanDate, getIsWeekend } from "./utils";
|
||||||
import { getDate } from "./utils";
|
import { getDate } from "./utils";
|
||||||
|
|
||||||
// /** Jedna konkrétní pizza */
|
// /** Jedna konkrétní pizza */
|
||||||
@ -33,7 +33,7 @@ import { getDate } from "./utils";
|
|||||||
|
|
||||||
/** Vrátí "prázdná" (implicitní) data, pokud ještě nikdo nehlasoval. */
|
/** Vrátí "prázdná" (implicitní) data, pokud ještě nikdo nehlasoval. */
|
||||||
function getEmptyData(): ClientData {
|
function getEmptyData(): ClientData {
|
||||||
return { date: getTodayString(), choices: {} };
|
return { date: getHumanDate(new Date()), isWeekend: getIsWeekend(new Date()), choices: {} };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,7 @@ export interface Choices {
|
|||||||
|
|
||||||
export interface ClientData {
|
export interface ClientData {
|
||||||
date: string, // dnešní datum pro zobrazení
|
date: string, // dnešní datum pro zobrazení
|
||||||
|
isWeekend: boolean, // příznak, zda je dnes víkend
|
||||||
choices: Choices, // seznam voleb
|
choices: Choices, // seznam voleb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,12 +6,17 @@ export function getDate() {
|
|||||||
return `${currentYear}-${currentMonth}-${currentDay}`;
|
return `${currentYear}-${currentMonth}-${currentDay}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Vrátí human-readable reprezentaci dnešního data pro zobrazení. */
|
/** Vrátí human-readable reprezentaci předaného data pro zobrazení. */
|
||||||
export function getTodayString() {
|
export function getHumanDate(date: Date) {
|
||||||
const date = new Date();
|
|
||||||
let currentDay = String(date.getDate()).padStart(2, '0');
|
let currentDay = String(date.getDate()).padStart(2, '0');
|
||||||
let currentMonth = String(date.getMonth() + 1).padStart(2, "0");
|
let currentMonth = String(date.getMonth() + 1).padStart(2, "0");
|
||||||
let currentYear = date.getFullYear();
|
let currentYear = date.getFullYear();
|
||||||
let currentDayOfWeek = date.toLocaleDateString("CZ-cs", { weekday: 'long' });
|
let currentDayOfWeek = date.toLocaleDateString("CZ-cs", { weekday: 'long' });
|
||||||
return `${currentDay}.${currentMonth}.${currentYear} (${currentDayOfWeek})`;
|
return `${currentDay}.${currentMonth}.${currentYear} (${currentDayOfWeek})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Vrátí true, pokud je předané datum o víkendu. */
|
||||||
|
export function getIsWeekend(date: Date) {
|
||||||
|
const dayName = date.toLocaleDateString("CZ-cs", { weekday: 'long' }).toLowerCase()
|
||||||
|
return dayName === 'sobota' || dayName === 'neděle'
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user