Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/businesses #145

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ yarn-error.log*

.DS_Store

*.old*
*.old*
MOCK_DATA*
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/site.webmanifest" />

<link rel="preload" href="/images/btn_back.png" as="image" type="image/png">
<link rel="preload" href="/images/btn_back.webp" as="image" type="image/png">

<link rel="prefetch" href="/images/learnAndEarn/chest-half.png" as="image" type="image/png">
<link rel="prefetch" href="/images/learnAndEarn/chest-opened.png" as="image" type="image/png">
<link rel="prefetch" href="/images/learnAndEarn/coin.png" as="image" type="image/png">

<link rel="prefetch" href="/images/seeBusinesses/banner-btn-beige.webp" as="image" type="image/webp">
<link rel="prefetch" href="/images/seeBusinesses/banner-btn-brown.webp" as="image" type="image/webp">
<link rel="prefetch" href="/images/seeBusinesses/banner-btn-hover.webp" as="image" type="image/webp">

<title>$4YT @building-u.com</title>
</head>
<body>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.0.0",
"private": true,
"author": "David Bishop",
"contributors": ["David Bishop"],
"contributors": ["David Bishop", "Koki Vasileski"],
"description": "This is the special event/'game' front-end for Building-u, which is called Dollars for Your Thoughts ($4YT).",
"repository": {
"type": "git",
Expand All @@ -20,8 +20,8 @@
},
"dependencies": {
"nanoid": "^5.0.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^18",
"react-dom": "^18",
"react-redux": "^8.1.2",
"react-router-dom": "^6.15.0",
"redux": "4.2.1",
Expand Down
Binary file removed public/images/btn_back.png
Binary file not shown.
Binary file added public/images/btn_back.webp
Binary file not shown.
File renamed without changes
File renamed without changes
Binary file removed public/images/coins_variant1.png
Binary file not shown.
Binary file added public/images/coins_variant1.webp
Binary file not shown.
Binary file removed public/images/coins_variant2.png
Binary file not shown.
Binary file added public/images/coins_variant2.webp
Binary file not shown.
Binary file removed public/images/coins_variant3.png
Binary file not shown.
Binary file added public/images/coins_variant3.webp
Binary file not shown.
Binary file removed public/images/coins_variant4.png
Binary file not shown.
Binary file added public/images/coins_variant4.webp
Binary file not shown.
Binary file added public/images/error-logo.webp
Binary file not shown.
Binary file added public/images/eventResults/btn_next.webp
Binary file not shown.
Binary file removed public/images/feather.png
Binary file not shown.
Binary file added public/images/feather.webp
Binary file not shown.
Binary file added public/images/seeBusinesses/banner-btn-beige.webp
Binary file not shown.
Binary file added public/images/seeBusinesses/banner-btn-brown.webp
Binary file not shown.
Binary file added public/images/seeBusinesses/banner-btn-hover.webp
Binary file not shown.
8 changes: 4 additions & 4 deletions src/components/forms/cooldownIndicator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";

import s from "./styles.module.css";

interface Props {
disabledButton: boolean;
setDisabled: React.Dispatch<React.SetStateAction<boolean>>;
disabledButton: boolean;
cooldownTime?: string;
}

const CooldownIndicator: React.FC<Props> = ({
setDisabled,
cooldownTime,
disabledButton,
cooldownTime
}) => {
const [timeRemaining, setTimeRemaining] = useState<number | null>(0);
const submittedTime = new Date(cooldownTime!).getTime();
Expand All @@ -36,7 +36,7 @@ const CooldownIndicator: React.FC<Props> = ({
}, 1000);

return () => clearInterval(timerInterval);
}, [cooldownTime, setDisabled, disabledButton, submittedOffset]);
}, []);

