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