Skip to content

Commit 7e0cf70

Browse files
committed
🪀🌼 ↝ [SGV2-10 SGV2-14 SGV2-2]: Setting up a test to automate 'mission' completion
1 parent 6d1795a commit 7e0cf70

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
2+
import React, { useEffect, useState } from "react";
3+
4+
export function PickYourPlanet() {
5+
const supabase = useSupabaseClient();
6+
const session = useSession();
7+
8+
const [profile, setProfile] = useState<any>(null);
9+
const [loading, setLoading] = useState(true);
10+
11+
useEffect(() => {
12+
if (session?.user?.id) {
13+
supabase
14+
.from("profiles")
15+
.select()
16+
.eq("id", session.user.id)
17+
.then((result) => {
18+
if (result.data && result.data.length > 0) {
19+
setProfile(result.data[0]);
20+
}
21+
setLoading(false);
22+
})
23+
} else {
24+
setLoading(false);
25+
}
26+
}, [session]);
27+
28+
if (loading) {
29+
return <p>Loading...</p>;
30+
}
31+
32+
if (!session) {
33+
return <p>Please sign in</p>;
34+
}
35+
36+
if (profile) {
37+
return (
38+
<div>
39+
<p>Name: {profile.username}</p>
40+
</div>
41+
);
42+
};
43+
44+
return <p>No profile found</p>;
45+
};

components/Gameplay/mission-list.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CardTitle, CardDescription, CardHeader, CardContent, CardFooter, Card } from "../ui/card";
22
import Link from "next/link";
3-
import { Button } from "../ui/button";
3+
import { Button } from "../ui/button";
44

55
export function MissionList() {
66
const missions = [

pages/tests/onboarding.tsx

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { PickYourPlanet } from "../../components/Gameplay/Chapter 1/onboarding";
2+
import Layout from "../../components/_Core/Section/Layout";
3+
4+
export default function OnboardingTest() {
5+
6+
return (
7+
<Layout>
8+
<style jsx global>
9+
{`
10+
body {
11+
background: url('') center/cover;
12+
background-attachment: fixed;
13+
}
14+
15+
@media only screen and (max-width: 767px) {
16+
.planet-heading {
17+
color: white;
18+
font-size: 24px;
19+
text-align: center;
20+
margin-bottom: 10px;
21+
}
22+
}
23+
`}
24+
</style>
25+
<PickYourPlanet />
26+
</Layout>
27+
);
28+
};

0 commit comments

Comments
 (0)