return (
<time className={s.cooldownContainer}>
Expand Down
71 changes: 9 additions & 62 deletions src/components/forms/user/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { useSearchParams, Link } from "react-router-dom";
import { connect } from "react-redux";

import { registerPlayer, updateProfile } from "@actions/user";
import { getCountries, getRegions, getCities } from "@actions/formOptions";
import { getCountries, getRegions } from "@actions/formOptions";
import { addNotification } from "@actions/notifications";
import { SET_REGIONS, SET_CITIES } from "@actions/index";
import { SET_REGIONS } from "@actions/index";

import updateField from "@utils/forms/updateField";
import checkValidity from "@utils/forms/checkValidity";
Expand All @@ -28,8 +28,6 @@ interface Props {
getCountries: () => Promise<void>;
getRegions: (countryName: number) => Promise<void>;
resetRegions: (setCurrentData: React.Dispatch<React.SetStateAction<UserFormData>>) => void;
getCities: (regionName: number) => Promise<void>;
resetCities: (setCurrentData: React.Dispatch<React.SetStateAction<UserFormData>>) => void;
user: UserReduxState;
registerPlayer: (
userData: UserFormData,
Expand Down Expand Up @@ -69,8 +67,6 @@ const UserForm: React.FC<Props> = ({
getCountries,
getRegions,
resetRegions,
getCities,
resetCities,
user,
registerPlayer,
updateProfile,
Expand Down Expand Up @@ -102,17 +98,9 @@ const UserForm: React.FC<Props> = ({
if (currentData.country) {
getRegions(currentData.country);
if (currentData.region) resetRegions(setCurrentData);
if (currentData.city) resetCities(setCurrentData);
}
}, [currentData.country]);

useEffect(() => {
if (currentData.region) {
getCities(currentData.region);
if (currentData.city) resetCities(setCurrentData);
}
}, [currentData.region]);

const submit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();

Expand Down Expand Up @@ -419,52 +407,17 @@ const UserForm: React.FC<Props> = ({
</div>
</span>

<div
role="presentation"
{...(user.tokens.access &&
typeof formOptions.regions === "string" && {
className: s.notFoundMsg
})}
>
<div role="presentation">
<label htmlFor="city">City</label>
<Select
aria-live="polite"
aria-busy={formOptions.cities.length === 0}
<Input
id="city"
name="city"
type="text"
onChange={(e) => updateField<UserFormData>(e, setCurrentData)}
disabled={
!currentData.region ||
formOptions.cities.length === 0 ||
typeof formOptions.regions === "string" ||
typeof formOptions.cities === "string" ||
form.processing
}
disabled={!currentData.region || form.processing}
{...(currentData.city && { value: currentData.city })}
>
<option value="">- Select -</option>
{formOptions.cities &&
typeof formOptions.cities !== "string" &&
formOptions.cities.map((city, index) => {
return (
<option key={index} value={city.name}>
{city.name}
</option>
);
})}
</Select>
{formOptions.cities.length === 0 &&
currentData.region &&
currentData.region !== user.credentials?.region && (
<Spinner />
)}
{typeof formOptions.regions === "string" ? (
<small className={s.notFoundMsg}>{formOptions.regions}</small>
) : (
typeof formOptions.cities === "string" && (
<small className={s.notFoundMsg}>{formOptions.cities}</small>
)
)}
autoComplete="off"
/>
</div>

<div>
Expand Down Expand Up @@ -508,8 +461,6 @@ const mapDispatchToProps = (dispatch: Dispatch<any>) => ({
getCountries: () => dispatch(getCountries() as unknown) as Promise<void>,
getRegions: (countryName: number) =>
dispatch(getRegions(countryName) as unknown) as Promise<void>,
getCities: (regionName: number) =>
dispatch(getCities(regionName) as unknown) as Promise<void>,
registerPlayer: (
userData: UserFormData,
formRef: React.RefObject<HTMLFormElement>,
Expand All @@ -536,11 +487,7 @@ const mapDispatchToProps = (dispatch: Dispatch<any>) => ({
resetRegions: (setCurrentData: React.Dispatch<React.SetStateAction<UserFormData>>) => {
setCurrentData((prev) => ({ ...prev, region: null }));
dispatch({ type: SET_REGIONS, payload: [] });
},
resetCities: (setCurrentData: React.Dispatch<React.SetStateAction<UserFormData>>) => {
setCurrentData((prev) => ({ ...prev, city: null }));
dispatch({ type: SET_CITIES, payload: [] });
},
}
});

export default connect(mapStateToProps, mapDispatchToProps)(UserForm);
59 changes: 5 additions & 54 deletions src/components/forms/user/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@
.form span:nth-of-type(3) > div small.notFoundMsg {
left: 70px;
}
.form > div:nth-of-type(3) small.notFoundMsg {
left: 97px;
}
.form div input[aria-invalid="true"] + small,
.form {
left: 0;
Expand All @@ -111,11 +108,11 @@
.form[id="registerForm"] span:nth-of-type(2) div:last-child label {
margin-right: calc(0.5rem + 0.5ch);
}
.form[id="registerForm"] > div:nth-of-type(3) select {
.form[id="registerForm"] > div:nth-of-type(3) input {
max-width: 264.883px;
}
@media screen and (max-width: 644px) {
.form[id="registerForm"] > div:nth-of-type(3) select {
.form[id="registerForm"] > div:nth-of-type(3) input {
max-width: 254.883px;
}
}
Expand All @@ -126,46 +123,11 @@
margin-right: 1rem;
}

.form[id="registerForm"] > div:nth-of-type(3) :global(.spinner) {
left: 315px;
}

@media screen and (min-width: 759px) and (max-width: 788px) {
.form[id="registerForm"] > div:nth-of-type(3) :global(.spinner) {
left: 305px;
}
}
@media screen and (min-width: 735px) and (max-width: 758px) {
.form[id="registerForm"] > div:nth-of-type(3) :global(.spinner) {
left: 295px;
}
}
@media screen and (min-width: 701px) and (max-width: 734px) {
.form[id="registerForm"] > div:nth-of-type(3) :global(.spinner) {
left: 285px;
}
}
@media screen and (min-width: 677px) and (max-width: 700px) {
.form[id="registerForm"] > div:nth-of-type(3) :global(.spinner) {
left: 275px;
}
}
@media screen and (min-width: 626px) and (max-width: 676px) {
.form[id="registerForm"] > div:nth-of-type(3) :global(.spinner) {
left: 260px;
}
}

@media screen and (min-width: 626px) {
.form[id="registerForm"] span:nth-of-type(3) div small.notFoundMsg {
bottom: -32px;
}
}
@media screen and (max-width: 419px) {
.form[id="registerForm"] div:nth-of-type(3) small.notFoundMsg {
bottom: -32px;
}
}
@media screen and (max-width: 437px) {
.form[id="registerForm"] span:nth-of-type(3) div small.notFoundMsg {
bottom: -32px;
Expand All @@ -181,7 +143,7 @@
margin-right: unset;
top: unset;
}
.form[id="registerForm"] > div:nth-of-type(3) select {
.form[id="registerForm"] > div:nth-of-type(3) input {
max-width: 100%;
}

Expand All @@ -199,10 +161,6 @@
.form[id="registerForm"] div :global(.spinner) {
top: 39px;
}
.form[id="registerForm"] > div:nth-of-type(3) :global(.spinner) {
right: 29px;
left: auto;
}

.form[id="registerForm"] div input ~ small,
.form[id="registerForm"] div select ~ small,
Expand All @@ -227,14 +185,10 @@
margin-right: calc(0.5rem + 1.3ch);
}

.form[id="userForm"] > div:nth-of-type(3) select {
.form[id="userForm"] > div:nth-of-type(3) input {
max-width: 42.1%;
}

.form[id="userForm"] > div:nth-of-type(3) :global(.spinner) {
left: 43.48%;
}

.form[id="userForm"] div.notFoundMsg {
margin-bottom: 0.5rem;
}
Expand All @@ -243,7 +197,7 @@
.form[id="userForm"] div:not(.form[id="userForm"] > div:last-of-type) {
flex-direction: column;
}
.form[id="userForm"] > div:nth-of-type(3) select {
.form[id="userForm"] > div:nth-of-type(3) input {
max-width: 48.85%;
}

Expand All @@ -255,9 +209,6 @@
.form[id="userForm"] div :global(.spinner) {
top: 39px;
}
.form[id="userForm"] > div:nth-of-type(3) :global(.spinner) {
left: 41.5%;
}
}

@media screen and (min-width: 664px) {
Expand Down
4 changes: 3 additions & 1 deletion src/components/mapNavigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const MapNavigation: React.FC<Props> = ({
const disabled =
!to ||
disableOn?.includes(
gameConfig.gameStart
gameConfig.preGame
? "preGame"
: gameConfig.gameStart
? "gameStart"
: gameConfig.reviewStart
? "reviewStart"
Expand Down
Loading