Compare commits
2 Commits
feat/refak
...
20f4ee0427
| Author | SHA1 | Date | |
|---|---|---|---|
|
20f4ee0427
|
|||
|
be4cee4cdb
|
@@ -24,6 +24,7 @@
|
|||||||
"react-router": "^7.9.5",
|
"react-router": "^7.9.5",
|
||||||
"react-router-dom": "^7.9.5",
|
"react-router-dom": "^7.9.5",
|
||||||
"react-select-search": "^4.1.6",
|
"react-select-search": "^4.1.6",
|
||||||
|
"react-snow-overlay": "^1.0.14",
|
||||||
"react-snowfall": "^2.3.0",
|
"react-snowfall": "^2.3.0",
|
||||||
"react-toastify": "^11.0.5",
|
"react-toastify": "^11.0.5",
|
||||||
"recharts": "^3.4.1",
|
"recharts": "^3.4.1",
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ import { useSettings } from './context/settings';
|
|||||||
import Footer from './components/Footer';
|
import Footer from './components/Footer';
|
||||||
import { faChainBroken, faChevronLeft, faChevronRight, faGear, faSatelliteDish, faSearch } from '@fortawesome/free-solid-svg-icons';
|
import { faChainBroken, faChevronLeft, faChevronRight, faGear, faSatelliteDish, faSearch } from '@fortawesome/free-solid-svg-icons';
|
||||||
import Loader from './components/Loader';
|
import Loader from './components/Loader';
|
||||||
import { getDayOfWeekIndex, getHumanDate, getHumanDateTime, getIsWeekend, isInTheFuture } from './Utils';
|
import { getHumanDateTime, isInTheFuture } from './Utils';
|
||||||
import NoteModal from './components/modals/NoteModal';
|
import NoteModal from './components/modals/NoteModal';
|
||||||
import { useEasterEgg } from './context/eggs';
|
import { useEasterEgg } from './context/eggs';
|
||||||
import { ClientData, Food, PizzaOrder, DepartureTime, PizzaDayState, Restaurant, RestaurantDayMenu, RestaurantDayMenuMap, LunchChoice, UserLunchChoice, PizzaVariant, getData, getEasterEggImage, addPizza, removePizza, updatePizzaDayNote, createPizzaDay, deletePizzaDay, lockPizzaDay, unlockPizzaDay, finishOrder, finishDelivery, addChoice, jdemeObed, removeChoices, removeChoice, updateNote, changeDepartureTime } from '../../types';
|
import { ClientData, Food, PizzaOrder, DepartureTime, PizzaDayState, Restaurant, RestaurantDayMenu, RestaurantDayMenuMap, LunchChoice, UserLunchChoice, PizzaVariant, getData, getEasterEggImage, addPizza, removePizza, updatePizzaDayNote, createPizzaDay, deletePizzaDay, lockPizzaDay, unlockPizzaDay, finishOrder, finishDelivery, addChoice, jdemeObed, removeChoices, removeChoice, updateNote, changeDepartureTime } from '../../types';
|
||||||
import { getLunchChoiceName } from './enums';
|
import { getLunchChoiceName } from './enums';
|
||||||
import FallingLeaves, { LEAF_PRESETS, LEAF_COLOR_THEMES } from './FallingLeaves';
|
// import FallingLeaves, { LEAF_PRESETS, LEAF_COLOR_THEMES } from './FallingLeaves';
|
||||||
import './FallingLeaves.scss';
|
// import './FallingLeaves.scss';
|
||||||
|
|
||||||
const EVENT_CONNECT = "connect"
|
const EVENT_CONNECT = "connect"
|
||||||
|
|
||||||
@@ -71,10 +71,7 @@ function App() {
|
|||||||
const departureChoiceRef = useRef<HTMLSelectElement>(null);
|
const departureChoiceRef = useRef<HTMLSelectElement>(null);
|
||||||
const pizzaPoznamkaRef = useRef<HTMLInputElement>(null);
|
const pizzaPoznamkaRef = useRef<HTMLInputElement>(null);
|
||||||
const [failure, setFailure] = useState<boolean>(false);
|
const [failure, setFailure] = useState<boolean>(false);
|
||||||
const [dayIndex, setDayIndex] = useState<number>(); // Index zobrazovaného dne
|
const [dayIndex, setDayIndex] = useState<number>();
|
||||||
// TODO berka zde je nutné dořešit mocking pro testování
|
|
||||||
const [todayDayIndex, setTodayDayIndex] = useState<number>(getDayOfWeekIndex(new Date())); // Index dnešního dne
|
|
||||||
const [isTodayWeekend, setIsTodayWeekend] = useState<boolean>(getIsWeekend(new Date()));
|
|
||||||
const [loadingPizzaDay, setLoadingPizzaDay] = useState<boolean>(false);
|
const [loadingPizzaDay, setLoadingPizzaDay] = useState<boolean>(false);
|
||||||
const [noteModalOpen, setNoteModalOpen] = useState<boolean>(false);
|
const [noteModalOpen, setNoteModalOpen] = useState<boolean>(false);
|
||||||
const [eggImage, setEggImage] = useState<Blob>();
|
const [eggImage, setEggImage] = useState<Blob>();
|
||||||
@@ -92,9 +89,8 @@ function App() {
|
|||||||
const data = response.data
|
const data = response.data
|
||||||
if (data) {
|
if (data) {
|
||||||
setData(data);
|
setData(data);
|
||||||
const dayIndex = getDayOfWeekIndex(new Date(data.date));
|
setDayIndex(data.dayIndex);
|
||||||
setDayIndex(dayIndex);
|
dayIndexRef.current = data.dayIndex;
|
||||||
dayIndexRef.current = dayIndex;
|
|
||||||
setFood(data.menus);
|
setFood(data.menus);
|
||||||
}
|
}
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
@@ -107,8 +103,6 @@ function App() {
|
|||||||
if (!auth?.login) {
|
if (!auth?.login) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setTodayDayIndex(getDayOfWeekIndex(new Date()));
|
|
||||||
setIsTodayWeekend(getIsWeekend(new Date()));
|
|
||||||
getData({ query: { dayIndex: dayIndex } }).then(response => {
|
getData({ query: { dayIndex: dayIndex } }).then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
setData(data);
|
setData(data);
|
||||||
@@ -131,7 +125,7 @@ function App() {
|
|||||||
socket.on(EVENT_MESSAGE, (newData: ClientData) => {
|
socket.on(EVENT_MESSAGE, (newData: ClientData) => {
|
||||||
// console.log("Přijata nová data ze socketu", newData);
|
// console.log("Přijata nová data ze socketu", newData);
|
||||||
// Aktualizujeme pouze, pokud jsme dostali data pro den, který máme aktuálně zobrazený
|
// Aktualizujeme pouze, pokud jsme dostali data pro den, který máme aktuálně zobrazený
|
||||||
if (dayIndexRef.current == null || getDayOfWeekIndex(new Date(newData.date)) === dayIndexRef.current) {
|
if (dayIndexRef.current == null || newData.dayIndex === dayIndexRef.current) {
|
||||||
setData(newData);
|
setData(newData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -445,7 +439,7 @@ function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const noOrders = data?.pizzaDay?.orders?.length === 0;
|
const noOrders = data?.pizzaDay?.orders?.length === 0;
|
||||||
const canChangeChoice = dayIndex == null || dayIndex >= todayDayIndex;
|
const canChangeChoice = dayIndex == null || data.todayDayIndex == null || dayIndex >= data.todayDayIndex;
|
||||||
|
|
||||||
const { path, url, startOffset, endOffset, duration, ...style } = easterEgg || {};
|
const { path, url, startOffset, endOffset, duration, ...style } = easterEgg || {};
|
||||||
|
|
||||||
@@ -454,15 +448,15 @@ function App() {
|
|||||||
{easterEgg && eggImage && <img ref={eggRef} alt='' src={URL.createObjectURL(eggImage)} style={{ position: 'absolute', ...EASTER_EGG_STYLE, ...style, animationDuration: `${duration ?? EASTER_EGG_DEFAULT_DURATION}s` }} />}
|
{easterEgg && eggImage && <img ref={eggRef} alt='' src={URL.createObjectURL(eggImage)} style={{ position: 'absolute', ...EASTER_EGG_STYLE, ...style, animationDuration: `${duration ?? EASTER_EGG_DEFAULT_DURATION}s` }} />}
|
||||||
<Header />
|
<Header />
|
||||||
<div className='wrapper'>
|
<div className='wrapper'>
|
||||||
{isTodayWeekend ? <h4>Užívejte víkend :)</h4> : <>
|
{data.isWeekend ? <h4>Užívejte víkend :)</h4> : <>
|
||||||
<Alert variant={'primary'}>
|
<Alert variant={'primary'}>
|
||||||
{/* <img alt="" src='hat.png' style={{ position: "absolute", width: "70px", rotate: "-45deg", left: -40, top: -58 }} />
|
<img alt="" src='hat.png' style={{ position: "absolute", width: "70px", rotate: "-45deg", left: -40, top: -58 }} />
|
||||||
<img alt="" src='snowman.png' style={{ position: "absolute", height: "110px", right: 10, top: 5 }} /> */}
|
<img alt="" src='snowman.png' style={{ position: "absolute", height: "110px", right: 10, top: 5 }} />
|
||||||
Poslední změny:
|
Poslední změny:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Zobrazení alergenu při najetí myší a proklik na seznam alergenů</li>
|
<li>Oprava parsování Sladovnické</li>
|
||||||
<li>Přesun přenačtení menu do samostatného dialogu</li>
|
<li>Oprava parsování cen TechTower</li>
|
||||||
<li>Podzimní atmosféra</li>
|
<li>Zimní atmosféra</li>
|
||||||
</ul>
|
</ul>
|
||||||
</Alert>
|
</Alert>
|
||||||
{dayIndex != null &&
|
{dayIndex != null &&
|
||||||
@@ -470,7 +464,7 @@ function App() {
|
|||||||
<span title='Předchozí den'>
|
<span title='Předchozí den'>
|
||||||
<FontAwesomeIcon icon={faChevronLeft} style={{ cursor: "pointer", visibility: dayIndex > 0 ? "initial" : "hidden" }} onClick={() => handleDayChange(dayIndex - 1)} />
|
<FontAwesomeIcon icon={faChevronLeft} style={{ cursor: "pointer", visibility: dayIndex > 0 ? "initial" : "hidden" }} onClick={() => handleDayChange(dayIndex - 1)} />
|
||||||
</span>
|
</span>
|
||||||
<h1 className='title' style={{ color: dayIndex === todayDayIndex ? 'black' : 'gray' }}>{getHumanDate(new Date(data.date))}</h1>
|
<h1 className='title' style={{ color: dayIndex === data.todayDayIndex ? 'black' : 'gray' }}>{data.date}</h1>
|
||||||
<span title="Následující den">
|
<span title="Následující den">
|
||||||
<FontAwesomeIcon icon={faChevronRight} style={{ cursor: "pointer", visibility: dayIndex < 4 ? "initial" : "hidden" }} onClick={() => handleDayChange(dayIndex + 1)} />
|
<FontAwesomeIcon icon={faChevronRight} style={{ cursor: "pointer", visibility: dayIndex < 4 ? "initial" : "hidden" }} onClick={() => handleDayChange(dayIndex + 1)} />
|
||||||
</span>
|
</span>
|
||||||
@@ -486,7 +480,7 @@ function App() {
|
|||||||
<div className='content-wrapper'>
|
<div className='content-wrapper'>
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
{canChangeChoice && <>
|
{canChangeChoice && <>
|
||||||
<p>{`Jak to ${dayIndex == null || dayIndex === todayDayIndex ? 'dnes' : 'tento den'} vidíš s obědem?`}</p>
|
<p>{`Jak to ${dayIndex == null || dayIndex === data.todayDayIndex ? 'dnes' : 'tento den'} vidíš s obědem?`}</p>
|
||||||
<Form.Select ref={choiceRef} onChange={doAddChoice}>
|
<Form.Select ref={choiceRef} onChange={doAddChoice}>
|
||||||
<option></option>
|
<option></option>
|
||||||
{Object.entries(LunchChoice)
|
{Object.entries(LunchChoice)
|
||||||
@@ -595,7 +589,7 @@ function App() {
|
|||||||
: <div className='mt-5'><i>Zatím nikdo nehlasoval...</i></div>
|
: <div className='mt-5'><i>Zatím nikdo nehlasoval...</i></div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
{dayIndex === todayDayIndex &&
|
{dayIndex === data.todayDayIndex &&
|
||||||
<div className='mt-5'>
|
<div className='mt-5'>
|
||||||
{!data.pizzaDay &&
|
{!data.pizzaDay &&
|
||||||
<div style={{ textAlign: 'center' }}>
|
<div style={{ textAlign: 'center' }}>
|
||||||
@@ -717,10 +711,10 @@ function App() {
|
|||||||
</div>
|
</div>
|
||||||
</> || "Jejda, něco se nám nepovedlo :("}
|
</> || "Jejda, něco se nám nepovedlo :("}
|
||||||
</div>
|
</div>
|
||||||
<FallingLeaves
|
{/* <FallingLeaves
|
||||||
numLeaves={LEAF_PRESETS.NORMAL}
|
numLeaves={LEAF_PRESETS.NORMAL}
|
||||||
leafVariants={LEAF_COLOR_THEMES.AUTUMN}
|
leafVariants={LEAF_COLOR_THEMES.AUTUMN}
|
||||||
/>
|
/> */}
|
||||||
<Footer />
|
<Footer />
|
||||||
<NoteModal isOpen={noteModalOpen} onClose={() => setNoteModalOpen(false)} onSave={saveNote} />
|
<NoteModal isOpen={noteModalOpen} onClose={() => setNoteModalOpen(false)} onSave={saveNote} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Routes, Route } from "react-router-dom";
|
import { Routes, Route } from "react-router-dom";
|
||||||
import { ProvideSettings } from "./context/settings";
|
import { ProvideSettings } from "./context/settings";
|
||||||
// import Snowfall from "react-snowfall";
|
// import Snowfall from "react-snowfall";
|
||||||
|
import { SnowOverlay } from 'react-snow-overlay';
|
||||||
import { ToastContainer } from "react-toastify";
|
import { ToastContainer } from "react-toastify";
|
||||||
import { SocketContext, socket } from "./context/socket";
|
import { SocketContext, socket } from "./context/socket";
|
||||||
import StatsPage from "./pages/StatsPage";
|
import StatsPage from "./pages/StatsPage";
|
||||||
@@ -22,6 +23,7 @@ export default function AppRoutes() {
|
|||||||
width: '100vw',
|
width: '100vw',
|
||||||
height: '100vh'
|
height: '100vh'
|
||||||
}} /> */}
|
}} /> */}
|
||||||
|
<SnowOverlay color={'rgba(240, 240, 240, 0.9)'} disabledOnSingleCpuDevices={true} />
|
||||||
<App />
|
<App />
|
||||||
</>
|
</>
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
|
|||||||
@@ -73,12 +73,6 @@ export const getDayOfWeekIndex = (date: Date) => {
|
|||||||
return (((date.getDay() - 1) % 7) + 7) % 7;
|
return (((date.getDay() - 1) % 7) + 7) % 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Vrátí true, pokud je předané datum o víkendu. */
|
|
||||||
export function getIsWeekend(date: Date) {
|
|
||||||
const index = getDayOfWeekIndex(date);
|
|
||||||
return index == 5 || index == 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Vrátí první pracovní den v týdnu předaného data. */
|
/** Vrátí první pracovní den v týdnu předaného data. */
|
||||||
export function getFirstWorkDayOfWeek(date: Date) {
|
export function getFirstWorkDayOfWeek(date: Date) {
|
||||||
const firstDay = new Date(date.getTime());
|
const firstDay = new Date(date.getTime());
|
||||||
|
|||||||
@@ -1706,6 +1706,11 @@ react-select-search@^4.1.6:
|
|||||||
resolved "https://registry.yarnpkg.com/react-select-search/-/react-select-search-4.1.8.tgz#435bdd7893685d45332813ad65b000e0dafcfbac"
|
resolved "https://registry.yarnpkg.com/react-select-search/-/react-select-search-4.1.8.tgz#435bdd7893685d45332813ad65b000e0dafcfbac"
|
||||||
integrity sha512-mzHhYzpaAJ3iYDjayydfb+grvvP59VWlLUWLqP26Trvm4xj2rzLnksopWZdkwWORB3dhAneqmXos3RWOMjFOxQ==
|
integrity sha512-mzHhYzpaAJ3iYDjayydfb+grvvP59VWlLUWLqP26Trvm4xj2rzLnksopWZdkwWORB3dhAneqmXos3RWOMjFOxQ==
|
||||||
|
|
||||||
|
react-snow-overlay@^1.0.14:
|
||||||
|
version "1.0.14"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-snow-overlay/-/react-snow-overlay-1.0.14.tgz#1080ab24018bc9f86e7ae0e341b7d1b94ec80cc8"
|
||||||
|
integrity sha512-i178E9PVcMobSYxGiV+L2SMKcVNKytOwTG6Sz3dNw53Eq3Q0NC8BbVL4ewXXd/QCGX5YBVpv8R5+bSBxpUHeRw==
|
||||||
|
|
||||||
react-snowfall@^2.3.0:
|
react-snowfall@^2.3.0:
|
||||||
version "2.3.0"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/react-snowfall/-/react-snowfall-2.3.0.tgz#3c7af4fa8c3786d3d3b7ccdc36ddb73108d23b07"
|
resolved "https://registry.yarnpkg.com/react-snowfall/-/react-snowfall-2.3.0.tgz#3c7af4fa8c3786d3d3b7ccdc36ddb73108d23b07"
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ export const getMenuSladovnicka = async (firstDayOfWeek: Date, mock: boolean = f
|
|||||||
const html = await getHtml(SLADOVNICKA_URL);
|
const html = await getHtml(SLADOVNICKA_URL);
|
||||||
const $ = load(html);
|
const $ = load(html);
|
||||||
|
|
||||||
// Nejdříve zjistíme, které dny jsou k dispozici z tab elementů
|
// Zjistíme, které dny jsou k dispozici z tab elementů
|
||||||
const tabElements = $('#daily-menu-tab-list').children('button[id^="daily-menu-tab-"]');
|
const tabElements = $('#daily-menu-tab-list').children('button[id^="daily-menu-tab-"]');
|
||||||
const availableDays: { [dayIndex: number]: number } = {}; // mapování dayIndex -> contentIndex
|
const availableDays: { [dayIndex: number]: number } = {}; // mapování dayIndex -> contentIndex
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ export const getMenuSladovnicka = async (firstDayOfWeek: Date, mock: boolean = f
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const menuContentElements = $('#daily-menu-content-list').children('[id^="daily-menu-content-"]');
|
const menuContentElements = $('#daily-menu-content-list').children('.daily-menu-content__content').not('.daily-menu-content__content--static');
|
||||||
|
|
||||||
const result: Food[][] = [];
|
const result: Food[][] = [];
|
||||||
|
|
||||||
@@ -130,59 +130,32 @@ export const getMenuSladovnicka = async (firstDayOfWeek: Date, mock: boolean = f
|
|||||||
continue; // Přeskočíme, pokud content element neexistuje
|
continue; // Přeskočíme, pokud content element neexistuje
|
||||||
}
|
}
|
||||||
|
|
||||||
const dayChildren = $(menuContentElements[contentIndexNum]).children();
|
const contentElement = $(menuContentElements[contentIndexNum]);
|
||||||
|
const itemElement = contentElement.find('.daily-menu-content__item');
|
||||||
// Ověříme, že má element očekávanou strukturu
|
const table = itemElement.find('table.daily-menu-content__table tbody');
|
||||||
if (dayChildren.length < 2) {
|
const rows = table.children('tr');
|
||||||
console.warn(`Neočekávaný počet children v menu Sladovnické pro den ${dayIndexNum}: ${dayChildren.length}, očekávány alespoň 2 (polévka a hlavní jídlo)`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parsování polévky
|
|
||||||
const soupElement = dayChildren.get(0);
|
|
||||||
const soupTable = $(soupElement).find('table tbody tr');
|
|
||||||
const soupCells = soupTable.children('td');
|
|
||||||
if (soupCells.length !== 3) {
|
|
||||||
console.warn(`Neočekávaný počet buněk v tabulce polévky pro den ${dayIndexNum}: ${soupCells.length}, ale očekávány byly 3`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const soupAmount = sanitizeText($(soupCells.get(0)).text());
|
|
||||||
const soupNameRaw = sanitizeText($(soupCells.get(1)).text());
|
|
||||||
const soupPrice = sanitizeText($(soupCells.get(2)).text().replace(' ', '\xA0'));
|
|
||||||
const soupParsed = parseAllergens(soupNameRaw);
|
|
||||||
|
|
||||||
// Parsování hlavních jídel
|
|
||||||
const mainCourseElement = dayChildren.get(1);
|
|
||||||
const mainCourseTable = $(mainCourseElement).find('table tbody');
|
|
||||||
const mainCourseRows = mainCourseTable.children('tr');
|
|
||||||
|
|
||||||
const currentDayFood: Food[] = [];
|
const currentDayFood: Food[] = [];
|
||||||
|
|
||||||
// Přidáme polévku do seznamu jídel
|
// Projdeme všechny řádky - první je polévka, zbytek jsou hlavní jídla
|
||||||
currentDayFood.push({
|
rows.each((i, row) => {
|
||||||
amount: soupAmount,
|
|
||||||
name: soupParsed.cleanName,
|
|
||||||
price: soupPrice,
|
|
||||||
isSoup: true,
|
|
||||||
allergens: soupParsed.allergens.length > 0 ? soupParsed.allergens : undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Projdeme všechny řádky hlavních jídel
|
|
||||||
mainCourseRows.each((i, row) => {
|
|
||||||
const cells = $(row).children('td');
|
const cells = $(row).children('td');
|
||||||
|
if (cells.length !== 3) {
|
||||||
|
return; // Přeskočíme řádky s nesprávnou strukturou
|
||||||
|
}
|
||||||
|
|
||||||
const amount = sanitizeText($(cells.get(0)).text());
|
const amount = sanitizeText($(cells.get(0)).text());
|
||||||
const nameRaw = sanitizeText($(cells.get(1)).text());
|
const nameRaw = sanitizeText($(cells.get(1)).text());
|
||||||
const price = sanitizeText($(cells.get(2)).text().replace(' ', '\xA0'));
|
const price = sanitizeText($(cells.get(2)).text().replace(' ', '\xA0'));
|
||||||
const parsed = parseAllergens(nameRaw);
|
const parsed = parseAllergens(nameRaw);
|
||||||
|
|
||||||
// Přeskočíme prázdné řádky (první řádek může být prázdný)
|
// Přeskočíme prázdné řádky
|
||||||
if (parsed.cleanName.trim().length > 0) {
|
if (parsed.cleanName.trim().length > 0) {
|
||||||
currentDayFood.push({
|
currentDayFood.push({
|
||||||
amount,
|
amount,
|
||||||
name: parsed.cleanName,
|
name: parsed.cleanName,
|
||||||
price,
|
price,
|
||||||
isSoup: false,
|
isSoup: i === 0, // První řádek je polévka
|
||||||
allergens: parsed.allergens.length > 0 ? parsed.allergens : undefined,
|
allergens: parsed.allergens.length > 0 ? parsed.allergens : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -351,6 +324,11 @@ export const getMenuTechTower = async (firstDayOfWeek: Date, mock: boolean = fal
|
|||||||
const split = [tmp.slice(0, -2).join(' ')].concat(tmp.slice(-2));
|
const split = [tmp.slice(0, -2).join(' ')].concat(tmp.slice(-2));
|
||||||
price = `${split.slice(1)[0]}\xA0Kč`
|
price = `${split.slice(1)[0]}\xA0Kč`
|
||||||
nameRaw = split[0].replace('•', '');
|
nameRaw = split[0].replace('•', '');
|
||||||
|
} else if (text.toLowerCase().endsWith(',-')) {
|
||||||
|
const tmp = text.replace('\xA0', ' ').split(' ');
|
||||||
|
const split = [tmp.slice(0, -1).join(' ')].concat(tmp.slice(-1));
|
||||||
|
price = `${split.slice(1)[0].replace(',-', '')}\xA0Kč`
|
||||||
|
nameRaw = split[0].replace('•', '');
|
||||||
}
|
}
|
||||||
if (nameRaw.endsWith('–')) {
|
if (nameRaw.endsWith('–')) {
|
||||||
nameRaw = nameRaw.slice(0, -1).trim();
|
nameRaw = nameRaw.slice(0, -1).trim();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { InsufficientPermissions, formatDate, getDayOfWeekIndex, getFirstWorkDayOfWeek, getIsWeekend, getWeekNumber } from "./utils";
|
import { InsufficientPermissions, formatDate, getDayOfWeekIndex, getFirstWorkDayOfWeek, getHumanDate, getIsWeekend, getWeekNumber } from "./utils";
|
||||||
import getStorage from "./storage";
|
import getStorage from "./storage";
|
||||||
import { getMenuSladovnicka, getMenuTechTower, getMenuZastavkaUmichala, getMenuSenkSerikova } from "./restaurants";
|
import { getMenuSladovnicka, getMenuTechTower, getMenuZastavkaUmichala, getMenuSenkSerikova } from "./restaurants";
|
||||||
import { getTodayMock } from "./mock";
|
import { getTodayMock } from "./mock";
|
||||||
@@ -31,7 +31,10 @@ export const getDateForWeekIndex = (index: number) => {
|
|||||||
function getEmptyData(date?: Date): ClientData {
|
function getEmptyData(date?: Date): ClientData {
|
||||||
const usedDate = date || getToday();
|
const usedDate = date || getToday();
|
||||||
return {
|
return {
|
||||||
date: usedDate.toISOString().split('T')[0],
|
todayDayIndex: getDayOfWeekIndex(getToday()),
|
||||||
|
date: getHumanDate(usedDate),
|
||||||
|
isWeekend: getIsWeekend(usedDate),
|
||||||
|
dayIndex: getDayOfWeekIndex(usedDate),
|
||||||
choices: {},
|
choices: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -483,5 +486,9 @@ export async function updateDepartureTime(login: string, time?: string, date?: D
|
|||||||
export async function getClientData(date?: Date): Promise<ClientData> {
|
export async function getClientData(date?: Date): Promise<ClientData> {
|
||||||
const targetDate = date ?? getToday();
|
const targetDate = date ?? getToday();
|
||||||
const dateString = formatDate(targetDate);
|
const dateString = formatDate(targetDate);
|
||||||
return await storage.getData<ClientData>(dateString) || getEmptyData(date);
|
const clientData = await storage.getData<ClientData>(dateString) || getEmptyData(date);
|
||||||
|
return {
|
||||||
|
...clientData,
|
||||||
|
todayDayIndex: getDayOfWeekIndex(getToday()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,13 +21,23 @@ ClientData:
|
|||||||
type: object
|
type: object
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
|
- todayDayIndex
|
||||||
- date
|
- date
|
||||||
|
- isWeekend
|
||||||
- choices
|
- choices
|
||||||
properties:
|
properties:
|
||||||
|
todayDayIndex:
|
||||||
|
description: Index dnešního dne v týdnu
|
||||||
|
$ref: "#/DayIndex"
|
||||||
date:
|
date:
|
||||||
description: Datum konkrétního dne
|
description: Human-readable datum dne
|
||||||
type: string
|
type: string
|
||||||
format: date
|
isWeekend:
|
||||||
|
description: Příznak, zda je tento den víkend
|
||||||
|
type: boolean
|
||||||
|
dayIndex:
|
||||||
|
description: Index dne v týdnu, ke kterému se vztahují tato data
|
||||||
|
$ref: "#/DayIndex"
|
||||||
choices:
|
choices:
|
||||||
$ref: "#/LunchChoices"
|
$ref: "#/LunchChoices"
|
||||||
menus:
|
menus:
|
||||||
|
|||||||
Reference in New Issue
Block a user