-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
000c3c2
commit 0c42dc2
Showing
15 changed files
with
480 additions
and
18 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 |
---|---|---|
@@ -1,3 +1,117 @@ | ||
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; | ||
import { Button } from "../ui/Button"; | ||
// import { Card } | ||
// Look into methods to engage resource gathering with the lightcurves, make it a scrollable feed with planet content, show how the curves lead into the rover. | ||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui/Card"; | ||
import { Form, FormControl, FormField, FormItem, FormMessage } from "../ui/Form"; | ||
import { Textarea } from "../ui/TextArea"; | ||
import { useToast } from "../ui/use-toast"; | ||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { VenetianMask } from "lucide-react"; | ||
import React, { useContext, useEffect, useState} from "react"; | ||
import { useForm } from "react-hook-form"; | ||
import { z } from "zod"; | ||
import { UserContext } from "../../context/UserContext"; | ||
import { useRouter } from "next/router"; | ||
import { Avatar, AvatarFallback } from "../ui/Avatar"; | ||
import { AvatarImage } from "@radix-ui/react-avatar"; | ||
|
||
type TProps = { | ||
category_id: "1" | "2", | ||
openCreateMenu: boolean; | ||
setOpenCreateMenu: (value: React.SetStateAction<boolean>) => void; | ||
setCreatedPost: (value: React.SetStateAction<boolean>) => void; | ||
}; | ||
|
||
export default function CreatePostForm ( { planetId2 } ) { // category_id | ||
const supabase = useSupabaseClient(); | ||
const session = useSession(); | ||
|
||
const [postContent, setPostContent] = useState('') | ||
const profile = useContext(UserContext); | ||
const [username, setUsername] = useState(''); | ||
|
||
const [uploads, SetUploads] = useState(''); | ||
const [isUploading, setIsUploading] = useState(false); | ||
const [avatar_url, setAvatarUrl] = useState(null); | ||
const [userExperience, setUserExperience] = useState(); | ||
// const [hasRequiredItem, setHasRequiredItem] = useState(false); | ||
|
||
function createPost() { | ||
supabase | ||
.from('posts_duplicates') | ||
.insert({ | ||
author: session?.user?.id, | ||
content: postContent, | ||
media: uploads, | ||
planets2: planetId2, | ||
}) | ||
}; | ||
|
||
useEffect(() => { | ||
supabase | ||
.from('profiles') | ||
.select(`avatar_url, experience, username`) | ||
.eq('id', session?.user?.id) | ||
.then(result => { | ||
setAvatarUrl(result?.data[0]?.avatar_url); | ||
setUsername(result?.data[0]?.username); | ||
}); | ||
}, [session]); | ||
|
||
// async function addMedia ( e ) { | ||
// const files = e.target.files; | ||
// if (files.length > 0) { | ||
// setIsUploading(true); | ||
// for (const file of files) { // To-Do: List of user's photos from the image gallery in wb3-10 | ||
// const fileName = Date.now() + session?.user?.id + file.name; // Generate a random string to make the file unique | ||
// const result = await supabase.storage | ||
// .from('media') // Upload the file/media | ||
// .upload(fileName, file); | ||
|
||
// if (result.data) { | ||
// const url = process.env.NEXT_PUBLIC_SUPABASE_URL + '/storage/v1/object/public/media/' + result.data.path; | ||
// SetUploads(prevUploads => [...prevUploads, url]); // Add the most recently uploaded image to an array of images that are in state | ||
// } else { | ||
// console.log(result); | ||
// } | ||
// } | ||
// setIsUploading(false); | ||
// } | ||
// } | ||
|
||
const form = useForm({ | ||
defaultValues: { | ||
content: "", | ||
}, | ||
}); | ||
|
||
return ( | ||
<> | ||
<div className="flex gap-2"> | ||
<Avatar> | ||
{/* <AvatarImage src={"https://qwbufbmxkjfaikoloudl.supabase.co/storage/v1/object/public/avatars/" + avatar_url ?? ""}> */} | ||
<AvatarFallback>{username}</AvatarFallback> | ||
{/* </AvatarImage> */} | ||
</Avatar> | ||
</div> | ||
{/* <CardContent className="p-0 pt-2"> | ||
<Form {...form}> | ||
</Form> | ||
</CardContent> */} | ||
<textarea value={postContent} onChange={e => setPostContent(e.target.value)} className="grow p-3 h-24 rounded-xl" placeholder={"What do you think about this candidate"} /> | ||
{/* {uploads.length > 0 && ( | ||
<div className="flex gap-2 mt-4"> | ||
{uploads.map(upload => ( | ||
<div className=""><img src={upload} className="w-auto h-48 rounded-md" /> | ||
))} | ||
</div> | ||
)} */} | ||
{/* <div className={`fixed inset-0 bg-white/80 backdrop-blur-md z-20 items-center justify-center`}> */} | ||
{/* <Card> */} | ||
{/* </Card> */} | ||
{/* </div> */} | ||
</> | ||
) | ||
} | ||
|
||
// Look into methods to engage resource gathering with the lightcurves, make it a scrollable feed with planet content, show how the curves lead into the rover. |
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
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,82 @@ | ||
import * as React from "react"; | ||
import { cn } from "../../lib/uitls"; | ||
|
||
const Card = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
"rounded-xl border bg-card text-card-foreground shadow", | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
Card.displayName = "Card"; | ||
|
||
const CardHeader = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("flex flex-col space-y-1.5 p-6", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardHeader.displayName = "CardHeader"; | ||
|
||
const CardTitle = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLHeadingElement> | ||
>(({ className, ...props }, ref) => ( | ||
<h3 | ||
ref={ref} | ||
className={cn("font-semibold leading-none tracking-tight", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardTitle.displayName = "CardTitle"; | ||
|
||
const CardDescription = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLParagraphElement> | ||
>(({ className, ...props }, ref) => ( | ||
<p | ||
ref={ref} | ||
className={cn("text-sm text-muted-foreground", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardDescription.displayName = "CardDescription"; | ||
|
||
const CardContent = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} /> | ||
)); | ||
CardContent.displayName = "CardContent"; | ||
|
||
const CardFooter = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("flex items-center p-6 pt-0", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardFooter.displayName = "CardFooter"; | ||
|
||
export { | ||
Card, | ||
CardHeader, | ||
CardFooter, | ||
CardTitle, | ||
CardDescription, | ||
CardContent, | ||
}; |
Oops, something went wrong.