Skip to content

Commit

Permalink
Final change
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromemccree committed Aug 14, 2023
1 parent 969abcb commit d71c7ae
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 34 deletions.
16 changes: 16 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# When adding additional environment variables, the schema in "/src/env.mjs"
# should be updated accordingly.

# Prisma
# https://www.prisma.io/docs/reference/database-reference/connection-urls#env
DATABASE_URL=""
NEXTAUTH_SECRET=""
NEXTAUTH_URL="http://localhost:3000"
EMAIL_SERVER_USER=""
EMAIL_SERVER_PASSWORD=""
EMAIL_SERVER_HOST="smtp.gmail.com"
EMAIL_SERVER_PORT=465
EMAIL_FROM=""
NEXT_PUBLIC_CLOUDINARY_NAME=""


26 changes: 13 additions & 13 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ datasource db {
relationMode = "prisma"
}

enum EngagementType {
LIKE
DISLIKE
SAVE
FOLLOW
VIEW
}

model User {
id String @id @default(cuid())
name String?
Expand All @@ -39,10 +31,10 @@ model User {

model Video {
id String @id @default(cuid())
title String @default(dbgenerated("(_utf8mb4\\'No Name\\')")) @db.Text
title String? @db.Text
thumbnailUrl String? @db.Text
description String? @db.Text
thumbnailUrl String @default(dbgenerated("(_utf8mb4\\'https://via.placeholder.com/150\\')")) @db.Text
videoUrl String @db.Text
videoUrl String? @db.Text
publish Boolean @default(true)
userId String
createdAt DateTime @default(now())
Expand All @@ -59,9 +51,9 @@ model VideoEngagement {
id String @id @default(cuid())
userId String?
videoId String
engagementType EngagementType
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
engagementType EngagementType
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
video Video @relation(fields: [videoId], references: [id], onDelete: Cascade)
Expand Down Expand Up @@ -122,10 +114,10 @@ model Announcement {

model AnnouncementEngagement {
userId String
announcementId String
engagementType EngagementType
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
announcementId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
announcement Announcement @relation(fields: [announcementId], references: [id], onDelete: Cascade)
Expand Down Expand Up @@ -184,3 +176,11 @@ model VerificationToken {
@@unique([identifier, token])
}

enum EngagementType {
LIKE
DISLIKE
SAVE
FOLLOW
VIEW
}
23 changes: 2 additions & 21 deletions src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import {
} from "~/Components/Buttons/Buttons";
import { api } from "~/utils/api";
import { GreenEye, GreenUserCheck, GreenHeart } from "~/Components/Icons/Icons";
import React, { type ReactElement } from "react";
import React from "react";
const Dashboard: NextPage = () => {
const { data: sessionData } = useSession();

// ! step 1 start
const userId = sessionData?.user.id;
const { data, isLoading, error, refetch } =
api.user.getDashboardData.useQuery(userId as string);
Expand All @@ -44,8 +43,7 @@ const Dashboard: NextPage = () => {
return <></>;
}
};
// ! step 1 End
// ! step 3 Start

const stats: StatsItem[] = [
{
name: "Total Views",
Expand All @@ -63,7 +61,6 @@ const Dashboard: NextPage = () => {
icon: (className) => <GreenHeart className={className} />,
},
];
// ! step 3 End

return (
<>
Expand All @@ -76,7 +73,6 @@ const Dashboard: NextPage = () => {
{!data ? (
<Error />
) : (
// ! step 2 start
<div className="flex flex-col gap-8 bg-white pt-3 shadow sm:rounded-lg">
<div className="md:flex md:items-center md:justify-between md:space-x-5">
<div className="flex items-start space-x-5">
Expand All @@ -89,15 +85,11 @@ const Dashboard: NextPage = () => {
</p>
</div>
</div>
{/* // ! step 8 Skip Start */}
<div className="mt-6 flex flex-col-reverse justify-stretch space-y-4 space-y-reverse sm:flex-row-reverse sm:justify-end sm:space-x-3 sm:space-y-0 sm:space-x-reverse md:mt-0 md:flex-row md:space-x-3">
<UploadButton refetch={refetch} />
</div>
{/* // ! step 8 Skip End */}
</div>
<div>
{/* // ! step 2 End */}
{/* // ! step 4 Start */}
<dl className="mt-5 grid grid-cols-1 divide-y divide-gray-200 overflow-hidden rounded-2xl border border-gray-200 shadow-sm md:grid-cols-3 md:divide-x md:divide-y-0">
{stats.map((item) => (
<div key={item.name} className="px-4 py-5 sm:p-6">
Expand Down Expand Up @@ -156,14 +148,10 @@ const Dashboard: NextPage = () => {
</th>
</tr>
</thead>
{/* // ! step 4 End */}

<tbody className="divide-y divide-gray-200 bg-white">
{data?.videos.map((video) => (
<tr key={video.id}>
{/* // ! step 5 Start */}
<PublishedButton video={video} />
{/* // ! step 5 End */}
<td className="whitespace-nowrap py-5 pl-4 pr-3 text-sm sm:pl-0">
<div className="flex">
<div className="h-16 w-16 flex-shrink-0">
Expand All @@ -189,14 +177,11 @@ const Dashboard: NextPage = () => {
</td>
<td className="whitespace-nowrap px-3 py-5 text-sm text-gray-600">
<div className="flex flex-row gap-2">
{/* // ! step 6 Start */}
<DeleteButton
videoId={video.id}
refetch={refetch}
/>
{/* // ! step 6 End */}

{/* // ! step 7 Start */}
<EditButton
video={{
id: video?.id || "",
Expand All @@ -206,7 +191,6 @@ const Dashboard: NextPage = () => {
}}
refetch={refetch}
/>
{/* // ! step 7 End */}
</div>
</td>
</tr>
Expand All @@ -223,9 +207,6 @@ const Dashboard: NextPage = () => {
</Layout>
</>
);
{
/* // ! step 4 End */
}
};

export default Dashboard;

0 comments on commit d71c7ae

Please sign in to comment.