stable first version

This commit is contained in:
2018-09-26 11:47:16 +02:00
parent 924e126767
commit e695b8dfb2
392 changed files with 110 additions and 65 deletions
+15
View File
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
}
]
}
+21 -26
View File
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from "react-redux"; import { connect } from "react-redux";
import fetch from 'isomorphic-unfetch' import fetch from 'isomorphic-unfetch'
import api from '../../data/api'
import GriddleCustomTable from "../organisms/GriddleCustomTableComponent"; import GriddleCustomTable from "../organisms/GriddleCustomTableComponent";
@@ -24,39 +26,32 @@ class Grid extends Component {
filterText: "" filterText: ""
}; };
async componentDidMount() { async componentDidMount() {
// this.props.fetchUserGamesRequest( // this.props.fetchUserGamesRequest(
// this.state.currentPage, // this.state.currentPage,
// this.state.pageSize // this.state.pageSize
// ); // );
var obj = { // var obj = {
method: 'GET' , // method: 'GET',
//mode : 'no-cors', // //mode : 'no-cors',
headers: { // headers: {
// 'Access-Control-Request-Headers': 'Authorization', // // 'Access-Control-Request-Headers': 'Authorization',
// 'Authorization': 'Basic amFzcGVyYWRtaW46amFzcGVyYWRtaW4=', // // 'Authorization': 'Basic amFzcGVyYWRtaW46amFzcGVyYWRtaW4=',
'Content-Type': 'application/json', // 'Content-Type': 'application/json',
'Origin': '' // 'Origin': ''
}, // },
credentials: 'include' // credentials: 'include'
}; // };
try{
const res = await fetch(`http://localhost/app_dev.php/api/ads?limit=10`,obj);
//console.log(res);
// if (!res.ok) {
// throw Error(res.statusText);
// }
const show = await res.json();
this.setState({ data:show.data});
} catch (error) try {
{ let data = await api.ads.fetchAds(10);
this.setState({ data });
} catch (error) {
console.log(error); console.log(error);
} }
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
+40 -24
View File
@@ -1,37 +1,53 @@
import fetch from 'isomorphic-unfetch' import fetch from 'isomorphic-unfetch'
//TODO: 'isomorphic-unfetch' :how to set default headers ? //TODO: 'isomorphic-unfetch' :how to set default headers ?
// var obj = { // var obj = {
// method: 'GET', // method: 'GET',
// mode: 'no-cors', // mode: 'no-cors',
// // headers: { // // headers: {
// // 'Access-Control-Request-Headers': 'Authorization', // // 'Access-Control-Request-Headers': 'Authorization',
// // 'Authorization': 'Basic amFzcGVyYWRtaW46amFzcGVyYWRtaW4=', // // 'Authorization': 'Basic amFzcGVyYWRtaW46amFzcGVyYWRtaW4=',
// // 'Content-Type': 'application/json', // // 'Content-Type': 'application/json',
// // 'Origin': '' // // 'Origin': ''
// // }, // // },
// credentials: 'include' // credentials: 'include'
// }; // };
export default { export default {
ads:{ ads: {
fetchAd: async (id) => fetchAd: async (id) => {
{
const res = await fetch(`http://localhost/app_dev.php/api/ads/${id}`) const res = await fetch(`http://localhost/app_dev.php/api/ads/${id}`)
const offre = await res.json() const offre = await res.json()
return { offre: offre.data} return { offre: offre.data }
}, },
fetchAds: async (offset,limit,order,keyword) => fetchAds: async (limit = "", order = "", keyword = "", offset = 1) => {
{ var obj = {
const url = `http://localhost/app_dev.php/api/ads`; method: 'GET',
//mode : 'no-cors',
headers: {
// 'Access-Control-Request-Headers': 'Authorization',
// 'Authorization': 'Basic amFzcGVyYWRtaW46amFzcGVyYWRtaW4=',
'Content-Type': 'application/json',
'Origin': ''
},
credentials: 'include'
};
let url = `http://localhost/app_dev.php/api/ads?offset=${offset}`;
if (limit != "") {
return await fetch( url = url + `&limit=${limit}`;
)
} }
if (order != "") {
url = url + `&order=${order}`;
}
if (keyword != "") {
url = url + `&keyword=${keyword}`;
}
const res = await fetch(url, obj);
const show = await res.json();
return show.data;
}
} }
} }
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More