This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Author, Book, Genre } from '../entities'; | |
import { IGenericRepository } from './generic-repository.abstract'; | |
export abstract class IDataServices { | |
abstract authors: IGenericRepository<Author>; | |
abstract books: IGenericRepository<Book>; | |
abstract genres: IGenericRepository<Genre>; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export abstract class IGenericRepository<T> { | |
abstract getAll(): Promise<T[]>; | |
abstract get(id: string): Promise<T>; | |
abstract create(item: T): Promise<T>; | |
abstract update(id: string, item: T); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Author { | |
firstName: string; | |
lastName: string; | |
} | |
export class Genre { | |
name: string; | |
} | |
export class Book { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import api from '~/common/api' | |
const ConnectedLoginForm = () => { | |
const handleSubmit = async (email, password) => { | |
await api.login(email, password) | |
} | |
return ( | |
<LoginForm onSubmit={handleSubmit} /> | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Props = { | |
onSubmit: (email: string, password: string) => Promise<void> | |
} | |
const LoginForm = ({ onSubmit }: Props) => { | |
const [email, setEmail] = useState('') | |
const [password, setPassword] = useState('') | |
const handleSubmit = async (evt) => { | |
evt.preventDefault() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import api from '~/common/api' | |
const LoginForm = () => { | |
const [email, setEmail] = useState('') | |
const [password, setPassword] = useState('') | |
const handleSubmit = async (evt) => { | |
evt.preventDefault() | |
await api.login(email, password) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Props = { | |
items: Array<Video | LiveStream> | |
} | |
const VideoList = ({ items }) => { | |
return ( | |
<ul> | |
{items.map(item => { | |
if ('coverUrl' in item) { | |
// it's a video |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Props = { | |
coverUrl: string | |
} | |
const Thumbnail = ({ coverUrl }: Props) => { | |
return <img src={coverUrl} /> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Props = { | |
items: Array<Video | LiveStream> | |
} | |
const VideoList = ({ items }) => { | |
return ( | |
<ul> | |
{items.map(item => { | |
if ('coverUrl' in item) { | |
// it's a video |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type LiveStream = { | |
name: string | |
previewUrl: string | |
} |