Commit 012d2b04 authored by Dilip Wijethunga's avatar Dilip Wijethunga

Service file update

parent c3c907c0
import Connection from "./connection.json"
import axios from "axios";
const FLASK_API = Connection.localAddress + '/api/csv/';
class CoinService {
getSavedDataCSVByCoinName(coin) {
return axios.get(FLASK_API + coin, {responseType: 'blob'})
}
}
export default new CoinService();
import React from "react";
import {Redirect} from 'react-router-dom';
import UserService from "./UserService";
const CommonCheckAuth = (Component) => {
const AuthRoute = () => {
const isAuth = !!UserService.getCurrentUser();
if (isAuth) {
return <Component />;
} else {
return <Redirect to="/Login" />;
}
};
return AuthRoute;
};
export default CommonCheckAuth;
\ No newline at end of file
......@@ -20,6 +20,10 @@ class CurrencyService {
getPredictionByCurrencyAction(currency, action) {
return axios.get(FLASK_API + '/predict/' + currency + '/' + action)
}
getSentiment(){
return axios.get(FLASK_API + '/sentiment')
}
}
export default new CurrencyService();
import axios from "axios";
import Connection from "./connection.json"
const FLASK_API = Connection.localAddress + '/auth/';
class UserService{
// User login
login(username, password){
return axios.post(FLASK_API + "signin", {
username,
password
}).then(response => {
if(response.data){
if(response.message === "Unsuccessful") {
console.log("Unsuccessful");
}else{
sessionStorage.setItem("user", JSON.stringify(response.data));
}
}
return response.data;
});
}
// User register
register(full_name, email, username, password, role, image){
return axios.post(FLASK_API + "signup", {
full_name,
username,
email,
password,
role,
image
});
}
// Get current user
getCurrentUser() {
return JSON.parse(sessionStorage.getItem('user'));
}
//Remove current user
logout() {
sessionStorage.removeItem("user");
sessionStorage.clear();
window.location.href = "/";
}
getAllUsers() {
return axios.get(Connection.localAddress + '/user');
}
}
export default new UserService();
\ No newline at end of file
{
"localAddress": "http://127.0.0.1:5000",
"localAddress": "https://cfapi-dilipwijethunga.cloud.okteto.net",
"remoteAddress" : ""
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment