Základ zobrazování ověřených uživatelů

This commit is contained in:
2023-07-30 23:36:18 +02:00
parent 028186c8ea
commit 8a75c98c9a
6 changed files with 79 additions and 22 deletions

View File

@@ -12,9 +12,9 @@ import SelectSearch, { SelectedOptionValue } from 'react-select-search';
import 'react-select-search/style.css';
import './App.css';
import { SelectSearchOption } from 'react-select-search';
import { faTrashCan } from '@fortawesome/free-regular-svg-icons';
import { faCircleCheck, faTrashCan } from '@fortawesome/free-regular-svg-icons';
import { useBank } from './context/bank';
import { ClientData, Restaurants, Food, Pizza, Order, Locations, PizzaOrder, PizzaDayState } from './types';
import { ClientData, Restaurants, Food, Pizza, Order, Locations, PizzaOrder, PizzaDayState, FoodChoices } from './types';
import Footer from './components/Footer';
@@ -111,7 +111,7 @@ function App() {
} else {
setFoodChoiceList(undefined);
}
}, [choiceRef.current?.value])
}, [choiceRef.current?.value, food])
const doAddChoice = async (event: React.ChangeEvent<HTMLSelectElement>) => {
const index = Object.values(Locations).indexOf(event.target.value as unknown as Locations);
@@ -257,8 +257,13 @@ function App() {
<Alert variant={'primary'}>
Poslední změny:
<ul>
<li>(Trochu) přehlednější zobrazení tabulky</li>
<li>(Trochu) přehlednější zobrazení tabulky
<ul>
<li>Je to pořád ošklivý :(</li>
</ul>
</li>
<li>(Opět) možnost vybrat jen jednu variantu</li>
<li>"Blue checkmark" pro uživatele přihlášené přes AD</li>
</ul>
</Alert>
<h1 className='title'>Dnes je {data.date}</h1>
@@ -300,11 +305,16 @@ function App() {
<td className='p-0'>
<Table>
<tbody>
{locationLoginList.map((entry: [string, number[]], index) => {
{locationLoginList.map((entry: [string, FoodChoices], index) => {
const login = entry[0];
const userChoices = entry[1];
const userPayload = entry[1];
const userChoices = userPayload?.options;
const trusted = userPayload?.trusted || false;
return <tr key={index}>
<td className='text-nowrap'>
{trusted && <span className='trusted-icon'>
<FontAwesomeIcon title='Uživatel ověřený doménovým přihlášením' icon={faCircleCheck} style={{ cursor: "help" }} />
</span>}
{login}
{login === auth.login && <FontAwesomeIcon onClick={() => {
doRemoveChoices(locationKey);
@@ -312,7 +322,7 @@ function App() {
</td>
{userChoices?.length && food ? <td className='w-100'>
<ul>
{userChoices.map(foodIndex => {
{userChoices?.map(foodIndex => {
const locationsKey = Object.keys(Locations)[Number(locationKey)]
const restaurantKey = Object.keys(Restaurants).indexOf(locationsKey);
const restaurant = Object.values(Restaurants)[restaurantKey];