Skip to content

Commit

Permalink
🦫🌭 ↝ [SGV2-14 SGV2-10]: Onboarding test page, update user 'location' …
Browse files Browse the repository at this point in the history
…field in profiles: requires one or more parameters to run. Use 'profiles help' for instructions, or use the man page. table
  • Loading branch information
Gizmotronn committed Apr 23, 2024
1 parent 55b4775 commit 2ee7ac1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
58 changes: 54 additions & 4 deletions components/Gameplay/Chapter 1/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,71 @@ export function PickYourPlanet() {
}
}, [session]);

async function updateUserLocation() {
try {
const { error } = await supabase
.from("profiles")
.update({ location: 3 })
.eq('id', session?.user?.id);

if (error) {
throw error;
}
} catch (error) {
console.error("Error updating your profile's location: ", error.message);
}
};

if (loading) {
return <p>Loading...</p>;
return (
<>
<style jsx global>
{`
body {
background: url('/') center/cover;
background-attachment: fixed;
}
@media only screen and (max-width: 767px) {
.planet-heading {
color: white;
font-size: 24px;
text-align: center;
margin-bottom: 10px;
}
}
`}
</style>
<p>Loading...

</p></>
)
}

if (!session) {
return <p>Please sign in</p>;
return (
<p>Please sign in</p>
)
};

if (!profile) {
return <p>No profile found</p>;
}

if (profile) {
// Checking if profile location is one of the specified values
if ([1, 2, 3, 4, 5, 6].includes(profile.location)) {
return (
<div>
<p>Name: {profile.username}</p>
<p>Location: {profile.location}</p>
</div>
);
};

return <p>No profile found</p>;
return (
<div>
<p>Set your location</p>
<button onClick={updateUserLocation}>Click me!</button>
</div>
);
};
2 changes: 1 addition & 1 deletion pages/login/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Register = () => {
useEffect(() => {
// Check if the user is logged in and then redirect
if (session) {
router.push('/');
router.push('/tests/onboarding');
}
}, [session, router]);

Expand Down
6 changes: 3 additions & 3 deletions pages/tests/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import Layout from "../../components/_Core/Section/Layout";
export default function OnboardingTest() {

return (
<Layout>
<>
<style jsx global>
{`
body {
background: url('') center/cover;
background: url('/') center/cover;
background-attachment: fixed;
}
Expand All @@ -23,6 +23,6 @@ export default function OnboardingTest() {
`}
</style>
<PickYourPlanet />
</Layout>
</>
);
};

0 comments on commit 2ee7ac1

Please sign in to comment.