Skip to content

Commit e88d546

Browse files
committed
Prettier - client and server
1 parent 6235491 commit e88d546

File tree

9 files changed

+124
-126
lines changed

9 files changed

+124
-126
lines changed

client/.vscode/settings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"alias-resolver.type": "custom",
3-
"alias-resolver.accessPath": ""
4-
}
2+
"alias-resolver.type": "custom",
3+
"alias-resolver.accessPath": ""
4+
}

client/src/components/movie-list/Card.tsx

+58-57
Original file line numberDiff line numberDiff line change
@@ -71,68 +71,69 @@ export const Card = ({
7171
</div>
7272

7373
<div className=" flex w-full flex-wrap items-start justify-center gap-5 lg:gap-10">
74-
{movies && movies.map((movie) => {
75-
const isExpanded = expandedMovies[movie.id as string];
76-
return (
77-
<Component
78-
data-testid="movie-detail-card"
79-
horizontal
80-
key={movie.id}
81-
className="w-full rounded-md border-2 border-gray-300 shadow-xl dark:border-gray-700 lg:h-[387px]"
82-
renderImage={() => (
83-
<img
84-
loading="lazy"
85-
src={movie.poster}
86-
alt={`${movie.title} + poster picture`}
87-
className="h-64 w-auto rounded-l md:h-full lg:h-96 lg:w-64"
88-
/>
89-
)}
90-
>
91-
<div className=" flex h-full flex-col justify-start gap-5 md:gap-0 lg:gap-0">
92-
<div className="flex flex-col ">
93-
<h5 className="flex space-x-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white lg:block">
94-
{movie.title}
95-
{rank && ` (${movie._count?.reviews})`}
96-
</h5>
74+
{movies &&
75+
movies.map((movie) => {
76+
const isExpanded = expandedMovies[movie.id as string];
77+
return (
78+
<Component
79+
data-testid="movie-detail-card"
80+
horizontal
81+
key={movie.id}
82+
className="w-full rounded-md border-2 border-gray-300 shadow-xl dark:border-gray-700 lg:h-[387px]"
83+
renderImage={() => (
84+
<img
85+
loading="lazy"
86+
src={movie.poster}
87+
alt={`${movie.title} + poster picture`}
88+
className="h-64 w-auto rounded-l md:h-full lg:h-96 lg:w-64"
89+
/>
90+
)}
91+
>
92+
<div className=" flex h-full flex-col justify-start gap-5 md:gap-0 lg:gap-0">
93+
<div className="flex flex-col ">
94+
<h5 className="flex space-x-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white lg:block">
95+
{movie.title}
96+
{rank && ` (${movie._count?.reviews})`}
97+
</h5>
9798

98-
<Star />
99-
<p className="font-normal text-gray-700 dark:text-gray-400">
100-
{isExpanded
101-
? `${movie.description.substring(0, 200)}...`
102-
: `${movie.description.substring(0, 100)}...`}
103-
<button
104-
className="flex flex-col text-sm hover:underline"
99+
<Star />
100+
<p className="font-normal text-gray-700 dark:text-gray-400">
101+
{isExpanded
102+
? `${movie.description.substring(0, 200)}...`
103+
: `${movie.description.substring(0, 100)}...`}
104+
<button
105+
className="flex flex-col text-sm hover:underline"
106+
onClick={() =>
107+
setExpandedMovies({
108+
...expandedMovies,
109+
[movie.id as string]: !isExpanded,
110+
})
111+
}
112+
>
113+
{isExpanded ? "Read Less" : "Read More"}
114+
</button>
115+
</p>
116+
</div>
117+
<div className="mt-auto w-full ">
118+
<Button
119+
dataTestId="watch-now-button"
105120
onClick={() =>
106-
setExpandedMovies({
107-
...expandedMovies,
108-
[movie.id as string]: !isExpanded,
109-
})
121+
navigate(`/movie/${titleToSlug(movie.title)}`)
110122
}
123+
title={"Watch Now"}
124+
color="failure"
125+
className={`w-full rounded-md lg:w-[270px] ${
126+
isExpanded ? "lg:mt-10" : "md:mt-10 lg:mt-24"
127+
}`}
128+
isProcessing={false}
111129
>
112-
{isExpanded ? "Read Less" : "Read More"}
113-
</button>
114-
</p>
130+
<HiOutlineArrowRight className="ml-2 h-5 w-5" />
131+
</Button>
132+
</div>
115133
</div>
116-
<div className="mt-auto w-full ">
117-
<Button
118-
dataTestId="watch-now-button"
119-
onClick={() =>
120-
navigate(`/movie/${titleToSlug(movie.title)}`)
121-
}
122-
title={"Watch Now"}
123-
color="failure"
124-
className={`w-full rounded-md lg:w-[270px] ${
125-
isExpanded ? "lg:mt-10" : "md:mt-10 lg:mt-24"
126-
}`}
127-
isProcessing={false}
128-
>
129-
<HiOutlineArrowRight className="ml-2 h-5 w-5" />
130-
</Button>
131-
</div>
132-
</div>
133-
</Component>
134-
);
135-
})}
134+
</Component>
135+
);
136+
})}
136137
</div>
137138
</div>
138139
</section>

client/src/pages/Movies.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ export const Movies = () => {
2929

3030
const isAuthenticated = checkUserAuth();
3131
if (isMoviesPending || isFeaturedMoviesPending) return <Spinner />;
32-
if (isMoviesError || isFeaturedMoviesError)
33-
navigate("/error")
34-
// return <ErrorModal show={true} message={"Movies could not be fetched"} />;
32+
if (isMoviesError || isFeaturedMoviesError) navigate("/error");
33+
// return <ErrorModal show={true} message={"Movies could not be fetched"} />;
3534

3635
return (
3736
<>

server/prisma/seed.ts

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { db } from "../lib/prisma.db";
22

33
type User = {
4-
email: string;
5-
firstName: string;
6-
lastName: string;
7-
password: string;
4+
email: string;
5+
firstName: string;
6+
lastName: string;
7+
password: string;
88
};
99

1010
type Movie = {
11-
title: string;
12-
poster: string;
13-
trailer: string;
14-
description: string;
11+
title: string;
12+
poster: string;
13+
trailer: string;
14+
description: string;
1515
};
1616

1717
type Review = {
18-
title: string;
19-
description: string;
20-
rating: number;
18+
title: string;
19+
description: string;
20+
rating: number;
2121
};
2222

2323
function getUsers(): Array<User> {
@@ -33,7 +33,7 @@ function getUsers(): Array<User> {
3333
firstName: "mike",
3434
lastName: "jason",
3535
password: "test@Password",
36-
}
36+
},
3737
];
3838
}
3939

@@ -42,26 +42,27 @@ function getMovies(): Array<Movie> {
4242
{
4343
title: "Oppenheimer",
4444
poster:
45-
"https://upload.wikimedia.org/wikipedia/en/4/4a/Oppenheimer_%28film%29.jpg",
45+
"https://upload.wikimedia.org/wikipedia/en/4/4a/Oppenheimer_%28film%29.jpg",
4646
trailer: "https://www.youtube.com/watch?v=uYPbbksJxIg",
4747
description:
48-
"During World War II, Lt. Gen. Leslie Groves Jr. appoints physicist J. Robert Oppenheimer to work on the top-secret Manhattan Project. Oppenheimer and a team of scientists spend years developing and designing the atomic bomb. Their work comes to fruition on July 16, 1945, as they witness the world's first nuclear explosion, forever changing the course of history.",
48+
"During World War II, Lt. Gen. Leslie Groves Jr. appoints physicist J. Robert Oppenheimer to work on the top-secret Manhattan Project. Oppenheimer and a team of scientists spend years developing and designing the atomic bomb. Their work comes to fruition on July 16, 1945, as they witness the world's first nuclear explosion, forever changing the course of history.",
4949
},
5050
{
5151
title: "Napoleon",
5252
poster:
53-
"https://upload.wikimedia.org/wikipedia/en/2/2e/Napoleon_Film_poster.jpg",
53+
"https://upload.wikimedia.org/wikipedia/en/2/2e/Napoleon_Film_poster.jpg",
5454
trailer: "https://www.youtube.com/watch?v=OAZWXUkrjPc",
5555
description:
56-
"A look at the military commander's origins and his swift, ruthless climb to emperor, viewed through the prism of his addictive and often volatile relationship with his wife and one true love, Josephine",
56+
"A look at the military commander's origins and his swift, ruthless climb to emperor, viewed through the prism of his addictive and often volatile relationship with his wife and one true love, Josephine",
5757
},
5858
{
5959
title: "The Last Kingdom Seven Kings Must Die",
60-
poster: "https://upload.wikimedia.org/wikipedia/en/1/15/Last_kingdom_seven_kings_must_die.png",
60+
poster:
61+
"https://upload.wikimedia.org/wikipedia/en/1/15/Last_kingdom_seven_kings_must_die.png",
6162
trailer: "https://www.youtube.com/watch?v=eqCYw_o5lng",
6263
description:
63-
"Uhtred of Bebbanburg is given a task by King Edward to kill the seven kings who have formed an alliance against him. Uhtred is forced to face the greatest enemy he has ever encountered, and the fate of Wessex hangs in the balance.",
64-
}
64+
"Uhtred of Bebbanburg is given a task by King Edward to kill the seven kings who have formed an alliance against him. Uhtred is forced to face the greatest enemy he has ever encountered, and the fate of Wessex hangs in the balance.",
65+
},
6566
];
6667
}
6768

