reorganising files

This commit is contained in:
Antoine M 2024-02-13 19:26:36 +01:00
parent 79a5a213d6
commit c9f869f09b
3 changed files with 0 additions and 99 deletions

View File

@ -1,45 +0,0 @@
import { useState } from "react";
import { v4 as uuidv4 } from "uuid";
import { useWordpressCustomData } from "../hooks/WordpressFetchData.js";
import { useUserContext } from "../hooks/useUserContext.jsx";
export default function CountrySelect() {
const availableCountries = useWordpressCustomData("/available-countries");
const { country, changeCountry } = useUserContext();
const [isSubmenuOpen, setIsSubmenuOpen] = useState(false);
if (!availableCountries || !country) return <div className='country-select'>Loading...</div>;
function handleChangeCountry(key, value) {
changeCountry({ name: value, iso: key });
handleShowHideSubmenu();
}
function handleShowHideSubmenu() {
setIsSubmenuOpen(!isSubmenuOpen);
}
const countryOptions = Object.keys(availableCountries).map((key, value) => (
<li
key={uuidv4()}
className='country-select__option'
onClick={() => handleChangeCountry(key, availableCountries[key])}>
<img className='flag' src={`https://flagsapi.com/${key}/flat/32.png`} alt='' />
{availableCountries[key]}
</li>
));
if (!countryOptions) return;
return (
<div className='country-select'>
<button className='country-select__toggle' onClick={handleShowHideSubmenu}>
<img className='flag' src={`https://flagsapi.com/${country.iso}/flat/32.png`} alt='' />
{country.name}
</button>
<ul className='country-select__country-list' aria-hidden={!isSubmenuOpen}>
{countryOptions}
</ul>
</div>
);
}

View File

@ -1,19 +0,0 @@
import { NavLink } from "react-router-dom";
import { useLocation } from "react-router-dom";
import { useUserContext } from "../hooks/useUserContext";
export default function Menu() {
let location = useLocation();
const { language, changeLanguage } = useUserContext();
return (
<nav className='main-menu'>
<ul className='navlist'>
<NavLink to='/'>Home</NavLink>
<NavLink to='/select-profile'>Profile</NavLink>
<NavLink to='/play'>Play</NavLink>
<NavLink to='/results'>Results</NavLink>
</ul>
<button onClick={changeLanguage}>{language}</button>
</nav>
);
}

View File

@ -1,35 +0,0 @@
import React, { useState } from "react";
import { v4 as uuidv4 } from "uuid";
import { useUserContext } from "../hooks/useUserContext";
export default function CountrySelect({ options }) {
const [isSubmenuOpen, setIsSubmenuOpen] = useState(false);
const { profile, changeProfile } = useUserContext();
function handleShowHideSubmenu() {
setIsSubmenuOpen(!isSubmenuOpen);
}
function handleChangeProfile() {
changeProfile("subcontractor_employee");
}
if (!profile) return <div className='profile-select dropdown-select'> Loading...</div>;
const selectOptions = Object.keys(options).map((key) => (
<li key={uuidv4()} className='dropdown-select__option' onClick={() => handleChangeProfile()}>
{options[key]}
</li>
));
return (
<div className='profile-select dropdown-select'>
<button className='dropdown-select__toggle' onClick={handleShowHideSubmenu}>
{profile}
</button>
<ul className='dropdown-select__select-list' aria-hidden={!isSubmenuOpen}>
{selectOptions}
</ul>
</div>
);
}