Skip to content

Commit

Permalink
🌱🔗 ↝ Journal metadata now shown without build error, add initial IPFS…
Browse files Browse the repository at this point in the history
… beginning for Signal-K/Silfur#22, Signal-K/Silfur#24. Added new ship interface for the web game type interface described in Signal-K/sytizen#16. Build error tracked down in #26 -> mapping the articles was not an issue, it was the use of the UI Provider that caused the build errors.
  • Loading branch information
Gizmotronn committed Mar 4, 2023
1 parent 297da3d commit 87b6a28
Show file tree
Hide file tree
Showing 15 changed files with 282 additions and 83 deletions.
Binary file modified .DS_Store
Binary file not shown.
13 changes: 11 additions & 2 deletions components/Core/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Fragment, forwardRef, useState, useEffect } from "react";
import Link from "next/link";
import { useRouter } from "next/router";
import { ConnectWallet, useAddress, /* useEditionDrop, */ useOwnedNFTs, useContract } from "@thirdweb-dev/react";
import styles from '../../styles/Staking-P2E/planetInteraction.module.css';

import {
Bars3CenterLeftIcon,
PencilIcon,
Expand All @@ -18,6 +21,8 @@ import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
export default function CoreNavigation ({ showNav, setShowNav }) {
const session = useSession();
const supabase = useSupabaseClient();
const address = useAddress();
const router = useRouter();

const [loading, setLoading] = useState(false);
const [username, setUsername] = useState(null);
Expand All @@ -43,7 +48,7 @@ export default function CoreNavigation ({ showNav, setShowNav }) {
setAvatarUrl(data.avatar_url);
}
} catch (error) {
alert('Error loading your user data');
//alert('Error loading your user data');
console.log(error);
} finally {
setLoading(false);
Expand Down Expand Up @@ -181,7 +186,7 @@ export default function CoreNavigation ({ showNav, setShowNav }) {
</Menu.Item>
<Menu.Item>
<Link
href="#"
href="https://orcid.org/my-orcid?orcid=0009-0000-9139-5148"
className="flex hover:bg-orange-500 hover:text-white text-gray-700 rounded p-2 text-sm group transition-colors items-center"
>
<CreditCardIcon className="h-4 w-4 mr-2" />
Expand All @@ -197,6 +202,10 @@ export default function CoreNavigation ({ showNav, setShowNav }) {
Settings
</Link>
</Menu.Item>
<Menu.Item>
{/*<div className={styles.container}>*/}
<ConnectWallet />
</Menu.Item>
</div>
</Menu.Items>
</Transition>
Expand Down
38 changes: 35 additions & 3 deletions components/Core/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { forwardRef } from "react";
import Link from "next/link";
import { HomeIcon, CreditCardIcon, UserIcon, RocketLaunchIcon, MagnifyingGlassCircleIcon } from "@heroicons/react/24/solid";
import { HomeIcon, PaintBrushIcon, DocumentMagnifyingGlassIcon, CreditCardIcon, UserIcon, RocketLaunchIcon, MagnifyingGlassCircleIcon } from "@heroicons/react/24/solid";
import { useRouter } from "next/router";

const CoreSidebar = forwardRef(({ showNav }, ref) => {
const router = useRouter();

return (
<div ref={ref} className="fixed w-56 h-full bg-white shadow-sm">
<div ref={ref} className="fixed w-64 h-full bg-white shadow-sm">
<div className="flex justify-center mt-6 mb-14">
<picture>
<img
className="w-32 h-auto"
src="https://user-images.githubusercontent.com/31812229/222339335-ae57fdb9-6fbd-4d26-9225-a18c02b6edeb.png"
alt="company logo"
alt="signal kinetics logo"
/>
</picture>
</div>
Expand Down Expand Up @@ -83,6 +83,38 @@ const CoreSidebar = forwardRef(({ showNav }, ref) => {
</div>
</div>
</Link>
<Link href="/journal/ipfs">
<div
className={`pl-6 py-3 mx-5 rounded text-center cursor-pointer mb-3 flex items-center transition-colors ${
router.pathname == "/journal/ipfs"
? "bg-green-100 text-green-500"
: "text-gray-400 hover:bg-green-100 hover:text-green-500"
}`}
>
<div className="mr-2">
<PaintBrushIcon className="h-5 w-5" />
</div>
<div>
<p>Pins</p>
</div>
</div>
</Link>
<Link href="/journal">
<div
className={`pl-6 py-3 mx-5 rounded text-center cursor-pointer mb-3 flex items-center transition-colors ${
router.pathname == "/journal"
? "bg-green-100 text-green-500"
: "text-gray-400 hover:bg-green-100 hover:text-green-500"
}`}
>
<div className="mr-2">
<DocumentMagnifyingGlassIcon className="h-5 w-5" />
</div>
<div>
<p>Journal</p>
</div>
</div>
</Link>
<Link href="/posts/lens/parselay.lens">
<div
className={`pl-6 py-3 mx-5 rounded text-center cursor-pointer mb-3 flex items-center transition-colors ${
Expand Down
68 changes: 68 additions & 0 deletions components/Gameplay/Vehicles/ShipyardCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, { useEffect, useState } from "react";
import Link from "next/link";

import Layout from "../../Layout";
import CoreLayout from "../../Core/Layout";
import PostCard from "../../PostCard";
import Card from "../../Card";

import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
import { UserContext } from "../../../context/UserContext";
import { Database } from "../../../utils/database.types";
import PlanetEditor from "../../../pages/generator/planet-editor";

type Spaceships = Database['public']['Tables']['spaceships']['Row'];

export default function ShipyardCard ( { image, name, shipId, hp, attack, speed, location, owner } ) {
const supabase = useSupabaseClient();
const session = useSession();
const [posts, setPosts] = useState([]);
const [profile, setProfile] = useState(null);
const [ship, setShip] = useState(null)

const [loading, setLoading] = useState(null);

useEffect(() => {
getShips();
}, [session]);

async function getShips () {

}

return (
<>
<Card noPadding={false}>
<div className="flex gap-3">
<div className="grow">
<p className="my-3 text-sm">Name: {name}</p>
<p className="my-3 text-sm">Defence: {hp}</p>
<p className="my-3 text-sm">Attack: {attack}</p>
<p className="my-3 text-sm">Speed: {speed}</p>
<p className="buttonColour my-3 text-sm">Location: {location}</p>
</div>
<div className="flex gap-4 rounded-md overflow-hidden">
<img src={image} />
</div>
</div>
<div className="grow text-right">
<button className="bg-buttonColour text-white px-6 py-1 rounded-md">Buy ship</button> {/* If there is an owner, don't show this button */}
</div>
</Card>
{/*<CoreLayout>
<Layout hideNavigation={true}>
<Card noPadding={false}>This page will display all the ships</Card>
<Card noPadding={false}>
<div className="flex gap-3">
<div className="grow">
<p><Link href={'/posts/ship' + ship}>
<span className="mr-1 font-semibold cursor-pointer hover:underline">Spaceship Name</span>
</Link></p>
</div>
</div>
</Card>
</Layout>
</CoreLayout>*/}
</>
)
}
35 changes: 20 additions & 15 deletions components/Journal/ArticleCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NextPage } from "next";
import { useRouter } from "next/router";
import { Card, Text, NextUIProvider } from "@nextui-org/react";
import { Box } from "./Box";
import Card from "../Card";
import JournalNavbarComponent from "./JournalNavbar";

import { useSession } from "@supabase/auth-helpers-react";
Expand All @@ -16,20 +15,26 @@ const JournalArticleCard: NextPage<Props> = ( props ) => {
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>
return (<>
<Card noPadding={false}>
<div className="relative">
<p>{article.title}</p>
<p>Posted by {article.user_id.toLowerCase()}</p>
</div>
</Card>
</NextUIProvider>
{/*<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>*/}</>
)
}

Expand Down
2 changes: 1 addition & 1 deletion pages/generator/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function OffchainAccount({ session }: { session: Session}) {
setAddress(data.address);
}
} catch (error) {
alert('Error loading your user data');
//alert('Error loading your user data');
console.log(error);
} finally {
setLoading(false);
Expand Down
1 change: 1 addition & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SocialGraphHomeNoSidebar } from "./posts";

export default function Home() {
const session = useSession();
// add an iframe/ref to super.so dashboard

return (
<>
Expand Down
88 changes: 35 additions & 53 deletions pages/journal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,65 +1,47 @@
import React, { useEffect, useState } from "react";

import Layout from "../../components/Layout";
import SearchFormCard from "../../components/Journal/SearchFormCard";
import PostCard from "../../components/PostCard";
import type { NextPage } from "next";
import CoreLayout from "../../components/Core/Layout";
import { useState, useEffect } from "react";
import { Text, NextUIProvider } from '@nextui-org/react';

import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
import { UserContext } from "../../context/UserContext";

import TimeAgo from "javascript-time-ago";
import en from 'javascript-time-ago/locale/en.json';
import Login from "../login";
TimeAgo.addDefaultLocale(en);
import JournalArticleCard from "../../components/Journal/ArticleCard";
import JournalNavbarComponent from "../../components/Journal/JournalNavbar";
import { Box } from "../../components/Journal/Box";

export default function SearchToExtract () {
export default function JournalFeed () {
const supabase = useSupabaseClient();
const session = useSession();
const [posts, setPosts] = useState([]);
const [profile, setProfile] = useState(null);

useEffect(() => {
fetchPosts(); // Will later be fetching recently searched/saved papers by the user (in Cards)
}, []);
const [articles, setArticles] = useState([]);

useEffect(() => {
if (!session?.user?.id) { return; };
supabase.from('profiles')
.select()
.eq("id", session?.user?.id)
.then( result => {
if (result.data.length) { setProfile(result.data[0]); };
})
}, [session?.user?.id]);

function fetchPosts () {
supabase.from('posts')
.select('id, content, created_at, media, profiles(id, avatar_url, username)') // Reset id on testing playground server later
.order('created_at', { ascending: false })
.then(result => { setPosts(result.data); })
}

function fetchProfile () {
supabase.from('profiles')
.select()
.eq('id', session.user.id)
.then(result => {
if (result.data) {
setProfile(result.data[0]);
}
})
}
getArticles();
}, []);

if (!session) { return <Login />; };
const getArticles = async () => {
try {
const { data, error } = await supabase
.from('articles')
.select("*")
.limit(10)
console.log(data);
if (data != null) { setArticles(data); };
if (error) throw error;
} catch (error: any) { alert(error.message) };
};

return (
<Layout hideNavigation={false}>
<UserContext.Provider value={{profile}}> {/* Move this into `_app.tsx` later */}
<SearchFormCard onSearch={fetchPosts} />
{posts?.length > 0 && posts.map(post => (
<PostCard key = { post.id } {...post} />
))}
</UserContext.Provider>
</Layout>
);
<><div></div>
<NextUIProvider>
<CoreLayout>
<Box css={{ px: "$12", py: "$15", mt: "$12", "@xsMax": {px: "$10"}, maxWidth: "800px", margin: "0 auto" }}>
<>
{articles.map((article) => (
<JournalArticleCard article={article} />
))}
</>
</Box>
</CoreLayout>
</NextUIProvider></>
)
}
27 changes: 27 additions & 0 deletions pages/journal/ipfs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { NextPage } from "next";
import { useCallback } from "react";
import CoreLayout from "../../components/Core/Layout";

import { ConnectWallet, useStorageUpload } from "@thirdweb-dev/react";

const IpfsPinning: NextPage = () => {
const { mutateAsync: upload } = useStorageUpload();
const onDrop = useCallback(
async ( acceptedFiles: File[] ) => {
const uris = await upload ({ data: acceptedFiles });
console.log(uris);
},
[upload],
);

//const { getRootProps, getInputProps } = useDropzone({ onDrop });

return (
<CoreLayout>
<div>
</div>
</CoreLayout>
);
};

export default IpfsPinning;
Loading

0 comments on commit 87b6a28

Please sign in to comment.