redirectToGenre = (e:any) => {
console.log('redirectToGenre')
this.setState({showGenreText:true})
this.setState({tabs:'genre'})
this.setState({ hastagName: e.attributes.name })
this.setState({ isFollowing: e.attributes.is_following })
}
MostPopularGenrelistApi = async () => {
this.setState({ loader: true })
const token = await StorageProvider?.get('USER_TOKEN')
const header = {
'Content-Type': 'multipart/form-data',
token: token,
}
const requestMessage = new Message(
getName(MessageEnum.RestAPIRequestMessage),
)
this.mostgenrelistCallId = requestMessage.messageId
requestMessage.addData(
getName(MessageEnum.RestAPIResponceEndPointMessage),
configJSON.mostpopularEndPoint
)
requestMessage.addData(
getName(MessageEnum.RestAPIRequestHeaderMessage),
JSON.stringify(header),
)
requestMessage.addData(
getName(MessageEnum.RestAPIRequestMethodMessage),
configJSON.httpGetType,
)
runEngine.sendMessage(requestMessage.id, requestMessage)
return true
}
UserFollowingGenrelistApi = async () => {
this.setState({ loader: true })
const token = await StorageProvider?.get('USER_TOKEN')
const header = {
token: token,
}
const requestMessage = new Message(
getName(MessageEnum.RestAPIRequestMessage),
)
this.usergenrelistCallId = requestMessage.messageId
requestMessage.addData(
getName(MessageEnum.RestAPIResponceEndPointMessage),
configJSON.followingpopularEndPoint,
)
requestMessage.addData(
getName(MessageEnum.RestAPIRequestHeaderMessage),
JSON.stringify(header),
)
requestMessage.addData(
getName(MessageEnum.RestAPIRequestMethodMessage),
configJSON.httpGetType,
)
runEngine.sendMessage(requestMessage.id, requestMessage)
return true
}
handleGenreChangeTextList = (text: any) => {
if (text.length === 0) {
this.setState({ showsearch: false })
this.GenrelistApi()
} else if (text.length > 1) {
this.addGenre(text)
}
// console.log(' search text>>>', text)
}
addGenre = (text: any) => {
this.setState({ showsearch: true })
let text1 = text.replace('#', '')
let matched_terms: any = []
let search_term = text1
search_term = search_term.toLowerCase()
this.state.GenretagList.forEach((item: any) => {
if (item.attributes.name.toLowerCase().indexOf(search_term) !== -1) {
matched_terms.push(item)
}
this.setState({ GenretagList: matched_terms, })
})
console.log('data is in api body of genre>>.', this.state.GenretagList)
}
handleGenretxt = () => {
console.log('showGenreModal')
this.setState({showGenreModal:true})
}
_unfollowingGenre = async (e: any) => {
this.setState({ id: e, isFollowing: !this.state.isFollowing, isfollowinggenre: !this.state.isfollowinggenre })
const _token = await StorageProvider?.get('USER_TOKEN')
this.setState({ loader: true })
const header = {
token: _token,
}
const requestMessage = new Message(
getName(MessageEnum.RestAPIRequestMessage),
)
this.unfollowingGenre = requestMessage.messageId
requestMessage.addData(
getName(MessageEnum.RestAPIResponceEndPointMessage),
configJSON.getGenreApiEndPoint + `/${this.state.id}`,
)
requestMessage.addData(
getName(MessageEnum.RestAPIRequestHeaderMessage),
JSON.stringify(header),
)
requestMessage.addData(
getName(MessageEnum.RestAPIRequestMethodMessage),
configJSON.httpDeleteType,
)
runEngine.sendMessage(requestMessage.id, requestMessage)
console.log("sdsdfdsds", requestMessage)
}
_followingGenre = async (e) => {
this.setState({ id: e, isFollowing: !this.state.isFollowing, isfollowinggenre: !this.state.isfollowinggenre })
const token = await StorageProvider?.get('USER_TOKEN')
const header = {
'Content-Type': 'multipart/form-data',
token,
};
var formdata = new FormData();
formdata.append("data[genre_ids][]", e);
const requestMessage = new Message(getName(MessageEnum.RestAPIRequestMessage));
this.followingGenre = requestMessage.messageId;
requestMessage.addData(
getName(MessageEnum.RestAPIResponceEndPointMessage),
configJSON.getGenreApiEndPoint,
);
requestMessage.addData(
getName(MessageEnum.RestAPIRequestHeaderMessage),
JSON.stringify(header)
);
requestMessage.addData(
getName(MessageEnum.RestAPIRequestBodyMessage),
formdata
);
requestMessage.addData(
getName(MessageEnum.RestAPIRequestMethodMessage),
configJSON.httpPostType
);
runEngine.sendMessage(requestMessage.id, requestMessage);
}