| REACT_APP_BASE_API_URL=https://portalgatewayapi-q1.bullioninternational.info/ | |||||
| REACT_APP_BASE_API_URL='http://localhost:3333' |
| { | |||||
| "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/*" | |||||
| } | |||||
| }, | |||||
| ] | |||||
| } | |||||
| import React, {useState} from 'react'; | import React, {useState} from 'react'; | ||||
| import { useTranslation } from 'react-i18next'; | 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 { prices, beds, types, lifeStyles } from '../../constants/filters'; | ||||
| import CreateScrapeRequestDto from '../../dtos/CreateScrapeRequestDto' | |||||
| import {sendNewRequest} from '../../store/actions/scrapeRequest/newScrapeActions' | |||||
| import './CreateScrapeRequest.scss' | import './CreateScrapeRequest.scss' | ||||
| const CreateScrapeRequest = () => { | const CreateScrapeRequest = () => { | ||||
| const dispatch = useDispatch(); | |||||
| const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
| const [inputLocation, setLocation] = useState('') | const [inputLocation, setLocation] = useState('') | ||||
| const [priceFilter, setPriceFilter] = useState('') | const [priceFilter, setPriceFilter] = useState('') | ||||
| function handleSubmit (event){ | function handleSubmit (event){ | ||||
| event.preventDefault() | event.preventDefault() | ||||
| console.log(inputLocation); | 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 ( | return ( | ||||
| <div className="card card-primary"> | <div className="card card-primary"> |
| 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; |
| setCookie: '/affiliate/picture', | setCookie: '/affiliate/picture', | ||||
| setFingerprint: '/affiliate/fingerprint', | setFingerprint: '/affiliate/fingerprint', | ||||
| }, | }, | ||||
| scrapes: | |||||
| { | |||||
| setScrape: '/scrapes' | |||||
| } | |||||
| }; | }; |
| baseURL: process.env.REACT_APP_BASE_API_URL, | baseURL: process.env.REACT_APP_BASE_API_URL, | ||||
| headers: { | headers: { | ||||
| 'Content-Type': 'application/json', | 'Content-Type': 'application/json', | ||||
| 'Access-Control-Allow-Origin': '*', | |||||
| }, | }, | ||||
| withCredentials: true, | withCredentials: true, | ||||
| paramsSerializer: (params) => | paramsSerializer: (params) => |
| 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); | |||||
| } |
| export const SEND_REQUEST = 'SEND_REQUEST'; |
| import { | |||||
| SEND_REQUEST | |||||
| } from './newRequestActionConstants'; | |||||
| export const sendNewRequest = (payload) => ({ | |||||
| type: SEND_REQUEST, | |||||
| payload, | |||||
| }); |
| import { all } from 'redux-saga/effects'; | import { all } from 'redux-saga/effects'; | ||||
| import loginSaga from './loginSaga'; | import loginSaga from './loginSaga'; | ||||
| import scraperSaga from './scraperSaga'; | |||||
| export default function* rootSaga() { | export default function* rootSaga() { | ||||
| yield all([ | yield all([ | ||||
| loginSaga(), | loginSaga(), | ||||
| scraperSaga() | |||||
| ]); | ]); | ||||
| } | } |
| 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) | |||||
| ]) | |||||
| } |