Skip to content

Commit

Permalink
watch page feeds and video page feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
SH20RAJ committed May 18, 2024
1 parent b8c6ca4 commit d4e0d57
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 267 deletions.
73 changes: 46 additions & 27 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,36 @@ enum ReactionType {
}

model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
name String?
bio String?
avatar String?
coverPhoto String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
posts Post[]
likes Like[]
videos Video[]
status Status @default(public)
comments Comment[]
followers Follow[] @relation("UserFollowers")
following Follow[] @relation("UserFollowing")
roles UserRole[]
receivedMessages Message[] @relation("ReceiverMessages")
sentMessages Message[] @relation("SenderMessages")
pollResponses PollResponse[]
communities Community[] @relation("CommunityMembers")
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
name String?
bio String?
avatar String?
coverPhoto String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
posts Post[]
likes Like[]
videos Video[]
status Status @default(public)
comments Comment[]
followers Follow[] @relation("UserFollowers")
following Follow[] @relation("UserFollowing")
roles UserRole[]
receivedMessages Message[] @relation("ReceiverMessages")
sentMessages Message[] @relation("SenderMessages")
pollResponses PollResponse[]
communities Community[] @relation("CommunityMembers")
views View[] // Added relation to View model
}

model Post {
id Int @id @default(autoincrement())
content String @db.VarChar(20000)
taglist String? @db.VarChar(2000)
image String?
image String? @db.VarChar(2000)
contentURL String?
title String? @db.VarChar(200)
type Type? @default(text)
Expand All @@ -74,9 +75,10 @@ model Post {
status Status @default(public)
likes Like[]
comments Comment[]
tags Tag[]
tags Tag[]
pollOptions PollOption[]
communities Community[] @relation("PostCommunities")
views View[] // Added relation to View model
}

model Video {
Expand All @@ -92,6 +94,7 @@ model Video {
updatedAt DateTime @updatedAt
status Status @default(public) // Added to control visibility
likes Like[] // Added to handle likes specifically for videos
views View[] // Added relation to View model
}

model Like {
Expand All @@ -107,7 +110,6 @@ model Like {
@@unique([userId, postId, videoId])
}


model Comment {
id Int @id @default(autoincrement())
content String
Expand Down Expand Up @@ -170,7 +172,7 @@ model PollOption {
option String
responses PollResponse[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
updatedAt DateTime @default(now())
}

model PollResponse {
Expand All @@ -189,5 +191,22 @@ model Community {
members User[] @relation("CommunityMembers")
posts Post[] @relation("PostCommunities")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
updatedAt DateTime @default(now())
}

model View {
id Int @id @default(autoincrement())
videoId Int?
postId Int?
userId Int?
ipAddress String?
createdAt DateTime @default(now())
video Video? @relation(fields: [videoId], references: [id])
post Post? @relation(fields: [postId], references: [id])
user User? @relation(fields: [userId], references: [id])
@@index([videoId])
@@index([postId])
@@index([userId])
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function VideoComponent({feed}){
<Link href={"/watch/4"}><h3 className="font-semibold text-base line-clamp-2">{feed?.title || " _ "}</h3></Link>
<div
className="flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400">
<div>{feed?.author?.name}</div>
<div>{feed?.user?.name}</div>
<div></div>
<div>1.2M views</div>
<div></div>
Expand Down
32 changes: 25 additions & 7 deletions src/app/(services)/(sections)/videos/compo/UploadNewVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { useRouter } from 'next/navigation'
import 'react-toastify/dist/ReactToastify.css';



import {
Expand All @@ -23,6 +25,7 @@ import {
} from "@/components/ui/card";
import axios from "axios";
import { redirect } from "next/navigation";
import { ToastContainer, toast } from "react-toastify";

export default function UploadNewVideo() {
const router = useRouter()
Expand Down Expand Up @@ -78,17 +81,24 @@ export default function UploadNewVideo() {

// Validate if video URL is provided
if (!videoUrl) {
return alert("Please provide a video URL");
toast.warn(`Enter Video URL`)
return
alert("Please provide a video URL");
}

// Validate if title is provided
if (!title) {
return alert("Please provide a title");
toast.warn(`Please provide a title`)

return
alert("Please provide a title");
}

// Validate if description is provided
if (!description) {
return alert("Please provide a description");
toast.warn(`Please provide a description`)
return
alert("Please provide a description");
}

setUploading(true);
Expand All @@ -106,10 +116,15 @@ export default function UploadNewVideo() {
setUploading(false);

// Display success message
alert(response.data.message);
// alert(response.data.message);
toast.success(response.data.message);
console.log(response);
console.log(response.message);
router.push("/watch/"+response.data.post.id)
router.push("/watch/"+response.data.post.id)
router.push("/")
(() => {
location.href = "/watch/"+response.data.post.id
})()


// redirect("/watch/"+response.data.post.id)
Expand Down Expand Up @@ -183,8 +198,9 @@ router.push("/watch/"+response.data.post.id)
<input
type="text"
ref={thumbnailRef}
hidden
readOnly={true}
placeholder="Enter a thumbnail URL"
value={thumbnailURL}
onChange={(e)=>setThumbnailURL(e.target.value)}
/>
<Input id="thumbnail" type="file" onChange={getThumbnail} />
</div>
Expand Down Expand Up @@ -234,6 +250,8 @@ router.push("/watch/"+response.data.post.id)
</CardFooter>
</Card>
</div>
<ToastContainer />

</div>
);
}
Expand Down
Loading

0 comments on commit d4e0d57

Please sign in to comment.