From cd0a5a829d22518e87e97b26d78bdb5edb38843b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Rodrigues?= Date: Sun, 17 Dec 2023 02:39:03 +0000 Subject: [PATCH 1/4] feat: normalize profile mentions --- layout/Attendee/Wheel/Wheel.tsx | 1 - layout/Badge/Badge.tsx | 2 -- .../Leaderboard/components/Table/index.tsx | 19 +++++++++---------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/layout/Attendee/Wheel/Wheel.tsx b/layout/Attendee/Wheel/Wheel.tsx index 56fa88c4..298c130c 100644 --- a/layout/Attendee/Wheel/Wheel.tsx +++ b/layout/Attendee/Wheel/Wheel.tsx @@ -79,7 +79,6 @@ function WheelPage() { .then((response) => updateLatestWins(response.data)) .catch((_) => updateError(true)); }; - useEffect(requestAllInfo, []); const canSpin = () => { diff --git a/layout/Badge/Badge.tsx b/layout/Badge/Badge.tsx index f8868045..6550c659 100644 --- a/layout/Badge/Badge.tsx +++ b/layout/Badge/Badge.tsx @@ -50,8 +50,6 @@ const BadgeSlug: React.FC = () => { .catch((_) => router.replace("/404")); }, [slug]); - console.log(badge); - return ( (
{id + 1}
- {entry.name} + {entry.name}
{entry.badges}
@@ -57,6 +55,7 @@ export default function Table({ list, user, maxUsersToShow }) {
); + return (
From 3470373cb040641059502d32b7410943f175aa7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Rodrigues?= Date: Sat, 23 Dec 2023 18:35:54 +0000 Subject: [PATCH 2/4] chore: implement suggestions --- layout/Attendee/Wheel/Wheel.tsx | 3 ++- .../Wheel/components/ListItem3Cols/index.tsx | 9 +++++++-- layout/Attendees/Attendees.tsx | 5 ++--- layout/Staff/Identifier/Identifier.tsx | 4 ++-- .../Leaderboard/components/Table/index.tsx | 16 +++++++++------- lib/api.js | 18 ++++++++++++++++-- 6 files changed, 38 insertions(+), 17 deletions(-) diff --git a/layout/Attendee/Wheel/Wheel.tsx b/layout/Attendee/Wheel/Wheel.tsx index 298c130c..7a8c9895 100644 --- a/layout/Attendee/Wheel/Wheel.tsx +++ b/layout/Attendee/Wheel/Wheel.tsx @@ -175,7 +175,8 @@ function WheelPage() { const latestWinsComponents = latestWins.map((entry, id) => (
-

{user}

+ +

{user_name}

+
diff --git a/layout/Attendees/Attendees.tsx b/layout/Attendees/Attendees.tsx index 8d765867..a5e7add6 100644 --- a/layout/Attendees/Attendees.tsx +++ b/layout/Attendees/Attendees.tsx @@ -7,7 +7,7 @@ import BadgeFilter from "@components/BadgeFilter"; import Layout from "@components/Layout"; import Heading from "@components/Heading"; -import { getAttendee, isAttendeeRegistered } from "@lib/api"; +import { getAttendeeByUsername, isAttendeeRegistered } from "@lib/api"; function Profile() { const [attendee, updateAttendee] = useState(null); @@ -17,7 +17,7 @@ function Profile() { const [filter, updateFilter] = useState(null); useEffect(() => { - getAttendee(uuid) + getAttendeeByUsername(uuid) .then((response) => { updateAttendee(response.data); }) @@ -25,7 +25,6 @@ function Profile() { router.replace("/404"); }); }, []); - if (!attendee) return null; return ( { - getAttendee(uuid) + getAttendeeByID(uuid) .then((response) => { setText(`${response.data.name} | ${response.data.email}`); setFeedback(FEEDBACK.SUCCESS); diff --git a/layout/shared/Leaderboard/components/Table/index.tsx b/layout/shared/Leaderboard/components/Table/index.tsx index b23087c0..29ef8f17 100644 --- a/layout/shared/Leaderboard/components/Table/index.tsx +++ b/layout/shared/Leaderboard/components/Table/index.tsx @@ -6,20 +6,23 @@ export default function Table({ list, user, maxUsersToShow }) { const rows = toShow.map((entry, id) => (
{id + 1}
{entry.name}
{entry.badges}
@@ -55,7 +58,6 @@ export default function Table({ list, user, maxUsersToShow }) {
); - return (
diff --git a/lib/api.js b/lib/api.js index 000d9102..f3239add 100644 --- a/lib/api.js +++ b/lib/api.js @@ -137,8 +137,22 @@ export async function sendResetEmail({ email }) { return response.data; } -export async function getAttendee(id) { - const response = await API.get(`/api/attendees/${id}`); +export async function getAttendeeByID(id) { + const response = await API.get(`/api/attendees/${id}`, { + params: { + id, + }, + }); + + return response.data; +} + +export async function getAttendeeByUsername(username) { + const response = await API.get(`/api/attendees/${username}`, { + params: { + username, + }, + }); return response.data; } From 2d613953e78ee2cba89d463bb006dbb1525f3334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Rodrigues?= Date: Thu, 11 Jan 2024 02:26:43 +0000 Subject: [PATCH 3/4] fix: qr reader --- layout/Attendees/Attendees.tsx | 35 +++++++++++++++++++++++++--------- lib/api.js | 7 +++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/layout/Attendees/Attendees.tsx b/layout/Attendees/Attendees.tsx index a5e7add6..63992f11 100644 --- a/layout/Attendees/Attendees.tsx +++ b/layout/Attendees/Attendees.tsx @@ -7,7 +7,8 @@ import BadgeFilter from "@components/BadgeFilter"; import Layout from "@components/Layout"; import Heading from "@components/Heading"; -import { getAttendeeByUsername, isAttendeeRegistered } from "@lib/api"; +import { getAttendeeByID, getAttendeeByUsername, isAttendeeRegistered } from "@lib/api"; +import { get } from "http"; function Profile() { const [attendee, updateAttendee] = useState(null); @@ -16,15 +17,31 @@ function Profile() { const { uuid } = router.query; const [filter, updateFilter] = useState(null); - useEffect(() => { - getAttendeeByUsername(uuid) - .then((response) => { - updateAttendee(response.data); - }) - .catch((error) => { + +useEffect(() => { + const fetchData = async () => { + try { + const response = await getAttendeeByID(uuid); + updateAttendee(response.data); + } catch (error) { + if (error.response && error.response.status === 400) { + try { + const response = await getAttendeeByUsername(uuid); + updateAttendee(response.data); + } catch (usernameError) { + router.replace("/404"); + } + } else { router.replace("/404"); - }); - }, []); + } + } + }; + + fetchData(); +}, [uuid, router, updateAttendee]); + + + if (!attendee) return null; return ( Date: Tue, 16 Jan 2024 17:27:57 +0000 Subject: [PATCH 4/4] fix: remove includes --- layout/Attendees/Attendees.tsx | 40 +++++++++++++++------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/layout/Attendees/Attendees.tsx b/layout/Attendees/Attendees.tsx index 63992f11..ad635637 100644 --- a/layout/Attendees/Attendees.tsx +++ b/layout/Attendees/Attendees.tsx @@ -7,8 +7,7 @@ import BadgeFilter from "@components/BadgeFilter"; import Layout from "@components/Layout"; import Heading from "@components/Heading"; -import { getAttendeeByID, getAttendeeByUsername, isAttendeeRegistered } from "@lib/api"; -import { get } from "http"; +import { getAttendeeByID, getAttendeeByUsername } from "@lib/api"; function Profile() { const [attendee, updateAttendee] = useState(null); @@ -17,30 +16,27 @@ function Profile() { const { uuid } = router.query; const [filter, updateFilter] = useState(null); - -useEffect(() => { - const fetchData = async () => { - try { - const response = await getAttendeeByID(uuid); - updateAttendee(response.data); - } catch (error) { - if (error.response && error.response.status === 400) { - try { - const response = await getAttendeeByUsername(uuid); - updateAttendee(response.data); - } catch (usernameError) { + useEffect(() => { + const fetchData = async () => { + try { + const response = await getAttendeeByID(uuid); + updateAttendee(response.data); + } catch (error) { + if (error.response && error.response.status === 400) { + try { + const response = await getAttendeeByUsername(uuid); + updateAttendee(response.data); + } catch (usernameError) { + router.replace("/404"); + } + } else { router.replace("/404"); } - } else { - router.replace("/404"); } - } - }; - - fetchData(); -}, [uuid, router, updateAttendee]); - + }; + fetchData(); + }, [uuid, router, updateAttendee]); if (!attendee) return null; return (