Replace interfaces with Types
This commit is contained in:
parent
cb9f3ec3d1
commit
6ba958fafa
12 changed files with 45 additions and 34 deletions
|
|
@ -2,7 +2,7 @@ import React from "react";
|
|||
import Album from "./album";
|
||||
import * as interfaces from "../interfaces";
|
||||
|
||||
export default (props: AlbumList) => {
|
||||
export default (props: Props) => {
|
||||
const { albums, handleOnClick, blurred } = props;
|
||||
const classNames = blurred ? "blur" : "";
|
||||
return (
|
||||
|
|
@ -18,8 +18,8 @@ export default (props: AlbumList) => {
|
|||
);
|
||||
};
|
||||
|
||||
interface AlbumList {
|
||||
type Props = {
|
||||
albums: Array<interfaces.Album>;
|
||||
handleOnClick: Function;
|
||||
blurred: boolean;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React from "react";
|
||||
import * as interfaces from "../interfaces";
|
||||
import { Album } from "../interfaces";
|
||||
|
||||
export default (props: Album) => {
|
||||
export default (props: Props) => {
|
||||
const handleKeyPress = (e: KeyboardEvent, callback: Function) => {
|
||||
const SPACE_KEY = 32;
|
||||
const ENTER_KEY = 13;
|
||||
|
|
@ -37,7 +37,8 @@ export default (props: Album) => {
|
|||
);
|
||||
};
|
||||
|
||||
interface Album {
|
||||
album: interfaces.Album;
|
||||
type Props = {
|
||||
key: number;
|
||||
album: Album;
|
||||
handleOnClick: Function;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React from "react";
|
||||
|
||||
export default (props: FilterInput) => {
|
||||
export default (props: Props) => {
|
||||
const { value, handleOnChange } = props;
|
||||
return (
|
||||
<div>
|
||||
|
|
@ -14,7 +14,7 @@ export default (props: FilterInput) => {
|
|||
);
|
||||
};
|
||||
|
||||
interface FilterInput {
|
||||
type Props = {
|
||||
value: string;
|
||||
handleOnChange: Function;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
import React from "react";
|
||||
import { Album } from "../interfaces";
|
||||
|
||||
interface Modal {
|
||||
album: Album;
|
||||
handleOnClick: Function;
|
||||
}
|
||||
|
||||
export default (props: Modal) => {
|
||||
export default (props: Props) => {
|
||||
const handleKeyPress = (e: KeyboardEvent, callback: Function) => {
|
||||
console.log(e.charCode);
|
||||
callback();
|
||||
|
|
@ -40,3 +35,8 @@ export default (props: Modal) => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
type Props = {
|
||||
album: Album;
|
||||
handleOnClick(): void;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React from "react";
|
||||
|
||||
export default (props: SortSelect) => {
|
||||
export default (props: Props) => {
|
||||
const { value, handleOnChange } = props;
|
||||
return (
|
||||
<div hidden>
|
||||
|
|
@ -18,7 +18,7 @@ export default (props: SortSelect) => {
|
|||
);
|
||||
};
|
||||
|
||||
interface SortSelect {
|
||||
type Props = {
|
||||
value: string;
|
||||
handleOnChange: Function;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import Modal from "../components/modal";
|
||||
import { unselectAlbum } from "../actions";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import SortSelect from "../components/sort-select";
|
||||
import { setSortKey } from "../actions";
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import { LOAD_ALBUMS_OK } from "../actions";
|
||||
import { Album } from "../interfaces";
|
||||
|
||||
interface AlbumsAction {
|
||||
type Action = {
|
||||
type: string;
|
||||
payload: {
|
||||
albums: Array<Album>;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default (state: Array<Album> = [], action: AlbumsAction) => {
|
||||
export default (state: Array<Album> = [], action: Action) => {
|
||||
switch (action.type) {
|
||||
case LOAD_ALBUMS_OK:
|
||||
const { albums } = action.payload;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
import { combineReducers } from "redux";
|
||||
import albums from "./albums";
|
||||
import visibilityFilter from "./visibility-filter";
|
||||
import sortKey from "./sort-key";
|
||||
import selectedAlbum from "./selected-album";
|
||||
|
||||
export default combineReducers({
|
||||
albums,
|
||||
visibilityFilter,
|
||||
sortKey,
|
||||
selectedAlbum
|
||||
});
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
import { SELECT_ALBUM, UNSELECT_ALBUM } from "../actions";
|
||||
import { Album } from "../interfaces";
|
||||
|
||||
interface AlbumAction {
|
||||
type Action = {
|
||||
type: string;
|
||||
payload: {
|
||||
album: Album;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default (state: Object = {}, action: AlbumAction) => {
|
||||
export default (state: Object = {}, action: Action) => {
|
||||
switch (action.type) {
|
||||
case SELECT_ALBUM:
|
||||
return action.payload.album;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { SET_SORT_KEY } from "../actions";
|
||||
|
||||
interface SortKeyAction {
|
||||
type Action = {
|
||||
type: string;
|
||||
payload: {
|
||||
key: string;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default (state: string = "id", action: SortKeyAction) => {
|
||||
export default (state: string = "id", action: Action) => {
|
||||
switch (action.type) {
|
||||
case SET_SORT_KEY:
|
||||
return action.payload.key;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { SET_VISIBILITY_FILTER } from "../actions";
|
||||
|
||||
interface VisibilityFilterAction {
|
||||
type Action = {
|
||||
type: string;
|
||||
payload: {
|
||||
filter: string;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default (state: string = "", action: VisibilityFilterAction) => {
|
||||
export default (state: string = "", action: Action) => {
|
||||
switch (action.type) {
|
||||
case SET_VISIBILITY_FILTER:
|
||||
return action.payload.filter;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue