2015-07-27 20:49:37 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
class Api extends React.Component {
|
|
|
|
|
|
|
|
static categories() {
|
|
|
|
return $.get(config.api + 'all-categories');
|
|
|
|
}
|
|
|
|
|
2016-02-23 13:27:31 +01:00
|
|
|
static items(type, category, filterBy) {
|
|
|
|
return $.get(config.api + type + '-items/' + category + '/' + filterBy);
|
2015-07-28 14:57:41 +02:00
|
|
|
}
|
|
|
|
|
2015-07-27 20:49:37 +02:00
|
|
|
static categoryItems(category) {
|
2015-07-28 20:50:39 +02:00
|
|
|
return $.get(config.api + 'category-items/' + category + '/' + this.usersFilterFor(category) + '/' + config.loadingItems);
|
|
|
|
}
|
|
|
|
|
|
|
|
static moreCategoryItems(category, currentLoaded) {
|
|
|
|
return $.get(config.api + 'more-category-items/' + category.id + '/' + this.usersFilterFor(category.slug) + '/' + config.loadingItems + '/' + currentLoaded);
|
2015-07-27 20:49:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static usersFilterFor(category) {
|
|
|
|
if( ! localStorage.getItem('category-' + category)) {
|
|
|
|
localStorage.setItem('category-' + category, 'seen');
|
|
|
|
}
|
|
|
|
|
|
|
|
return localStorage.getItem('category-' + category);
|
|
|
|
}
|
|
|
|
|
|
|
|
static changeUsersFilterFor(category, type) {
|
|
|
|
localStorage.setItem('category-' + category, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static search(type, value) {
|
|
|
|
return $.get(config.api + 'search/' + type + '/' + value);
|
|
|
|
}
|
|
|
|
|
2015-07-28 19:05:15 +02:00
|
|
|
static addItem(data) {
|
|
|
|
return $.post(config.api + 'new', {data, _token: $('meta[name="csrf_token"]').attr('content')});
|
|
|
|
}
|
|
|
|
|
2015-07-27 20:49:37 +02:00
|
|
|
/*static searchTMDBByID(id) {
|
|
|
|
return $.get(config.api + 'search/tmdb/id/' + id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static searchItemBySlug(slug) {
|
|
|
|
return $.get(config.api + 'item/' + slug)
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Api;
|