Výběr obědu kliknutím
This commit is contained in:
		
							parent
							
								
									a9fe369abc
								
							
						
					
					
						commit
						52e78d4ea5
					
				@ -190,6 +190,13 @@ function App() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }, [auth?.login, easterEgg?.duration, easterEgg?.url, eggImage]);
 | 
					  }, [auth?.login, easterEgg?.duration, easterEgg?.url, eggImage]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const doAddClickFoodChoice = async (location: Locations, foodIndex: number) => {
 | 
				
			||||||
 | 
					    const locationKey = Object.keys(Locations).find(key => Locations[key as keyof typeof Locations] === location) as LocationKey;
 | 
				
			||||||
 | 
					    if (auth?.login) {
 | 
				
			||||||
 | 
					      await errorHandler(() => addChoice(locationKey, foodIndex, dayIndex));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const doAddChoice = async (event: React.ChangeEvent<HTMLSelectElement>) => {
 | 
					  const doAddChoice = async (event: React.ChangeEvent<HTMLSelectElement>) => {
 | 
				
			||||||
    const locationKey = event.target.value as LocationKey;
 | 
					    const locationKey = event.target.value as LocationKey;
 | 
				
			||||||
    if (auth?.login) {
 | 
					    if (auth?.login) {
 | 
				
			||||||
@ -332,15 +339,15 @@ function App() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const renderFoodTable = (name: string, menu: DayMenu) => {
 | 
					  const renderFoodTable = (name: string, location: Locations, menu: DayMenu) => {
 | 
				
			||||||
    let content;
 | 
					    let content;
 | 
				
			||||||
    if (menu?.closed) {
 | 
					    if (menu?.closed) {
 | 
				
			||||||
      content = <h3>Zavřeno</h3>
 | 
					      content = <h3>Zavřeno</h3>
 | 
				
			||||||
    } else if (menu?.food?.length > 0) {
 | 
					    } else if (menu?.food?.length > 0) {
 | 
				
			||||||
      content = <Table striped bordered hover>
 | 
					      content = <Table striped bordered hover>
 | 
				
			||||||
        <tbody>
 | 
					        <tbody style={{ cursor: 'pointer' }}>
 | 
				
			||||||
          {menu.food.filter(f => (settings?.hideSoups ? !f.isSoup : true)).map((f: any, index: number) =>
 | 
					          {menu.food.filter(f => (settings?.hideSoups ? !f.isSoup : true)).map((f: any, index: number) =>
 | 
				
			||||||
            <tr key={index}>
 | 
					            <tr key={index} onClick={() => doAddClickFoodChoice(location, index)}>
 | 
				
			||||||
              <td>{f.amount}</td>
 | 
					              <td>{f.amount}</td>
 | 
				
			||||||
              <td>{f.name}</td>
 | 
					              <td>{f.name}</td>
 | 
				
			||||||
              <td>{f.price}</td>
 | 
					              <td>{f.price}</td>
 | 
				
			||||||
@ -414,11 +421,11 @@ function App() {
 | 
				
			|||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          <Row className='food-tables'>
 | 
					          <Row className='food-tables'>
 | 
				
			||||||
            {food[Restaurants.SLADOVNICKA] && renderFoodTable('Sladovnická', food[Restaurants.SLADOVNICKA])}
 | 
					            {food[Restaurants.SLADOVNICKA] && renderFoodTable('Sladovnická', Locations.SLADOVNICKA, 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', Locations.TECHTOWER, food[Restaurants.TECHTOWER])}
 | 
				
			||||||
            {food[Restaurants.ZASTAVKAUMICHALA] && renderFoodTable('Zastávka u Michala', food[Restaurants.ZASTAVKAUMICHALA])}
 | 
					            {food[Restaurants.ZASTAVKAUMICHALA] && renderFoodTable('Zastávka u Michala', Locations.ZASTAVKAUMICHALA, food[Restaurants.ZASTAVKAUMICHALA])}
 | 
				
			||||||
            {food[Restaurants.SENKSERIKOVA] && renderFoodTable('Pivovarský šenk Šeříková', food[Restaurants.SENKSERIKOVA])}
 | 
					            {food[Restaurants.SENKSERIKOVA] && renderFoodTable('Pivovarský šenk Šeříková', Locations.SENKSERIKOVA, food[Restaurants.SENKSERIKOVA])}
 | 
				
			||||||
          </Row>
 | 
					          </Row>
 | 
				
			||||||
          <div className='content-wrapper'>
 | 
					          <div className='content-wrapper'>
 | 
				
			||||||
            <div className='content'>
 | 
					            <div className='content'>
 | 
				
			||||||
 | 
				
			|||||||
@ -111,6 +111,7 @@ export type Food = {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO tohle je dost špatné pojmenování, vzhledem k tomu co to obsahuje
 | 
					// TODO tohle je dost špatné pojmenování, vzhledem k tomu co to obsahuje
 | 
				
			||||||
 | 
					// TODO pokud by se použilo ovládáni výběru obědu kliknutím, pak bych restaurace z tohoto výčtu vyhodil
 | 
				
			||||||
export enum Locations {
 | 
					export enum Locations {
 | 
				
			||||||
    SLADOVNICKA = 'Sladovnická',
 | 
					    SLADOVNICKA = 'Sladovnická',
 | 
				
			||||||
    // UMOTLIKU = 'U Motlíků',
 | 
					    // UMOTLIKU = 'U Motlíků',
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user