Přidání restaurace Zastávka u Michala
This commit is contained in:
parent
02de6691a8
commit
0fd1482810
@ -351,7 +351,7 @@ function App() {
|
|||||||
} else {
|
} else {
|
||||||
content = <h3>Chyba načtení dat</h3>
|
content = <h3>Chyba načtení dat</h3>
|
||||||
}
|
}
|
||||||
return <Col md={12} lg={6} className='mt-3'>
|
return <Col md={12} lg={4} className='mt-3'>
|
||||||
<h3>{name}</h3>
|
<h3>{name}</h3>
|
||||||
{menu?.lastUpdate && <small>Poslední aktualizace: {getHumanDateTime(new Date(menu.lastUpdate))}</small>}
|
{menu?.lastUpdate && <small>Poslední aktualizace: {getHumanDateTime(new Date(menu.lastUpdate))}</small>}
|
||||||
{content}
|
{content}
|
||||||
@ -417,6 +417,7 @@ function App() {
|
|||||||
{food[Restaurants.SLADOVNICKA] && renderFoodTable('Sladovnická', food[Restaurants.SLADOVNICKA])}
|
{food[Restaurants.SLADOVNICKA] && renderFoodTable('Sladovnická', food[Restaurants.SLADOVNICKA])}
|
||||||
{/* {food[Restaurants.UMOTLIKU] && renderFoodTable('U Motlíků', food[Restaurants.UMOTLIKU])} */}
|
{/* {food[Restaurants.UMOTLIKU] && renderFoodTable('U Motlíků', food[Restaurants.UMOTLIKU])} */}
|
||||||
{food[Restaurants.TECHTOWER] && renderFoodTable('TechTower', food[Restaurants.TECHTOWER])}
|
{food[Restaurants.TECHTOWER] && renderFoodTable('TechTower', food[Restaurants.TECHTOWER])}
|
||||||
|
{food[Restaurants.ZASTAVKAUMICHALA] && renderFoodTable('Zastávka u Michala', food[Restaurants.ZASTAVKAUMICHALA])}
|
||||||
</Row>
|
</Row>
|
||||||
<div className='content-wrapper'>
|
<div className='content-wrapper'>
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
|
@ -427,6 +427,96 @@ const MOCK_DATA = {
|
|||||||
isSoup: false,
|
isSoup: false,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
],
|
||||||
|
'zastavkaUmichala': [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Fazolačka s klobásou & zakysačkou",
|
||||||
|
price: "39\xA0Kč",
|
||||||
|
isSoup: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Zeleninová musaka – lilek, cuketa, tomatové sugo & sýrový bešamel",
|
||||||
|
price: "135\xA0Kč",
|
||||||
|
isSoup: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Slovácké strapačky s uzenou slaninou, zelím, mletým pepřem & sekanou petrželkou",
|
||||||
|
price: "140\xA0Kč",
|
||||||
|
isSoup: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Hovězí guláš s vejcem, zeleninovou garniturkou & žemlovými knedlíky",
|
||||||
|
price: "145\xA0Kč",
|
||||||
|
isSoup: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Kuřecí roláda s kaštanovou nádivkou, demi-glace & smetanovou bramborovou kaší",
|
||||||
|
price: "150\xA0Kč",
|
||||||
|
isSoup: false,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Hovězí vývar se zeleninou a játrovou rýží",
|
||||||
|
price: "39\xA0Kč",
|
||||||
|
isSoup: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Pečené vepřové koleno, křen, hořčice, chléb",
|
||||||
|
price: "320\xA0Kč",
|
||||||
|
isSoup: false,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Zeleninová polévka s kuskusem",
|
||||||
|
price: "39\xA0Kč",
|
||||||
|
isSoup: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Poutine (trhané vepřové, hranolky, sýr, čalamáda, pikantní omáčka)",
|
||||||
|
price: "190\xA0Kč",
|
||||||
|
isSoup: false,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Hrachová polévka s uzeninou",
|
||||||
|
price: "39\xA0Kč",
|
||||||
|
isSoup: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Vepřový řízek z kotlety, domácí bramborový salát",
|
||||||
|
price: "170\xA0Kč",
|
||||||
|
isSoup: false,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Cibulačka se sýrem",
|
||||||
|
price: "39\xA0Kč",
|
||||||
|
isSoup: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
amount: "-",
|
||||||
|
name: "Burger z Chuck rollu, hranolky, tatarská omáčka",
|
||||||
|
price: "200\xA0Kč",
|
||||||
|
isSoup: false,
|
||||||
|
}
|
||||||
|
],
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1180,8 +1270,11 @@ const MOCK_PIZZA_LIST = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
export const getTodayMock = () => {
|
/**
|
||||||
return '2023-05-31'; // středa
|
* Funkce vrací mock datu ve formátu YYYY-MM-DD
|
||||||
|
*/
|
||||||
|
export const getTodayMock = (): Date => {
|
||||||
|
return new Date('2025-01-10'); // pátek
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getMenuSladovnickaMock = () => {
|
export const getMenuSladovnickaMock = () => {
|
||||||
@ -1196,6 +1289,10 @@ export const getMenuTechTowerMock = () => {
|
|||||||
return MOCK_DATA['techTower'];
|
return MOCK_DATA['techTower'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getMenuZastavkaUmichalaMock = () => {
|
||||||
|
return MOCK_DATA['zastavkaUmichala'];
|
||||||
|
}
|
||||||
|
|
||||||
export const getPizzaListMock = () => {
|
export const getPizzaListMock = () => {
|
||||||
return MOCK_PIZZA_LIST;
|
return MOCK_PIZZA_LIST;
|
||||||
}
|
}
|
@ -1,7 +1,8 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { load } from 'cheerio';
|
import { load } from 'cheerio';
|
||||||
import { Food } from "../../types";
|
import { Food } from "../../types";
|
||||||
import { getMenuSladovnickaMock, getMenuTechTowerMock, getMenuUMotlikuMock } from "./mock";
|
import {getMenuSladovnickaMock, getMenuTechTowerMock, getMenuUMotlikuMock, getMenuZastavkaUmichalaMock} from "./mock";
|
||||||
|
import {formatDate, getDayOfWeekIndex, getIsWeekend} from "./utils";
|
||||||
|
|
||||||
// Fráze v názvech jídel, které naznačují že se jedná o polévku
|
// Fráze v názvech jídel, které naznačují že se jedná o polévku
|
||||||
const SOUP_NAMES = [
|
const SOUP_NAMES = [
|
||||||
@ -25,6 +26,8 @@ const DAYS_IN_WEEK = ['pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', '
|
|||||||
const SLADOVNICKA_URL = 'https://sladovnicka.unasplzenchutna.cz/cz/denni-nabidka';
|
const SLADOVNICKA_URL = 'https://sladovnicka.unasplzenchutna.cz/cz/denni-nabidka';
|
||||||
const U_MOTLIKU_URL = 'https://www.umotliku.cz/menu';
|
const U_MOTLIKU_URL = 'https://www.umotliku.cz/menu';
|
||||||
const TECHTOWER_URL = 'https://www.equifarm.cz/restaurace-techtower';
|
const TECHTOWER_URL = 'https://www.equifarm.cz/restaurace-techtower';
|
||||||
|
const ZASTAVKAUMICHALA_URL = 'https://www.zastavkaumichala.cz';
|
||||||
|
const SENKSERIKOVA_URL = 'https://www.menicka.cz/6561-pivovarsky-senk-serikova.html';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vrátí true, pokud předaný text obsahuje některé ze slov, které naznačuje, že se jedná o polévku.
|
* Vrátí true, pokud předaný text obsahuje některé ze slov, které naznačuje, že se jedná o polévku.
|
||||||
@ -327,3 +330,53 @@ export const getMenuTechTower = async (firstDayOfWeek: Date, mock: boolean = fal
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Získá obědovou nabídku ZastavkaUmichala pro jeden týden.
|
||||||
|
*
|
||||||
|
* @param firstDayOfWeek první den v týdnu, pro který získat menu
|
||||||
|
* @param mock zda vrátit mock data
|
||||||
|
* @returns seznam jídel pro dané datum
|
||||||
|
*/
|
||||||
|
export const getMenuZastavkaUmichala = async (firstDayOfWeek: Date, mock: boolean = false): Promise<Food[][]> => {
|
||||||
|
if (mock) {
|
||||||
|
return getMenuZastavkaUmichalaMock();
|
||||||
|
}
|
||||||
|
|
||||||
|
const nowDate = new Date().getDate();
|
||||||
|
const result: Food[][] = [];
|
||||||
|
for (let dayIndex = 0; dayIndex < 5; dayIndex++) {
|
||||||
|
const currentDate = new Date(firstDayOfWeek);
|
||||||
|
currentDate.setDate(firstDayOfWeek.getDate() + dayIndex);
|
||||||
|
|
||||||
|
// if (currentDate < now) {
|
||||||
|
if (currentDate.getDate() !== nowDate) {
|
||||||
|
result[dayIndex] = [{
|
||||||
|
amount: undefined,
|
||||||
|
name: "Pro tento den není uveřejněna nabídka jídel",
|
||||||
|
price: "",
|
||||||
|
isSoup: false,
|
||||||
|
}];
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
// let dateString = formatDate(currentDate, 'DD.MM.YYYY');
|
||||||
|
// const html = await getHtml(ZASTAVKAUMICHALA_URL + '/?do=dailyMenu-changeDate&dailyMenu-dateString=' + dateString);
|
||||||
|
const html = await getHtml(ZASTAVKAUMICHALA_URL);
|
||||||
|
const $ = load(html);
|
||||||
|
|
||||||
|
// const row = $($('.foodsList li')[0]).text();
|
||||||
|
|
||||||
|
const currentDayFood: Food[] = [];
|
||||||
|
$('.foodsList li').each((index, element) => {
|
||||||
|
currentDayFood.push({
|
||||||
|
amount: '-',
|
||||||
|
name: sanitizeText($(element).contents().not('span').text()),
|
||||||
|
price: sanitizeText($(element).find('span').text()),
|
||||||
|
isSoup: (index === 0),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
result[dayIndex] = currentDayFood;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { InsufficientPermissions, formatDate, getDayOfWeekIndex, getFirstWorkDayOfWeek, getHumanDate, getIsWeekend, getWeekNumber } from "./utils";
|
import { InsufficientPermissions, formatDate, getDayOfWeekIndex, getFirstWorkDayOfWeek, getHumanDate, getIsWeekend, getWeekNumber } from "./utils";
|
||||||
import { ClientData, Restaurants, DayMenu, DepartureTime, DayData, WeekMenu, LocationKey } from "../../types";
|
import { ClientData, Restaurants, DayMenu, DepartureTime, DayData, WeekMenu, LocationKey } from "../../types";
|
||||||
import getStorage from "./storage";
|
import getStorage from "./storage";
|
||||||
import { getMenuSladovnicka, getMenuTechTower, getMenuUMotliku } from "./restaurants";
|
import { getMenuSladovnicka, getMenuTechTower, getMenuUMotliku, getMenuZastavkaUmichala } from "./restaurants";
|
||||||
import { getTodayMock } from "./mock";
|
import { getTodayMock } from "./mock";
|
||||||
|
|
||||||
const storage = getStorage();
|
const storage = getStorage();
|
||||||
@ -10,7 +10,7 @@ const MENU_PREFIX = 'menu';
|
|||||||
/** Vrátí dnešní datum, případně fiktivní datum pro účely vývoje a testování. */
|
/** Vrátí dnešní datum, případně fiktivní datum pro účely vývoje a testování. */
|
||||||
export function getToday(): Date {
|
export function getToday(): Date {
|
||||||
if (process.env.MOCK_DATA === 'true') {
|
if (process.env.MOCK_DATA === 'true') {
|
||||||
return new Date(getTodayMock());
|
return getTodayMock();
|
||||||
}
|
}
|
||||||
return new Date();
|
return new Date();
|
||||||
}
|
}
|
||||||
@ -61,6 +61,7 @@ export async function getData(date?: Date): Promise<ClientData> {
|
|||||||
[Restaurants.SLADOVNICKA]: await getRestaurantMenu(Restaurants.SLADOVNICKA, date),
|
[Restaurants.SLADOVNICKA]: await getRestaurantMenu(Restaurants.SLADOVNICKA, date),
|
||||||
// [Restaurants.UMOTLIKU]: await getRestaurantMenu(Restaurants.UMOTLIKU, date),
|
// [Restaurants.UMOTLIKU]: await getRestaurantMenu(Restaurants.UMOTLIKU, date),
|
||||||
[Restaurants.TECHTOWER]: await getRestaurantMenu(Restaurants.TECHTOWER, date),
|
[Restaurants.TECHTOWER]: await getRestaurantMenu(Restaurants.TECHTOWER, date),
|
||||||
|
[Restaurants.ZASTAVKAUMICHALA]: await getRestaurantMenu(Restaurants.ZASTAVKAUMICHALA, date),
|
||||||
}
|
}
|
||||||
clientData = await addVolatileData(clientData);
|
clientData = await addVolatileData(clientData);
|
||||||
return clientData;
|
return clientData;
|
||||||
@ -168,6 +169,19 @@ export async function getRestaurantMenu(restaurant: Restaurants, date?: Date): P
|
|||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error("Selhalo načtení jídel pro podnik TechTower", e);
|
console.error("Selhalo načtení jídel pro podnik TechTower", e);
|
||||||
}
|
}
|
||||||
|
case Restaurants.ZASTAVKAUMICHALA:
|
||||||
|
try {
|
||||||
|
const zastavkaUmichalaFood = await getMenuZastavkaUmichala(firstDay, mock);
|
||||||
|
for (let i = 0; i < zastavkaUmichalaFood.length; i++) {
|
||||||
|
menus[i][restaurant]!.food = zastavkaUmichalaFood[i];
|
||||||
|
if (zastavkaUmichalaFood[i]?.length === 1 && zastavkaUmichalaFood[i][0].name === 'Pro tento den není uveřejněna nabídka jídel.') {
|
||||||
|
menus[i][restaurant]!.closed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error("Selhalo načtení jídel pro podnik Zastávka u Michala", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await storage.setData(getMenuKey(usedDate), menus);
|
await storage.setData(getMenuKey(usedDate), menus);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import { Choices, LocationKey } from "../../types";
|
import { Choices, LocationKey } from "../../types";
|
||||||
|
|
||||||
/** Vrátí datum v ISO formátu. */
|
/** Vrátí datum v ISO formátu. */
|
||||||
export function formatDate(date: Date) {
|
export function formatDate(date: Date, format?: string) {
|
||||||
let currentDay = String(date.getDate()).padStart(2, '0');
|
let day = String(date.getDate()).padStart(2, '0');
|
||||||
let currentMonth = String(date.getMonth() + 1).padStart(2, "0");
|
let month = String(date.getMonth() + 1).padStart(2, "0");
|
||||||
let currentYear = date.getFullYear();
|
let year = String(date.getFullYear());
|
||||||
return `${currentYear}-${currentMonth}-${currentDay}`;
|
|
||||||
|
const f = (format === undefined) ? 'YYYY-MM-DD' : format;
|
||||||
|
return f.replace('DD', day).replace('MM', month).replace('YYYY', year);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Vrátí human-readable reprezentaci předaného data pro zobrazení. */
|
/** Vrátí human-readable reprezentaci předaného data pro zobrazení. */
|
||||||
|
@ -3,6 +3,7 @@ export enum Restaurants {
|
|||||||
SLADOVNICKA = 'sladovnicka',
|
SLADOVNICKA = 'sladovnicka',
|
||||||
// UMOTLIKU = 'uMotliku',
|
// UMOTLIKU = 'uMotliku',
|
||||||
TECHTOWER = 'techTower',
|
TECHTOWER = 'techTower',
|
||||||
|
ZASTAVKAUMICHALA = 'zastavkaUmichala',
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FoodChoices = {
|
export type FoodChoices = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user