From 6e09ee0b73ada667bad23d4896bf5d81ffd17938 Mon Sep 17 00:00:00 2001 From: Danny Miller Date: Sun, 12 May 2024 16:10:36 -0400 Subject: [PATCH 1/3] fix google jsonld search issue --- pages/[subdomain]/level/[username]/[slugName].tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/[subdomain]/level/[username]/[slugName].tsx b/pages/[subdomain]/level/[username]/[slugName].tsx index c8249440a..44680cb38 100644 --- a/pages/[subdomain]/level/[username]/[slugName].tsx +++ b/pages/[subdomain]/level/[username]/[slugName].tsx @@ -335,7 +335,7 @@ export default function LevelPage({ _collection, _level, reqUser }: LevelProps) bestRating: 100, worstRating: 0, ratingValue: Math.round(100 * level.calc_reviews_score_laplace), - ratingCount: level.calc_reviews_count, + ratingCount: Math.max(1, level.calc_reviews_count), }} datePublished={level.ts && new Date(level.ts * 1000).toISOString() || ''} From 3e5f3cee2728efd3fe93edfdf5ab112bf71ce6c8 Mon Sep 17 00:00:00 2001 From: Spencer Spenst Date: Mon, 13 May 2024 22:35:24 -0700 Subject: [PATCH 2/3] fixes and tweaks --- components/forms/signupForm.tsx | 6 +- components/home/index.tsx | 6 +- components/home/upsellConvertOrConfirm.tsx | 16 --- components/home/upsellFullAccount.tsx | 18 +++ components/modal/index.tsx | 8 +- components/modal/postGameModal.tsx | 123 +++++++----------- components/settings/settingsAccountGuest.tsx | 2 +- constants/role.ts | 2 +- pages/[subdomain]/chapter1/index.tsx | 4 +- pages/[subdomain]/chapter2/index.tsx | 4 +- pages/[subdomain]/chapter3/index.tsx | 6 +- .../level/[username]/[slugName].tsx | 4 +- pages/[subdomain]/play-as-guest/index.tsx | 26 ++-- pages/[subdomain]/play/index.tsx | 4 +- pages/api/guest-convert/index.ts | 1 - pages/api/signup/index.ts | 2 +- styles/global.css | 11 -- 17 files changed, 98 insertions(+), 145 deletions(-) delete mode 100644 components/home/upsellConvertOrConfirm.tsx create mode 100644 components/home/upsellFullAccount.tsx diff --git a/components/forms/signupForm.tsx b/components/forms/signupForm.tsx index 32496b8ef..435c7ac9a 100644 --- a/components/forms/signupForm.tsx +++ b/components/forms/signupForm.tsx @@ -16,11 +16,11 @@ export default function SignupForm({ recaptchaPublicKey }: SignupFormProps) { const [email, setEmail] = useState(''); const { mutateUser, setShouldAttemptAuth } = useContext(AppContext); const [password, setPassword] = useState(''); - const router = useRouter(); - const [username, setUsername] = useState(''); - const [recaptchaToken, setRecaptchaToken] = useState(''); const recaptchaRef = useRef(null); + const [recaptchaToken, setRecaptchaToken] = useState(''); + const router = useRouter(); const [showRecaptcha, setShowRecaptcha] = useState(false); + const [username, setUsername] = useState(''); function onRecaptchaChange(value: string | null) { if (value) { diff --git a/components/home/index.tsx b/components/home/index.tsx index 85237ff7e..c917701d4 100644 --- a/components/home/index.tsx +++ b/components/home/index.tsx @@ -1,8 +1,6 @@ import StatFilter from '@root/constants/statFilter'; import TourPath from '@root/constants/tourPath'; import getProfileSlug from '@root/helpers/getProfileSlug'; -import isFullAccount from '@root/helpers/isFullAccount'; -import isGuest from '@root/helpers/isGuest'; import { ScreenSize } from '@root/hooks/useDeviceCheck'; import classNames from 'classnames'; import Image from 'next/image'; @@ -23,7 +21,7 @@ import LoadingCard from '../cards/loadingCard'; import FormattedReview from '../level/reviews/formattedReview'; import LoadingSpinner from '../page/loadingSpinner'; import MultiSelectUser from '../page/multiSelectUser'; -import UpsellConvertOrConfirmTopBar from './upsellConvertOrConfirm'; +import UpsellFullAccount from './upsellFullAccount'; interface HomeProps { lastLevelPlayed?: EnrichedLevel; @@ -152,7 +150,7 @@ export default function Home({ return (<> {tour} - +
diff --git a/components/home/upsellConvertOrConfirm.tsx b/components/home/upsellConvertOrConfirm.tsx deleted file mode 100644 index aa4054289..000000000 --- a/components/home/upsellConvertOrConfirm.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import isFullAccount from '@root/helpers/isFullAccount'; -import isGuest from '@root/helpers/isGuest'; -import User from '@root/models/db/user'; -import Link from 'next/link'; -import React from 'react'; - -export default function UpsellConvertOrConfirmTopBar({ user }: {user: User | null}) { - return user && !isFullAccount(user) && (
- {`${isGuest(user) ? 'Convert to a regular account' : 'Confirm your email'} `} - in your - Account Settings - - {' to unlock all basic features!'} -
- ); -} diff --git a/components/home/upsellFullAccount.tsx b/components/home/upsellFullAccount.tsx new file mode 100644 index 000000000..1e9c2de10 --- /dev/null +++ b/components/home/upsellFullAccount.tsx @@ -0,0 +1,18 @@ +import isFullAccount from '@root/helpers/isFullAccount'; +import isGuest from '@root/helpers/isGuest'; +import User from '@root/models/db/user'; +import Link from 'next/link'; +import React from 'react'; + +export default function UpsellFullAccount({ user }: {user: User | null}) { + return (user && !isFullAccount(user) && +
+ + {isGuest(user) ? 'Convert to a regular account' : 'Confirm your email'} + + + {' to unlock all basic features!'} + +
+ ); +} diff --git a/components/modal/index.tsx b/components/modal/index.tsx index a54421dfb..44ea95a42 100644 --- a/components/modal/index.tsx +++ b/components/modal/index.tsx @@ -31,7 +31,7 @@ interface ModalProps { isOpen: boolean; onConfirm?: () => void; onSubmit?: () => void; - title?: React.ReactNode; + title: React.ReactNode; } export default function Modal({ @@ -88,9 +88,9 @@ export default function Modal({ }} > - {title && + - {title} + {title} - } + {children}
{onConfirm ? diff --git a/components/modal/postGameModal.tsx b/components/modal/postGameModal.tsx index e3a0e5375..ac02247c5 100644 --- a/components/modal/postGameModal.tsx +++ b/components/modal/postGameModal.tsx @@ -88,94 +88,59 @@ export default function PostGameModal({ chapter, closeModal, collection, dontSho ); } - const upsellDiv =
- Sign up (or use a Guest Account) to save your progress and get access to more features. -
; - - const guestConvertUpsell = ( -
-
- By the way...You are playing as a guest and missing out on a ton of features. - Convert to regular account - (it's free and only takes a few seconds!) -
-
- ); - return ( + Congratulations! +
+ } > - -
-
-
- Congratulations! +
+ {!reqUser ? +
+ Sign up (or use a Guest Account) to save your progress and get access to more features.
-
- {reqUser && !isGuest(reqUser) && -
- { - // make this element invisible - (e.target as HTMLElement).style.display = 'none'; - }} className='text-xs cursor-pointer italic py-1'>Share your thoughts on {level.name} - -
- - } - -
-
-
- {!reqUser ? - - upsellDiv - : - <> - - {lastLevelInCollection && collection && + : + <> + {lastLevelInCollection && collection &&
{level.name} is the last level in {collection.name}.
- } - {nextActionCard()} - - } -
-
- {isGuest(reqUser) && guestConvertUpsell} -
-
+ } + {nextActionCard()} + {isGuest(reqUser) ? +
+
+ By the way...You are playing as a guest and missing out on a ton of features. Convert to a regular account (it's free and only takes a few seconds!) +
+
+ : +
+ { + // make this element invisible + (e.target as HTMLElement).style.display = 'none'; + }} className='text-xs cursor-pointer italic py-1'>Share your thoughts on {level.name} + +
+ } + + } +
{ @@ -191,7 +156,7 @@ export default function PostGameModal({ chapter, closeModal, collection, dontSho } }} /> - +
diff --git a/components/settings/settingsAccountGuest.tsx b/components/settings/settingsAccountGuest.tsx index 8e7f64de8..400ea2664 100644 --- a/components/settings/settingsAccountGuest.tsx +++ b/components/settings/settingsAccountGuest.tsx @@ -5,8 +5,8 @@ import toast from 'react-hot-toast'; export default function SettingsAccountGuest() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); - const [username, setUsername] = useState(''); const router = useRouter(); + const [username, setUsername] = useState(''); async function fetchSignup() { toast.dismiss(); diff --git a/constants/role.ts b/constants/role.ts index 690348a9c..98515929f 100644 --- a/constants/role.ts +++ b/constants/role.ts @@ -1,8 +1,8 @@ enum Role { ADMIN = 'Admin', CURATOR = 'Curator', - GUEST = 'Guest', FORMER_GUEST = 'FormerGuest', + GUEST = 'Guest', PRO = 'Pro', } diff --git a/pages/[subdomain]/chapter1/index.tsx b/pages/[subdomain]/chapter1/index.tsx index 69569c0c7..145f6c816 100644 --- a/pages/[subdomain]/chapter1/index.tsx +++ b/pages/[subdomain]/chapter1/index.tsx @@ -1,4 +1,4 @@ -import UpsellConvertOrConfirmTopBar from '@root/components/home/upsellConvertOrConfirm'; +import UpsellFullAccount from '@root/components/home/upsellFullAccount'; import { getGameIdFromReq } from '@root/helpers/getGameIdFromReq'; import { GetServerSidePropsContext, NextApiRequest } from 'next'; import Link from 'next/link'; @@ -30,7 +30,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { export default function Chapter1Page({ enrichedCollections, reqUser, solvedLevels, totalLevels }: CampaignProps) { return ( - + - + - + (''); const recaptchaRef = useRef(null); - const recaptchaToken = useRef(null); + const recaptchaToken = useRef(''); const [registrationState, setRegistrationState] = useState('registering'); const router = useRouter(); - const [temporaryPassword, setTemporaryPassword] = useState(''); const [showRecaptcha, setShowRecaptcha] = useState(false); + const [temporaryPassword, setTemporaryPassword] = useState(''); function onRecaptchaChange(value: string | null) { if (value) { @@ -125,16 +125,16 @@ export default function PlayAsGuest({ recaptchaPublicKey }: {recaptchaPublicKey?
  • Your guest account may be deleted after 7 days of no activity
  • By creating a guest account you agree to our terms of service and reviewed the privacy policy
  • - { recaptchaPublicKey && showRecaptcha ? ( + {recaptchaPublicKey && showRecaptcha ? - ) : + : } @@ -143,16 +143,18 @@ export default function PlayAsGuest({ recaptchaPublicKey }: {recaptchaPublicKey?
    ; async function fetchSignup() { - if (recaptchaPublicKey && !showRecaptcha) { - setShowRecaptcha(true); + if (recaptchaPublicKey) { + if (!showRecaptcha) { + setShowRecaptcha(true); - return; - } + return; + } - if (!recaptchaToken.current) { - toast.error('Please complete the recaptcha'); + if (!recaptchaToken.current) { + toast.error('Please complete the recaptcha'); - return; + return; + } } const tutorialCompletedAt = window.localStorage.getItem('tutorialCompletedAt') || '0'; diff --git a/pages/[subdomain]/play/index.tsx b/pages/[subdomain]/play/index.tsx index 183627ed1..ee55e25e0 100644 --- a/pages/[subdomain]/play/index.tsx +++ b/pages/[subdomain]/play/index.tsx @@ -1,4 +1,4 @@ -import UpsellConvertOrConfirmTopBar from '@root/components/home/upsellConvertOrConfirm'; +import UpsellFullAccount from '@root/components/home/upsellFullAccount'; import { AppContext } from '@root/contexts/appContext'; import { getGameFromId, getGameIdFromReq } from '@root/helpers/getGameIdFromReq'; import { GetServerSidePropsContext, NextApiRequest } from 'next'; @@ -41,7 +41,7 @@ export default function PlayPage({ reqUser }: PlayPageProps) { return ( - +
    {game.displayName} Official Campaign diff --git a/pages/api/guest-convert/index.ts b/pages/api/guest-convert/index.ts index 259f4385f..c752c0dd1 100644 --- a/pages/api/guest-convert/index.ts +++ b/pages/api/guest-convert/index.ts @@ -43,7 +43,6 @@ export default withAuth({ user.name = trimmedName; user.password = password; user.roles = user.roles.filter((role: Role) => role !== Role.GUEST); - // add the former guest role user.roles.push(Role.FORMER_GUEST); // check if name already exists diff --git a/pages/api/signup/index.ts b/pages/api/signup/index.ts index fc95fcc6f..4d7fa1807 100644 --- a/pages/api/signup/index.ts +++ b/pages/api/signup/index.ts @@ -68,8 +68,8 @@ export default apiWrapper({ POST: { email: ValidType('string'), name: ValidType('string'), password: ValidType('string'), - tutorialCompletedAt: ValidNumber(false), recaptchaToken: ValidType('string', false), + tutorialCompletedAt: ValidNumber(false), }, } }, async (req: NextApiRequestWrapper, res: NextApiResponse) => { await dbConnect(); diff --git a/styles/global.css b/styles/global.css index ec0d496ba..66cbd927b 100644 --- a/styles/global.css +++ b/styles/global.css @@ -331,7 +331,6 @@ body { } } - .flashBackground { /* flash once */ animation: flashBackground 2s ease-in-out alternate; @@ -397,16 +396,6 @@ body { } } -@keyframes moveUp { - 0% { - transform: translateY(200px); - - } - 100% { - transform: translateY(0); /* Adjust the value based on how far you want it to move */ - } -} - /* nprogress */ /* Make clicks pass-through */ #nprogress { From 5a6caf272c89a3e3b4b5d61607a470e440472e16 Mon Sep 17 00:00:00 2001 From: Spencer Spenst Date: Tue, 14 May 2024 16:50:50 -0700 Subject: [PATCH 3/3] fix byStat StatFilter.Unoptimized bug --- pages/api/search/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/api/search/index.ts b/pages/api/search/index.ts index cc2a6967d..b7913b135 100644 --- a/pages/api/search/index.ts +++ b/pages/api/search/index.ts @@ -446,7 +446,7 @@ export async function doQuery(gameId: GameId, query: SearchQuery, reqUser?: User // eslint-disable-next-line @typescript-eslint/no-explicit-any let statMatchQuery: FilterQuery = {}; - if (query.statFilter === StatFilter.HideSolved) { + if (query.statFilter === StatFilter.HideSolved || query.statFilter === StatFilter.Unoptimized) { statMatchQuery = { complete: false }; } else if (query.statFilter === StatFilter.Solved) { statMatchQuery = { complete: true };