@@ -79,8 +80,8 @@ async function seed() {
7980
});
8081
const testUser = await db.user.findFirst({
8182
where: {
82-
83-
}
83+
84+
},
8485
});
8586
const movies = getMovies();
8687
console.log("Seeding movies...");
@@ -92,7 +93,7 @@ async function seed() {
9293
poster: movie.poster,
9394
trailer: movie.trailer,
9495
description: movie.description,
95-
userId: testUser.id
96+
userId: testUser.id,
9697
},
9798
});
9899
});

server/src/__tests__/integration/review.test.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import request from "supertest";
33
import app from "../../app";
44

55
type ReviewPayload = {
6-
title: string;
7-
description: string;
8-
rating: number;
9-
userId?: string;
6+
title: string;
7+
description: string;
8+
rating: number;
9+
userId?: string;
1010
};
1111

1212
type MoviewPayload = {
13-
title: string;
14-
description: string;
15-
poster: string;
16-
trailer: string;
17-
userId?: string;
13+
title: string;
14+
description: string;
15+
poster: string;
16+
trailer: string;
17+
userId?: string;
1818
};
1919

2020
describe("Review - Controller", () => {

server/src/__tests__/unit/middleware.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NextFunction,Request, Response } from "express";
1+
import { NextFunction, Request, Response } from "express";
22

33
import { validateToken } from "../../middewares/auth";
44
import { verifyToken } from "../../utils/auth";

server/src/movie/repository.ts

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Movie,PrismaClient } from "@prisma/client";
1+
import { Movie, PrismaClient } from "@prisma/client";
22

33
import { IMovieRepository } from "./service";
44
export class MovieRepository implements IMovieRepository {
@@ -40,31 +40,28 @@ export class MovieRepository implements IMovieRepository {
4040
}
4141
async getMoviesWithMostReviews(): Promise<Movie[]> {
4242
return await this.prisma.movie.findMany({
43-
include:{
44-
_count:{
45-
select:{
46-
reviews:true
47-
}
48-
}
43+
include: {
44+
_count: {
45+
select: {
46+
reviews: true,
47+
},
48+
},
4949
},
5050
orderBy: {
51-
reviews:{
52-
_count:"desc"
53-
}
54-
}
51+
reviews: {
52+
_count: "desc",
53+
},
54+
},
5555
});
5656
}
5757
async getMovies(): Promise<Movie[]> {
58-
return await this.prisma.movie.findMany({
59-
60-
});
58+
return await this.prisma.movie.findMany({});
6159
}
6260
async getByTitle(title: string): Promise<Movie | null> {
6361
return await this.prisma.movie.findUnique({
6462
where: {
6563
title: title,
6664
},
67-
6865
});
6966
}
7067
async create(movie: Partial<Movie>): Promise<Movie> {

0 commit comments

Comments
 (0)