Commit 8a47fe12 authored by Daniel Puchala's avatar Daniel Puchala
Browse files

refactor: code cleanup

parent e8ef9352
import useSWR from 'swr';
import Header from './Header';
import MovieCard from './MovieCard';
import fetcher from '../models/fetcher';
import { MovieCardMode } from '../models/types';
import { MovieCardMode, MovieDto } from '../models/types';
export const LandingPage = () => {
const { data, error } = useSWR('movies');
const { data, error } = useSWR<MovieDto[]>('movies');
if (error) return <div>failed to load</div>;
if (!data) return <div>loading...</div>;
......
import Header from './Header';
import { useState } from 'react';
import { getUser, login } from '../services/auth';
import { login } from '../services/auth';
import { useNavigate } from 'react-router-dom';
export const Login = () => {
......
import { Link } from 'react-router-dom';
import { MovieCardMode } from '../models/types';
import { MovieCardMode, MovieCardProps } from '../models/types';
import formatDuration from '../services/formatDuration';
export interface MovieCardProps {
id: number,
name: string,
poster: string,
duration: number,
mode: MovieCardMode
}
export const MovieCard = ({ id, name, poster, duration, mode }: MovieCardProps) => {
return (
<Link
......
import { getToken, getUser } from '../services/auth';
import instance from '../models/axios';
import { KeyedMutator } from 'swr/dist/types';
export interface ReviewProps {
id: number,
userId: number,
text: string,
averageRating: number,
userName: string,
mutate: KeyedMutator<any>,
}
import { ReviewProps } from '../models/types';
export const Review = ({id, userId, text, averageRating, userName, mutate}: ReviewProps) => {
const user = getUser();
......
import { KeyedMutator } from 'swr/dist/types';
export enum MovieCardMode {
LandingPage,
Recommend
......@@ -83,3 +85,22 @@ export interface SimplerUserDto {
name: string,
avatar: string,
}
export interface ReviewProps {
id: number,
userId: number,
text: string,
averageRating: number,
userName: string,
mutate: KeyedMutator<any>,
}
export interface MovieCardProps {
id: number,
name: string,
poster: string,
duration: number,
mode: MovieCardMode
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment