From e2e88ccf1f9d1d835fc64f6181b5405e12882877 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 17 Feb 2024 18:50:43 -0500 Subject: [PATCH] feat: homepage --- src/client/index.ts | 80 +++++++++++-------- src/components/Header/index.tsx | 28 ++++--- src/pages/Main/index.tsx | 136 +++++++++++++++++++++++++------- src/pages/Main/style.module.css | 6 ++ src/pages/MovieCreate/index.tsx | 22 +++--- 5 files changed, 191 insertions(+), 81 deletions(-) create mode 100644 src/pages/Main/style.module.css diff --git a/src/client/index.ts b/src/client/index.ts index 0990721..92b83ac 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -16,16 +16,6 @@ export interface SchemaAuth { username?: string } -export interface SchemaCreateMovie { - /** @maxLength 255 */ - author: string - meta: SchemaMeta - status: number - /** @maxLength 255 */ - title: string - user_id: string -} - export interface SchemaCreateUser { /** @maxLength 150 */ email: string @@ -57,27 +47,30 @@ export interface SchemaJWT { user_id?: string } -export interface SchemaMeta { - description?: string - picture?: string - /** - * @min 1 - * @max 10 - */ - rating?: number -} - export interface SchemaMovie { /** @maxLength 255 */ - author: string - created_at?: string + cast: string + /** @maxLength 255 */ + category: string + /** @maxLength 255 */ + director: string id?: string - meta: SchemaMeta - status: number + /** @maxLength 255 */ + producer: string + /** @maxLength 255 */ + rating_code: string + /** @maxLength 255 */ + reviews: string + /** @maxLength 255 */ + show_time: string + /** @maxLength 255 */ + synopsis: string /** @maxLength 255 */ title: string - updated_at?: string - user_id: string + /** @maxLength 1023 */ + trailer_picture: string + /** @maxLength 1023 */ + trailer_video: string } export interface SchemaMovieListResponse { @@ -102,6 +95,30 @@ export interface SchemaUpdateUser { last_name: string } +export interface SchemaUpsertMovie { + /** @maxLength 255 */ + cast: string + /** @maxLength 255 */ + category: string + /** @maxLength 255 */ + director: string + /** @maxLength 255 */ + producer: string + /** @maxLength 255 */ + rating_code: string + /** @maxLength 255 */ + reviews: string + show_time: string + /** @maxLength 255 */ + synopsis: string + /** @maxLength 255 */ + title: string + /** @maxLength 1023 */ + trailer_picture: string + /** @maxLength 1023 */ + trailer_video: string +} + export interface SchemaUser { created_at?: string email?: string @@ -574,6 +591,10 @@ export class Api< offset?: number /** limit */ limit?: number + /** search by title */ + search?: string + /** the moive is running or not */ + running?: boolean }, params: RequestParams = {} ) => @@ -595,14 +616,11 @@ export class Api< * @request POST:/api/v1/movies * @secure */ - v1MoviesCreate: ( - createmovie: SchemaCreateMovie, - params: RequestParams = {} - ) => + v1MoviesCreate: (movie: SchemaUpsertMovie, params: RequestParams = {}) => this.request({ path: `/api/v1/movies`, method: 'POST', - body: createmovie, + body: movie, secure: true, type: ContentType.Json, format: 'json', diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index 22d8ac6..7e33099 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -55,20 +55,22 @@ const Index: React.FC = () => { ) : ( - - - + <> + + + + + + + )} - - - diff --git a/src/pages/Main/index.tsx b/src/pages/Main/index.tsx index ce12d42..7fbe3c7 100644 --- a/src/pages/Main/index.tsx +++ b/src/pages/Main/index.tsx @@ -1,43 +1,125 @@ +import './style.module.css' import { useRequest } from 'ahooks' +import type { SchemaMovie } from 'client' import PageContainer from 'components/PageContainer' import type React from 'react' +import { useState } from 'react' +import { Button, Col, Form, Modal, Row } from 'react-bootstrap' import Card from 'react-bootstrap/Card' -import ListGroup from 'react-bootstrap/ListGroup' +import { Link } from 'react-router-dom' import Backend from 'utils/service' +const Movie: React.FC<{ movie: SchemaMovie }> = ({ movie }) => { + const [show, setShow] = useState(false) + + const handleClose = () => setShow(false) + const handleShow = () => setShow(true) + return ( + + + + {movie.title} + +
Director: {movie.director}
+
Cast: {movie.cast}
+
Category: {movie.category}
+
+ {' '} + + + +
+ + + Trailer of {movie.title} + + + {/* eslint-disable-next-line react/iframe-missing-sandbox */} +