Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
customPorpTypes.js file added that would hold all propType validations
  • Loading branch information
hasibsahibzada committed Apr 9, 2017
commit cf13cfd4076476eb5cbf630a30bc5ce13e0e8576
64 changes: 26 additions & 38 deletions src/components/Verse/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import * as customPropTypes from 'customPropTypes';
import Link from 'react-router/lib/Link';
import Element from 'react-scroll/lib/components/Element';
import { connect } from 'react-redux';
Expand All @@ -25,44 +26,6 @@ const Share = Loadable({
});

class Verse extends Component {
static propTypes = {
isSearched: PropTypes.bool,
verse: verseType.isRequired,
chapter: surahType.isRequired,
bookmarked: PropTypes.bool, // TODO: Add this for search
bookmarkActions: PropTypes.shape({
isLoaded: PropTypes.func.isRequired,
load: PropTypes.func.isRequired,
addBookmark: PropTypes.func.isRequired,
removeBookmark: PropTypes.func.isRequired,
}),
mediaActions: PropTypes.shape({
setMedia: PropTypes.func.isRequired,
removeMedia: PropTypes.func.isRequired,
}),
audioActions: PropTypes.shape({
pause: PropTypes.func.isRequired,
setAyah: PropTypes.func.isRequired,
play: PropTypes.func.isRequired,
setCurrentWord: PropTypes.func.isRequired,
}), // not required because in search it is not.
match: PropTypes.arrayOf(matchType),
isPlaying: PropTypes.bool,
isAuthenticated: PropTypes.bool,
tooltip: PropTypes.string,
currentWord: PropTypes.number, // gets passed in an integer, null by default
iscurrentVerse: PropTypes.bool,
currentVerse: PropTypes.string,
userAgent: PropTypes.func,
audio: PropTypes.number.isRequired,
loadAudio: PropTypes.func.isRequired
};


static defaultProps = {
currentWord: null,
isSearched: false
};

// TODO: Should this belong here?
componentDidMount() {
Expand Down Expand Up @@ -340,4 +303,29 @@ class Verse extends Component {
}
}

Verse.propTypes = {
isSearched: PropTypes.bool,
verse: verseType.isRequired,
chapter: surahType.isRequired,
bookmarked: PropTypes.bool, // TODO: Add this for search
bookmarkActions: customPropTypes.bookmarkActions,
mediaActions: customPropTypes.mediaActions,
audioActions: customPropTypes.audioActions,
match: customPropTypes.match,
isPlaying: PropTypes.bool,
isAuthenticated: PropTypes.bool,
tooltip: PropTypes.string,
currentWord: PropTypes.number, // gets passed in an integer, null by default
iscurrentVerse: PropTypes.bool,
currentVerse: PropTypes.string,
userAgent: PropTypes.func,
audio: PropTypes.number.isRequired,
loadAudio: PropTypes.func.isRequired
};

Verse.defaultProps = {
currentWord: null,
isSearched: false
};

export default connect(() => ({}), { loadAudio })(Verse);
49 changes: 49 additions & 0 deletions src/customPropTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { PropTypes } from 'react';

export const bookmarkActions = PropTypes.shape({
isLoaded: PropTypes.func.isRequired,
load: PropTypes.func.isRequired,
addBookmark: PropTypes.func.isRequired,
removeBookmark: PropTypes.func.isRequired
});

export const mediaActions = PropTypes.shape({
setMedia: PropTypes.func.isRequired,
removeMedia: PropTypes.func.isRequired
});

export const audioActions = PropTypes.shape({
pause: PropTypes.func.isRequired,
setAyah: PropTypes.func.isRequired,
play: PropTypes.func.isRequired,
setCurrentWord: PropTypes.func.isRequired,
});

export const language = PropTypes.shape({
beta: PropTypes.bool,
direction: PropTypes.string.isRequired,
english: PropTypes.string.isRequired,
esAnalyzerDefault: PropTypes.string,
languageCode: PropTypes.string.isRequired,
priority: PropTypes.number.isRequired,
unicode: PropTypes.string,
});

export const matchType = PropTypes.shape({
score: PropTypes.number.isRequired,
text: PropTypes.string.isRequired,
languageCode: PropTypes.string.isRequired,
subType: PropTypes.string.isRequired,
cardinalityType: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
resourceId: PropTypes.number.isRequired,
description: PropTypes.string,
language: language.isRequired,
sourceId: PropTypes.number.isRequired,
type: PropTypes.string.isRequired,
authorId: PropTypes.number.isRequired,
slug: PropTypes.string.isRequired,
isAvailable: PropTypes.bool
});

export const match = PropTypes.arrayOf(matchType);