Skip to content

Commit 2ee7ac1

Browse files
committed
🦫🌭 ↝ [SGV2-14 SGV2-10]: Onboarding test page, update user 'location' field in profiles: requires one or more parameters to run. Use 'profiles help' for instructions, or use the man page. table
1 parent 55b4775 commit 2ee7ac1

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
lines changed

components/Gameplay/Chapter 1/onboarding.tsx

+54-4
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,71 @@ export function PickYourPlanet() {
2525
}
2626
}, [session]);
2727

28+
async function updateUserLocation() {
29+
try {
30+
const { error } = await supabase
31+
.from("profiles")
32+
.update({ location: 3 })
33+
.eq('id', session?.user?.id);
34+
35+
if (error) {
36+
throw error;
37+
}
38+
} catch (error) {
39+
console.error("Error updating your profile's location: ", error.message);
40+
}
41+
};
42+
2843
if (loading) {
29-
return <p>Loading...</p>;
44+
return (
45+
<>
46+
<style jsx global>
47+
{`
48+
body {
49+
background: url('/') center/cover;
50+
background-attachment: fixed;
51+
}
52+
53+
@media only screen and (max-width: 767px) {
54+
.planet-heading {
55+
color: white;
56+
font-size: 24px;
57+
text-align: center;
58+
margin-bottom: 10px;
59+
}
60+
}
61+
`}
62+
</style>
63+
<p>Loading...
64+
65+
</p></>
66+
)
3067
}
3168

3269
if (!session) {
33-
return <p>Please sign in</p>;
70+
return (
71+
<p>Please sign in</p>
72+
)
73+
};
74+
75+
if (!profile) {
76+
return <p>No profile found</p>;
3477
}
3578

36-
if (profile) {
79+
// Checking if profile location is one of the specified values
80+
if ([1, 2, 3, 4, 5, 6].includes(profile.location)) {
3781
return (
3882
<div>
3983
<p>Name: {profile.username}</p>
84+
<p>Location: {profile.location}</p>
4085
</div>
4186
);
4287
};
4388

44-
return <p>No profile found</p>;
89+
return (
90+
<div>
91+
<p>Set your location</p>
92+
<button onClick={updateUserLocation}>Click me!</button>
93+
</div>
94+
);
4595
};

pages/login/register.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Register = () => {
1313
useEffect(() => {
1414
// Check if the user is logged in and then redirect
1515
if (session) {
16-
router.push('/');
16+
router.push('/tests/onboarding');
1717
}
1818
}, [session, router]);
1919

pages/tests/onboarding.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import Layout from "../../components/_Core/Section/Layout";
44
export default function OnboardingTest() {
55

66
return (
7-
<Layout>
7+
<>
88
<style jsx global>
99
{`
1010
body {
11-
background: url('') center/cover;
11+
background: url('/') center/cover;
1212
background-attachment: fixed;
1313
}
1414
@@ -23,6 +23,6 @@ export default function OnboardingTest() {
2323
`}
2424
</style>
2525
<PickYourPlanet />
26-
</Layout>
26+
</>
2727
);
2828
};

0 commit comments

Comments
 (0)