| @@ -1,2 +1,2 @@ | |||
| REACT_APP_BASE_API_URL=https://portalgatewayapi-q1.bullioninternational.info/ | |||
| REACT_APP_BASE_API_URL='http://localhost:3333' | |||
| @@ -0,0 +1,22 @@ | |||
| { | |||
| "version": "0.2.0", | |||
| "configurations": [ | |||
| { | |||
| "type": "chrome", | |||
| "request": "launch", | |||
| "name": "Debug in Chrome", | |||
| "url": "http://localhost:3000", | |||
| "webRoot": "${workspaceRoot}", | |||
| "runtimeArgs": [ | |||
| "--disable-web-security", | |||
| "--ignore-certificate-errors" | |||
| ], | |||
| "sourceMaps": true, | |||
| "sourceMapPathOverrides": { | |||
| "webpack:///./dist/applications/*": "${workspaceRoot}/src/*" | |||
| } | |||
| }, | |||
| ] | |||
| } | |||
| @@ -1,11 +1,14 @@ | |||
| import React, {useState} from 'react'; | |||
| import { useTranslation } from 'react-i18next'; | |||
| import Select from 'react-select' | |||
| import Select from 'react-select'; | |||
| import { useDispatch } from "react-redux"; | |||
| import { prices, beds, types, lifeStyles } from '../../constants/filters'; | |||
| import CreateScrapeRequestDto from '../../dtos/CreateScrapeRequestDto' | |||
| import {sendNewRequest} from '../../store/actions/scrapeRequest/newScrapeActions' | |||
| import './CreateScrapeRequest.scss' | |||
| const CreateScrapeRequest = () => { | |||
| const dispatch = useDispatch(); | |||
| const { t } = useTranslation(); | |||
| const [inputLocation, setLocation] = useState('') | |||
| const [priceFilter, setPriceFilter] = useState('') | |||
| @@ -30,11 +33,9 @@ const CreateScrapeRequest = () => { | |||
| function handleSubmit (event){ | |||
| event.preventDefault() | |||
| console.log(inputLocation); | |||
| console.log(priceFilter); | |||
| console.log(bedFilter); | |||
| console.log(typeFilter); | |||
| console.log(lifeStyleFilter); | |||
| let newRequest = new CreateScrapeRequestDto(inputLocation, priceFilter.value, bedFilter.value, typeFilter.value, lifeStyleFilter.value) | |||
| console.log(newRequest); | |||
| dispatch(sendNewRequest(newRequest)) | |||
| } | |||
| return ( | |||
| <div className="card card-primary"> | |||
| @@ -0,0 +1,11 @@ | |||
| class CreateScrapeRequestDto { | |||
| constructor(location, price, beds, type, lifeStyle ) | |||
| { | |||
| this.location = location; | |||
| this.price = price; | |||
| this.beds = beds; | |||
| this.type = type; | |||
| this.lifeStyle = lifeStyle; | |||
| } | |||
| } | |||
| export default CreateScrapeRequestDto; | |||
| @@ -153,4 +153,8 @@ export default { | |||
| setCookie: '/affiliate/picture', | |||
| setFingerprint: '/affiliate/fingerprint', | |||
| }, | |||
| scrapes: | |||
| { | |||
| setScrape: '/scrapes' | |||
| } | |||
| }; | |||
| @@ -5,6 +5,7 @@ const request = axios.create({ | |||
| baseURL: process.env.REACT_APP_BASE_API_URL, | |||
| headers: { | |||
| 'Content-Type': 'application/json', | |||
| 'Access-Control-Allow-Origin': '*', | |||
| }, | |||
| withCredentials: true, | |||
| paramsSerializer: (params) => | |||
| @@ -0,0 +1,9 @@ | |||
| import apiEndpoints from './apiEndpoints'; | |||
| import {postRequest } from './index'; | |||
| export const sendRequest = (payload) => { | |||
| console.log('TRY TO SEND'); | |||
| console.log(payload) | |||
| postRequest(apiEndpoints.scrapes.setScrape, payload); | |||
| } | |||
| @@ -0,0 +1 @@ | |||
| export const SEND_REQUEST = 'SEND_REQUEST'; | |||
| @@ -0,0 +1,8 @@ | |||
| import { | |||
| SEND_REQUEST | |||
| } from './newRequestActionConstants'; | |||
| export const sendNewRequest = (payload) => ({ | |||
| type: SEND_REQUEST, | |||
| payload, | |||
| }); | |||
| @@ -1,8 +1,9 @@ | |||
| import { all } from 'redux-saga/effects'; | |||
| import loginSaga from './loginSaga'; | |||
| import scraperSaga from './scraperSaga'; | |||
| export default function* rootSaga() { | |||
| yield all([ | |||
| loginSaga(), | |||
| scraperSaga() | |||
| ]); | |||
| } | |||
| @@ -1,2 +1,21 @@ | |||
| import { all, call, put, takeLatest } from '@redux-saga/core/effects'; | |||
| import { all, call, takeLatest } from '@redux-saga/core/effects'; | |||
| import { | |||
| sendRequest | |||
| } from '../../request/sendScrapeRequest'; | |||
| import {SEND_REQUEST} from '../actions/scrapeRequest/newRequestActionConstants'; | |||
| function* sendNewRequest({payload}){ | |||
| try { | |||
| const { data } = yield call(sendRequest, payload); | |||
| console.log(data); | |||
| } | |||
| catch(e){ | |||
| console.log(e); | |||
| } | |||
| } | |||
| export default function* scraperSaga() { | |||
| yield all([ | |||
| takeLatest(SEND_REQUEST, sendNewRequest) | |||
| ]) | |||
| } | |||