-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧶🎄 ↝ Testing build with journal components
- Loading branch information
1 parent
0ed59d1
commit 744a0d6
Showing
6 changed files
with
1,175 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { NextPage } from "next"; | ||
import { useRouter } from "next/router"; | ||
import { Card, Text, NextUIProvider } from "@nextui-org/react"; | ||
import { Box } from "./Box"; | ||
import JournalNavbarComponent from "./JournalNavbar"; | ||
|
||
import { useSession } from "@supabase/auth-helpers-react"; | ||
|
||
interface Props { article: any }; | ||
|
||
const JournalArticleCard: NextPage<Props> = ( props ) => { | ||
const router = useRouter(); | ||
const { article } = props; | ||
|
||
/* function getDate() { | ||
let time = Date.parse(article.inserted_at) | ||
} */ | ||
|
||
return ( | ||
<NextUIProvider> | ||
<Card | ||
isPressable | ||
css = {{ mb: "$10" }} | ||
onPress={() => router.push("/journal/Article?id=" + article.id)} | ||
> | ||
<Card.Body> | ||
<Text h2>{article.title}</Text> | ||
{/*<Text b>posted {getDate()}</Text>*/} | ||
<Text b>By {article.user_id.toLowerCase()}</Text> | ||
</Card.Body> | ||
</Card> | ||
</NextUIProvider> | ||
) | ||
} | ||
|
||
export default JournalArticleCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { styled } from "@nextui-org/react"; | ||
|
||
export const Box = styled("div", { | ||
boxSizing: "border-box" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useRouter } from "next/router"; | ||
import Link from "next/link"; | ||
import { Navbar, Button, Text } from "@nextui-org/react"; | ||
|
||
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; | ||
|
||
const JournalNavbarComponent = () => { | ||
const supabaseClient = useSupabaseClient(); | ||
const session = useSession(); | ||
const router = useRouter(); | ||
|
||
function signOutUser() { | ||
supabaseClient.auth.signOut(); | ||
router.push("/"); // localhost:3000 | ||
} | ||
|
||
return ( | ||
<Navbar isBordered isCompact> | ||
<Navbar.Brand as={Link} href="/"> | ||
ShareArticles | ||
</Navbar.Brand> | ||
<Navbar.Content hideIn="xs" variant="highlight-rounded"> | ||
<Navbar.Link href="/journal/">Main Feed</Navbar.Link> | ||
<Navbar.Link href="/journal/createArticle">Create Article</Navbar.Link> | ||
</Navbar.Content> | ||
|
||
<Navbar.Content> | ||
{!session?.user ? /*User doesnt exist*/ | ||
<> | ||
<Navbar.Link href="/login"> | ||
<Button auto flat> | ||
Login | ||
</Button> | ||
</Navbar.Link> | ||
</> | ||
: /* User does exist */ | ||
<> | ||
<Navbar.Item> | ||
<Text>Hey, {session?.user?.email}</Text> | ||
</Navbar.Item> | ||
<Navbar.Item> | ||
<Button auto flat onPress={() => signOutUser()}> | ||
Sign Out | ||
</Button> | ||
</Navbar.Item> | ||
</> | ||
} | ||
</Navbar.Content> | ||
</Navbar> | ||
) | ||
} | ||
|
||
export default JournalNavbarComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type { NextPage } from "next"; | ||
import { useRouter } from "next/router"; | ||
import { useState, useEffect } from "react"; | ||
import { Text, NextUIProvider } from '@nextui-org/react'; | ||
|
||
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; | ||
import JournalArticleCard from "../../components/Journal/ArticleCard"; | ||
import JournalNavbarComponent from "../../components/Journal/JournalNavbar"; | ||
import { Box } from "../../components/Journal/Box"; | ||
|
||
const JournalFeed: NextPage = () => { | ||
const supabase = useSupabaseClient(); | ||
const session = useSession(); | ||
|
||
const router = useRouter(); | ||
const [articles, setArticles] = useState([]); | ||
|
||
useEffect(() => { | ||
getArticles(); | ||
}, []); | ||
|
||
const getArticles = async () => { | ||
try { | ||
const { data, error } = await supabase | ||
.from('articles') | ||
.select("*") | ||
.limit(10) | ||
console.log(data); | ||
if (data != null) { setArticles(data); }; | ||
} catch (error: any) { alert(error.message) }; | ||
}; | ||
|
||
return ( | ||
<NextUIProvider> | ||
<JournalNavbarComponent /> | ||
<Box css={{ px: "$12", py: "$15", mt: "$12", "@xsMax": {px: "$10"}, maxWidth: "800px", margin: "0 auto" }}> | ||
<> | ||
<Text h2>Main Feed</Text> | ||
<Text size="$lg" css={{my: "$8"}}> | ||
Check out articles from users here | ||
</Text> | ||
{articles.map((article) => ( | ||
<JournalArticleCard article={article}/> | ||
))} | ||
</> | ||
</Box> | ||
</NextUIProvider> | ||
); | ||
}; | ||
|
||
export default JournalFeed; |
Oops, something went wrong.
744a0d6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#28