Commit 65ab2c12 authored by Madhura Mihiranga H.N. IT19177410's avatar Madhura Mihiranga H.N. IT19177410

Merge branch 'master' into IT19048642

parents fd43dc14 cb1840bb
......@@ -10,6 +10,7 @@ const Pharmacy = require("./src/api/pharmacy.api");
const GroceryAPI = require("./src/api/grocery.api")
const UserAPI = require("./src/api/user.api")
const SubscriptionAPI = require("./src/api/subscription.api")
const AreaDetailsAPI = require("./src/api/areaDetails.api")
const port = process.env.PORT || 5000;
......@@ -33,6 +34,7 @@ app.use("/pharmacy",Pharmacy());
app.use("/grocery", GroceryAPI());
app.use("/user", UserAPI());
app.use("/subscription", SubscriptionAPI());
app.use("/areaDetails", AreaDetailsAPI());
app.listen(port, () => {
......
const express = require('express');
const router = express.Router();
const AreaDetailsController = require('../controller/areaDetails.controller');
module.exports = function () {
router.post('/getAreaAllAttractionPlaces', AreaDetailsController.getAreaAllAttractionPlaces);
router.post('/getAreaTransportationModesCount', AreaDetailsController.getAreaTransportationModesCount);
router.post('/getAreaNearByHotels', AreaDetailsController.getAreaNearByHotels);
router.post('/getAreaBusinessCount', AreaDetailsController.getAreaBusinessCount);
router.post('/getAreaDistanceToCity', AreaDetailsController.getAreaDistanceToCity);
router.post('/getAreaWorkPlacesCount', AreaDetailsController.getAreaWorkPlacesCount);
router.post('/getAreaEducationRelatedPlacesCount', AreaDetailsController.getAreaEducationRelatedPlacesCount);
router.post('/getAreaShoppingMallsCount', AreaDetailsController.getAreaShoppingMallsCount);
router.post('/getAreaRestaurentCount', AreaDetailsController.getAreaRestaurentCount);
return router;
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ module.exports = function () {
router.put('/updateUser', UserController.updateUser);
router.get('/:id', UserController.getUserById);
router.delete('/:id', UserController.deleteUser);
router.post('/search/:search', UserController.searchUser);
router.get('/search/:search', UserController.searchUser);
return router;
}
......@@ -218,7 +218,12 @@ const validateUser = async (req, res) => {
fullName: user.fullName,
}, process.env.JWT_SECRET)
res.status(200).send({ user: token, userDetails: user });
const subscriptionDetails = {
}
res.status(200).send({ user: token ,userDetails:user});
} else {
console.log("Credentials Does Not Matched");
res.status(500).send({ message: "Credentials Does Not Matched" });
......@@ -238,6 +243,7 @@ const validateUser = async (req, res) => {
const getAllUser = async (req, res) => {
await User.find()
.then((data) => {
console.log(data);
res.status(200).send(data);
})
.catch(error => {
......@@ -316,21 +322,25 @@ const getUserByEmail = async (req, res) => {
// Update User
const updateUser = async (req, res) => {
console.log("Call Update User",req.body);
if (req.body) {
let count = req.body.predictionCount;
let countLimit = req.body.predictionCountLimit;
if (count == countLimit) {
req.body.subscriptionStatus = "Over";
// if(count == countLimit && req.body.subscriptionStatus==="Active"){
// req.body.subscriptionStatus = "Over";
// }
try{
const data = await User.findByIdAndUpdate({ _id: req.body.id }, req.body)
console.log(data);
res.status(200).send(data);
}
await User.updateOne({ _id: req.params.id }, { $set: req.body }, (err, result) => {
if (err) {
console.log(err);
res.status(500).send(err);
} else {
res.status(200).send({ message: "User Updated Successfully" });
console.log(result);
}
})
catch(err){
console.log(err);
res.status(500).send(err);
}
}
}
......@@ -352,7 +362,7 @@ const deleteUser = async (req, res) => {
// Search User
const searchUser = async (req, res) => {
try {
const data = await User.find({ $text: { $search: req.params.search } });
const data = await User.find({ email: { $regex: req.params.search, $options: 'i' } });
if (!data) {
res.status(404).send({ message: "User Not Found" });
} else {
......@@ -364,6 +374,10 @@ const searchUser = async (req, res) => {
}
}
// pagination
const pagination = async (req, res) => {
const page = req.params.page;
......@@ -392,6 +406,24 @@ const pagination = async (req, res) => {
}
}
//upload User Profile Image Cloudinary
// const uploadProfileImage = async (req, res) => {
// try {
// const fileStr = req.body.data;
// const uploadResponse = await cloudinary.uploader.upload(fileStr, {
// upload_preset: 'ml_default',
// });
// console.log(uploadResponse);
// res.status(200).send(uploadResponse);
// } catch (err) {
// console.log(err);
// res.status(500).send(err);
// }
// }
module.exports = {
createUser,
getAllUser,
......
......@@ -7,9 +7,10 @@ const UserSchema = new mongoose.Schema({
isVerified: { type: Boolean, required: false },
googleUser: { type: Boolean, required: false },
emailToken: { type: String, required: false },
password: { type: String, required: true },
password: { type: String, required: true },
predictionCount: { type: Number, required: false },
predictionCountLimit: { type: Number, required: false },
compareCount: { type: Number, required: false },
locationPredictCount: { type: Number, required: false },
paymentType: { type: String, required: true },
paymentID: { type: String, required: true },
subscriptionPlan: { type: String, required: false },
......@@ -17,7 +18,6 @@ const UserSchema = new mongoose.Schema({
subscriptionDate: { type: String, required: false },
subscriptionEndDate: { type: String, required: false },
subscriptionStatus: { type: String, required: false },
subscriptionAmount: { type: Number, required: false },
},{
timestamps:true
......
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#3c5d5a",
"activityBar.background": "#3c5d5a",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#251927",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#3c5d5a",
"statusBar.background": "#283e3c",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#3c5d5a",
"statusBarItem.remoteBackground": "#283e3c",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#283e3c",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#283e3c99",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#283e3c"
}
\ No newline at end of file
This diff is collapsed.
......@@ -27,6 +27,7 @@
"jspdf": "^2.5.1",
"jwt-decode": "^3.1.2",
"mdb-react-ui-kit": "^4.2.0",
"moment": "^2.29.4",
"react": "^18.1.0",
"react-animated-3d-card": "^1.0.2",
"react-chartjs-2": "^4.3.1",
......
......@@ -13,6 +13,7 @@ import Map from './components/Map';
import Loader from './components/Loader'
import Footer from './components/Footer';
import themeReducer from "./features/theme";
import factorReducer from "./features/factorDetails";
import businessReducer from "./features/business";
import headerReducer from "./features/header";
import userReducer from "./features/user";
......@@ -32,13 +33,16 @@ import MultipleResultG from './components/Grocery Input/MultipleResultG'
import FactorDetails from './components/FactorDetails';
import AdminDashboard from './components/Admin/AdminDashboard';
import GroceryTips from './components/Grocery Input/groceryTips'
import UserSubscriptionPlan from './components/User/UserSubscriptionPlan';
import ResultsFD from './components/ResultsFD';
const store = configureStore({
reducer: {
theme: themeReducer,
business: businessReducer,
header: headerReducer,
user: userReducer
user: userReducer,
factorDetails: factorReducer
},
});
......@@ -68,9 +72,12 @@ function App() {
<Route path="/locationBasedPredict" element={<LocationBasedPredict />} />
<Route path="/pmultipleResult" element={<MultipleResultP/>} />
<Route path="/multipleResultG" element={<MultipleResultG/>} />
<Route path="/Factor%20Details" element={<FactorDetails />} />
<Route path="/AdminDashboard" element={<AdminDashboard />} />
<Route path="/GroceryTips" element={<GroceryTips />} />
<Route path="/Area%20Analysis" element={<FactorDetails />} />
<Route path="/AdminDashboard" element={<AdminDashboard />} />
<Route path="/UserSubscriptionPlan" element={<UserSubscriptionPlan />} />
<Route path="/ResultsFactorDetails" element={<ResultsFD />} />
</Route>
</Routes>
<Footer />
......
const SUBSCRIPTION_PLAN = [
{
"id": 1,
"plan": "Free",
"price": 0,
"type": "month",
"predictionCount": 5,
"compareCount": 3,
"locationPredictCount": 10,
"description": "For most businesses that want to optimize web queries 1",
"features": [
"Unlimited Factors Based Predictions",
"Free Five Predictions",
"Free Three Comparisons",
"Free Ten Location Predictions",
]
},
{
"id": 2,
"plan": "Basic",
"price": 15,
"type": "month",
"predictionCount": 30,
"compareCount": 10,
"locationPredictCount": 20,
"description": "For most businesses that want to optimize web queries 2",
"features": [
"Unlimited Factors Based Predictions",
"Free Thirty Predictions",
"Free Ten Comparisons",
"Free Twenty Location Predictions",
]
},
{
"id": 3,
"plan": "Popular",
"price": 50,
"type": "month",
"predictionCount": 50,
"compareCount": 20,
"locationPredictCount": 50,
"description": "For most businesses that want to optimize web queries 3",
"features": [
"Unlimited Factors Based Predictions",
"Free Fifty Predictions",
"Free Twenty Comparisons",
"Free Fifty Location Predictions",
]
},
{
"id": 4,
"plan": "Premium",
"price": 80,
"type": "month",
"predictionCount": 100,
"compareCount": 30,
"locationPredictCount": 80,
"description": "For most businesses that want to optimize web queries 4",
"features": [
"Unlimited Factors Based Predictions",
"Free Hundred Predictions",
"Free Thirty Comparisons",
"Free Eighty Location Predictions",
]
},
{
"id": 5,
"plan": "Intro",
"price": 300,
"type": "year",
"predictionCount": 250,
"compareCount": 100,
"locationPredictCount": 100,
"description": "For most businesses that want to optimize web queries 5",
"features": [
"Unlimited Factors Based Predictions",
"Free Two Hundred Fifty Predictions",
"Free Hundred Comparisons",
"Free Hundred Location Predictions",
]
}
,{
"id": 6,
"plan": "Pro",
"price": 400,
"type": "year",
"predictionCount": 350,
"compareCount": 100,
"locationPredictCount": 100,
"description": "For most businesses that want to optimize web queries 6",
"features": [
"Unlimited Factors Based Predictions",
"Free Three Hundred Fifty Predictions",
"Free Hundred Comparisons",
"Free Hundred Location Predictions",
]
},
{
"id": 7,
"plan": "Flash",
"price": 600,
"type": "year",
"predictionCount": 450,
"compareCount": 200,
"locationPredictCount": 150,
"description": "For most businesses that want to optimize web queries 7",
"features": [
"Unlimited Factors Based Predictions",
"Free Four Hundred Fifty Predictions",
"Free Two Hundred Comparisons",
"Free One Hundred Fifty Location Predictions",
]
},
{
"id": 8,
"plan": "Ultra",
"price": 1500,
"type": "year",
"predictionCount": 800,
"compareCount": 300,
"locationPredictCount": 300,
"description": "For most businesses that want to optimize web queries 8",
"features": [
"Unlimited Factors Based Predictions",
"Free Eight Hundred Predictions",
"Free Three Hundred Comparisons",
"Free Three Hundred Location Predictions",
]
},
]
export default SUBSCRIPTION_PLAN;
\ No newline at end of file
......@@ -19,6 +19,7 @@ import { darkMode, lightMode } from "../features/theme";
import { makeStyles } from '@mui/styles';
import { useDispatch } from "react-redux";
import { useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
function stringToColor(string) {
let hash = 0;
......@@ -88,7 +89,7 @@ const useStyles = makeStyles((theme) => ({
padding: "10px 20px",
cursor: "pointer",
'&:hover': {
backgroundColor: themeColor => themeColor.status == 'dark' ? '#3e3d3d' : '#e3e3e3',
backgroundColor: themeColor => themeColor.status == 'dark' ? '#3e3d3d' : '#e3e3e3',cursor: "pointer",
}
},
themeSwtich: {
......@@ -100,6 +101,7 @@ const useStyles = makeStyles((theme) => ({
}));
export default function AccountMenu({ name, email, onLogOut }) {
let navigate = useNavigate();
const themeColor = useSelector((state) => state.theme.value);
const dispatch = useDispatch();
const classes = useStyles(themeColor);
......@@ -230,7 +232,9 @@ export default function AccountMenu({ name, email, onLogOut }) {
Theme Mode<sup style={{ fontStyle: 'italic', fontSize: '12px', marginLeft: '-5px' , marginBottom: '-3px' }}>({themeColor.status})</sup> <Android12Switch sx={{ m: 1 }} checked={switchState} onChange={handleChange} />
</div>
<Divider sx={{ borderColor: '#b5b5b51f' }} />
<div className={classes.menuItems}>
<div className={classes.menuItems}
onClick={() => {navigate('UserSubscriptionPlan')}}
>
<ListItemIcon>
<IoIosGitBranch style={{ color: '#956cd0', fontSize: "25px", marginLeft: 10 }} />
</ListItemIcon>
......
......@@ -26,6 +26,7 @@ import Dashboard from './Dashboard';
import Subscriptions from './Subscriptions';
import {TfiUser} from 'react-icons/tfi';
import {BsColumns} from 'react-icons/bs';
import { Logout } from '@mui/icons-material';
const drawerWidth = 240;
const openedMixin = (theme) => ({
......@@ -126,6 +127,11 @@ const AdminDashboard = () => {
dispatch(addHeader({ 'header': false, 'footer': false }))
}, []);
const onLogOut = () => {
localStorage.removeItem('token');
dispatch(Logout());
}
return (
<Box sx={{ display: "flex" ,boxSizing:'border-box'}}>
<CssBaseline />
......@@ -206,7 +212,7 @@ const AdminDashboard = () => {
>
<IoLogOutOutline/>
</ListItemIcon>
<ListItemText primary={"Logout"} sx={{ opacity: open ? 1 : 0 }} />
<ListItemText primary={"Logout"} sx={{ opacity: open ? 1 : 0 }} onClick={onLogOut} />
</ListItemButton>
</ListItem>
</List>
......
import * as React from 'react';
import Paper from '@mui/material/Paper';
import {
ArgumentAxis,
ValueAxis,
Chart,
LineSeries,
} from '@devexpress/dx-react-chart-material-ui';
const data = [
{ argument: 1, value: 10 },
{ argument: 2, value:50 },
{ argument: 3, value: 30 },
{ argument: 4, value: 30 },
];
const PredictionChart =() => (
<Paper>
<Chart
data={data}
>
<ArgumentAxis />
<ValueAxis />
<LineSeries valueField="value" argumentField="argument" />
</Chart>
</Paper>
);
export default PredictionChart;
\ No newline at end of file
import React, { useEffect, useState } from "react";
import { jsPDF } from "jspdf";
import api from "../../api";
export const ReportDownload = ({ids,setDataToReport}) => {
const [dataReport, setDataReport] = useState([]);
useEffect(() => {
setDataToReport(false)
for(let i=0;i<ids.length;i++){
api.get(`/user/${ids[i]}`).then((response) => {
console.log(response.data)
setDataReport(response.data);
});
}
console.log(dataReport)
handleDownload(dataReport);
}, [ids]);
const doc = new jsPDF();
const handleDownload = (data) => {
console.log(data.length)
for (let i = 0; i < data.length; i++) {
doc.setFontSize(22);
doc.setFont("courier", "bolditalic");
doc.text(
"Hotel Success Precentage Prediction",
105,
8,
null,
null,
"center"
);
doc.setFont("helvetica", "normal");
doc.setFontSize(16);
doc.text(`Type : ${data.value[0].type}`, 20, 30);
doc.text(`Latitude : ${data.value[0].latitude}`, 20, 40);
doc.text(`Longitude : ${data.value[0].longitude}`, 20, 50);
doc.text(
`AttractionPlaces Count : ${data.value[0].locationFeatures.attractionPlacesCount}`,
20,
60
);
doc.text(
`Transportation Modes Count : ${data.value[0].locationFeatures.transportationModesCount}`,
20,
70
);
doc.text(
`Nearby Hotel Review Count : ${data.value[0].locationFeatures.nearByHotelReviewCount}`,
20,
80
);
doc.setFont("helvetica", "bold");
doc.text(`Final Prediction : ${data.value[0].ml_result}%`, 20, 90);
doc.save("Report.pdf");
}
}
};
......@@ -86,12 +86,6 @@ const headCells = [
id: "id",
numeric: true,
disablePadding: true,
label: "Subscription ID",
},
{
id: "uid",
numeric: false,
disablePadding: true,
label: "User ID",
},
{
......@@ -119,10 +113,22 @@ const headCells = [
label: "Subscription End Date",
},
{
id: "subscriptionAmount",
id: "subscriptionEndDate",
numeric: true,
disablePadding: false,
label: "Subscription End Date",
},
{
id: "subscriptionEndDate",
numeric: true,
disablePadding: false,
label: "Subscription End Date",
},
{
id: "subscriptionEndDate",
numeric: true,
disablePadding: false,
label: "Subscription Amount",
label: "Subscription End Date",
},
{
id: "subscriptionStatus",
......@@ -280,7 +286,7 @@ const Subscriptions = () => {
useEffect(() => {
api.get("/subscription/").then((response) => {
api.get("/user/").then((response) => {
console.log(response.data);
setRows(response.data);
});
......@@ -400,7 +406,6 @@ const Subscriptions = () => {
>
{row._id}
</TableCell>
<TableCell align="center">{row.userID}</TableCell>
<TableCell align="center">{row.paymentID}</TableCell>
<TableCell align="center">{row.paymentType}</TableCell>
<TableCell align="center">
......@@ -409,9 +414,6 @@ const Subscriptions = () => {
<TableCell align="center">
{row.subscriptionEndDate}
</TableCell>
<TableCell align="center">
{row.subscriptionAmount}
</TableCell>
<TableCell align="center">
{row.subscriptionStatus}
</TableCell>
......
This diff is collapsed.
......@@ -12,19 +12,20 @@ const Transition = React.forwardRef(function Transition(props, ref) {
return <Slide direction="up" ref={ref} {...props} />;
});
export default function AlertDialogSlide({ open, setOpen, title, content, setHandleConfirm }) {
export default function AlertDialogSlide({ open, setOpen, title, content, handleConfirmDailog }) {
// const [open, setOpen] = React.useState(false);
const handleCloseConfrim = () => {
handleConfirmDailog(true);
setOpen(false);
setHandleConfirm(true);
};
const handleClose = () => {
handleConfirmDailog(false);
setOpen(false);
setHandleConfirm(false);
};
......@@ -37,9 +38,17 @@ export default function AlertDialogSlide({ open, setOpen, title, content, setHan
onClose={handleClose}
aria-describedby="alert-dialog-slide-description"
>
<DialogTitle>{title}</DialogTitle>
<DialogTitle sx={{
color: "#231D4F",
fontSize: "20px",
fontWeight: "600",
whiteSpace: "nowrap",
}}>{title}</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-slide-description">
<DialogContentText id="alert-dialog-slide-description" sx={{color: "#888888",
fontSize: "14px",
fontWeight: "400",
}}>
{content}
</DialogContentText>
</DialogContent>
......@@ -57,5 +66,5 @@ AlertDialogSlide.propTypes = {
setOpen: PropTypes.func,
title: PropTypes.string,
content: PropTypes.string,
setHandleConfirm: PropTypes.func,
handleConfirmDailog: PropTypes.func,
}
......@@ -147,10 +147,7 @@ export default function SignIn() {
const [error, setError] = React.useState(false);
const [errorMsg, setErrorMsg] = React.useState("Error");
useEffect(() => {
console.log("userDetails", userDetails);
}, [userDetails]);
useEffect(() => {
function start() {
......@@ -188,15 +185,16 @@ export default function SignIn() {
role: 'user',
emailToken: null,
isVerified: true,
predictionCount : 0,
predictionCountLimit : 0,
subscriptionType : 'none',
predictionCount : 5,
compareCount : 3,
locationPredictCount:10,
subscriptionType: 'Monthly',
paymentType: 'none',
paymentID: 'none',
subscriptionPlan: 'none',
subscriptionEndDate : 'none',
subscriptionDate : 'none',
subscriptionStatus : 'none',
subscriptionPlan: 'Free',
subscriptionEndDate : '15-12-2022',
subscriptionDate : '15-11-2022',
subscriptionStatus : 'Active',
}
......@@ -212,6 +210,7 @@ export default function SignIn() {
console.log("result", result)
let decodedToken = jwt_decode(result.data.user)
localStorage.setItem('token', result.data.user)
localStorage.setItem('userInfo', JSON.stringify(result.data.userDetails))
dispatch(login({ 'fullName': decodedToken.fullName, 'email': decodedToken.email }))
dispatch(userInfo(result.data.userDetails))
dispatch(addHeader({ 'header': true, 'footer': true }))
......@@ -236,6 +235,7 @@ export default function SignIn() {
console.log("decodedToken", decodedToken)
localStorage.setItem('token', result.data.user)
localStorage.setItem('userInfo', JSON.stringify(result.data.userDetails))
dispatch(login({ 'fullName': decodedToken.fullName, 'email': decodedToken.email }))
dispatch(userInfo(result.data.userDetails))
dispatch(addHeader({ 'header': true, 'footer': true }))
......@@ -288,15 +288,14 @@ export default function SignIn() {
const result = await API.post('user/validate', body)
console.log("result", result)
let decodedToken = jwt_decode(result.data.user)
console.log("decodedToken", decodedToken)
localStorage.setItem('token', result.data.user)
localStorage.setItem('userInfo', JSON.stringify(result.data.userDetails))
dispatch(login({ 'fullName': decodedToken.fullName, 'email': decodedToken.email }))
dispatch(userInfo(result.data.userDetails))
dispatch(userInfo(result.data?.userDetails))
dispatch(addHeader({ 'header': true, 'footer': true }))
navigate('/')
} catch (error) {
console.log("errrrr",error)
console.log("error",error)
setErrorMsg(error.response.data.message)
handleError()
}
......
......@@ -106,10 +106,10 @@ export default function SignUp() {
dispatch(addHeader({ 'header': false, 'footer': false }))
}, []);
useEffect(() => {
// useEffect(() => {
console.log("headerVisibilityeee", headerVisibility.value)
}, [headerVisibility]);
// console.log("headerVisibilityeee", headerVisibility.value)
// }, [headerVisibility]);
const handleSubmit = async (event) => {
event.preventDefault();
......@@ -125,15 +125,16 @@ export default function SignUp() {
email: data.get('email'),
password: data.get('password'),
role: 'user',
predictionCount : 0,
predictionCountLimit : 0,
predictionCount : 5,
compareCount : 3,
locationPredictCount:10,
paymentType: 'none',
paymentID: 'none',
subscriptionPlan: 'none',
subscriptionType: 'none',
subscriptionEndDate : 'none',
subscriptionDate : 'none',
subscriptionStatus : 'none'
subscriptionType: 'Monthly',
subscriptionPlan: 'Free',
subscriptionEndDate : '15-12-2022',
subscriptionDate : '15-11-2022',
subscriptionStatus : 'Active',
}
try {
const result = await API.post('user/create', body)
......
......@@ -15,6 +15,16 @@ import TabContext from '@mui/lab/TabContext';
import TabList from '@mui/lab/TabList';
import TabPanel from '@mui/lab/TabPanel';
import { addNewBusiness } from './../features/business';
import AlertDialogSlide from './AlertDialogSlide';
import Snackbar from '@mui/material/Snackbar';
import MuiAlert, { AlertProps } from '@mui/material/Alert';
const Alert = React.forwardRef(function Alert(
props,
ref,
) {
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />;
});
const GetStarted = styled(Button)(() => ({
......@@ -87,26 +97,103 @@ const BusinessTypePage = () => {
const theme = useSelector((state) => state.theme);
const classes = useStyles(theme);
const [value, setValue] = React.useState('1');
const userInfo = useSelector((state) => state.user.userDetails);
const [open, setOpen] = React.useState(false);
const [titleBox, setTitleBox] = React.useState('');
const [contentBox, setContentBox] = React.useState('');
const [error, setError] = React.useState(false);
const [errorMsg, setErrorMsg] = React.useState("Error");
const handleChange = (event, newValue) => {
setValue(newValue);
};
const handleCheckCount = () => {
if(userInfo?.predictionCount > 0){
return true;
}else{
return false;
}
}
const handleCheckLogin = () => {
console.log(userInfo.predictionCount ? true : false);
if(userInfo){
return true;
}else{
return false;
}
}
const navigateToHInputForm = () => {
console.log("first")
dispatch(addNewBusiness({ 'type': 'hotel' }))
navigate(`/inputHotel`);
if(!handleCheckLogin()){
setErrorMsg('Please login to continue');
handleError()
}
else if(handleCheckCount()){
dispatch(addNewBusiness({ 'type': 'hotel' }))
navigate(`/inputHotel`);
}else{
setTitleBox('You have already used your prediction count');
setContentBox('You can only use your prediction count once. Please contact us to get more prediction count.');
setOpen(true);
}
}
const navigateToRInputForm = () => {
dispatch(addNewBusiness({ 'type': 'restaurant' }))
navigate(`/inputHotel`)
if(!handleCheckLogin()){
setErrorMsg('Please login to continue');
handleError()
}
else if(handleCheckCount()){
dispatch(addNewBusiness({ 'type': 'restaurant' }))
navigate(`/inputHotel`)
}else{
setTitleBox('You have already used your prediction count');
setContentBox('You can only use your prediction count once. Please contact us to get more prediction count.');
setOpen(true);
}
}
const navigateToLocationBasedPredic = () => {
dispatch(addNewBusiness({ 'type': 'locationBased' }))
navigate(`/locationBasedPredict`)
if(!handleCheckLogin()){
setErrorMsg('Please login to continue');
handleError()
}
else if(handleCheckCount()){
dispatch(addNewBusiness({ 'type': 'locationBased' }))
navigate(`/locationBasedPredict`)
}else{
setTitleBox('You have already used your prediction count');
setContentBox('You can only use your prediction count once. Please contact us to get more prediction count.');
setOpen(true);
}
}
const handleConfirmDailog = (Confirm) => {
if(Confirm){
navigate(`/Pricing`);
setOpen(false);
}else{
navigate(`/`);
setOpen(false);
}
}
const handleError = () => {
setError(true);
};
const handleCloseError = (event, reason) => {
if (reason === 'clickaway') {
return;
}
setError(false);
}
return (
<Box
sx={{
......@@ -122,6 +209,15 @@ return (
boxSizing:'border-box',
}}
>
<Snackbar open={error} autoHideDuration={6000} onClose={handleCloseError}>
<Alert onClose={handleCloseError} severity="error">{errorMsg}</Alert>
</Snackbar>
<AlertDialogSlide
open={open}
setOpen={setOpen}
title={titleBox}
content={contentBox}
handleConfirmDailog={handleConfirmDailog}/>
<TabContext value={value}>
<Box sx={{
display:'flex',
......
This diff is collapsed.
......@@ -65,10 +65,10 @@ const Footer = () => {
let navigate = useNavigate();
const headerVisibility = useSelector((state) => state.header)
useEffect(() => {
// useEffect(() => {
console.log("headerVisibilityeee", headerVisibility.value)
}, [headerVisibility]);
// console.log("headerVisibilityeee", headerVisibility.value)
// }, [headerVisibility]);
return (
<>
......
......@@ -25,6 +25,15 @@ import { useNavigate } from "react-router-dom";
import styled from '@emotion/styled';
import { FillingBottle } from "react-cssfx-loading";
import { TypeAnimation } from 'react-type-animation';
import Snackbar from '@mui/material/Snackbar';
import MuiAlert, { AlertProps } from '@mui/material/Alert';
const Alert = React.forwardRef(function Alert(
props,
ref,
) {
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />;
});
const NextBtn = styled(Button)(() => ({
......@@ -89,7 +98,10 @@ export default function InputDetails() {
const [open, setOpen] = React.useState(false);
const dispatch = useDispatch();
const [activeStep, setActiveStep] = React.useState(0);
const businessDetails = useSelector((state) => state.business)
const businessDetails = useSelector((state) => state.business);
const userInfo = useSelector((state) => state.user.userDetails);
const [error, setError] = React.useState(false);
const [errorMsg, setErrorMsg] = React.useState("Error");
let navigate = useNavigate();
const handleClose = () => {
setOpen(false);
......@@ -113,7 +125,10 @@ export default function InputDetails() {
}
};
const handleNext = () => {
if(businessDetails.value[0].latitude && businessDetails.value[0].longitude){
setActiveStep(activeStep + 1);
if (activeStep === steps.length - 1 && businessDetails && businessDetails.value[0].type == 'hotel') {
handleToggle()
......@@ -273,16 +288,32 @@ export default function InputDetails() {
}).catch(function (error) { })
}).catch(function (error) { });
}
}else{
setErrorMsg('Please Select a Location');
handleError()
}
};
const handleBack = () => {
setActiveStep(activeStep - 1);
};
const handleError = () => {
setError(true);
};
const handleCloseError = (event, reason) => {
if (reason === 'clickaway') {
return;
}
setError(false);
}
return (
<ThemeProvider theme={theme}>
{/* <CssBaseline /> */}
<Snackbar open={error} autoHideDuration={6000} onClose={handleCloseError}>
<Alert onClose={handleCloseError} severity="error">{errorMsg}</Alert>
</Snackbar>
<Container component="main" maxWidth={activeStep == 0 ? "md" : "sm"} sx={{ p: 8 ,boxSizing:"border-box",}}>
<Paper variant="outlined"
sx={{
......@@ -356,7 +387,6 @@ export default function InputDetails() {
repeat={Infinity}
style={{ fontSize: '2em',color:"#101554" }}
/>
</Box>
</React.Fragment>
......
......@@ -11,7 +11,7 @@ import { addBusiness } from '../features/business';
function Map() {
const dispatch = useDispatch();
const businessDetails = useSelector((state) => state.business)
const businessDetails = useSelector((state) => state.business);
const [mapRef, setMapRef] = useState(null);
const [selectedPlace, setSelectedPlace] = useState(null);
const [markerMap, setMarkerMap] = useState({});
......@@ -19,8 +19,8 @@ function Map() {
const [position, setPosition] = useState({});
const [zoom, setZoom] = useState(9);
const [clickedLatLng, setClickedLatLng] = useState({
lat: businessDetails && businessDetails.value[0].latitude ? businessDetails.value[0].latitude : '',
lng: businessDetails && businessDetails.value[0].longitude ? businessDetails.value[0].longitude : '',
lat: businessDetails?.value[0]?.latitude ? businessDetails.value[0].latitude : '',
lng: businessDetails?.value[0]?.longitude ? businessDetails.value[0].longitude : '',
});
const [infoOpen, setInfoOpen] = useState(false);
......@@ -64,9 +64,8 @@ function Map() {
useEffect(() => {
if (clickedLatLng) {
console.log('sqqqqqqqqqqqqqqqqqqqq')
setPosition(clickedLatLng)
console.log("clickedLatLng", clickedLatLng, businessDetails.value[0].type)
console.log("clickedLatLng", clickedLatLng, businessDetails.value[0]?.type)
dispatch(addBusiness({
...businessDetails.value[0],
latitude: clickedLatLng.lat,
......
......@@ -293,10 +293,10 @@ const MultipleResult = () => {
<div className={classes.featureTitleTxt}>Location Based Features</div>
<Box className={classes.featuresBox}>
<Grow in={checked} style={{ transformOrigin: '0 0 0' }} {...(checked ? { timeout: 500 } : {})} >
<div className={classes.features}><LocationOnRoundedIcon style={{ color: '#df5e52' }} />Location Attractiveness Places - {businessDetails.value[i].locationFeatures.attractionPlacesCount}</div>
<div className={classes.features}><LocationOnRoundedIcon style={{ color: '#df5e52' }} />Location Attractiveness Places - {businessDetails.value[i].locationFeatures?.attractionPlacesCount}</div>
</Grow>
<Grow in={checked} style={{ transformOrigin: '0 0 0' }} {...(checked ? { timeout: 800 } : {})} >
<div className={classes.features}><DirectionsTransitFilledSharpIcon style={{ color: '#2f9f48' }} />Transportation Modes Count - {businessDetails.value[i].locationFeatures.transportationModesCount}</div>
<div className={classes.features}><DirectionsTransitFilledSharpIcon style={{ color: '#2f9f48' }} />Transportation Modes Count - {businessDetails.value[i].locationFeatures?.transportationModesCount}</div>
</Grow>
<Grow in={checked} style={{ transformOrigin: '0 0 0' }} {...(checked ? { timeout: 1100 } : {})} >
<div className={classes.features}><ApartmentRoundedIcon style={{ color: '#ce7c39' }} />Nearby Hotel Count - {businessDetails.value[i].locationFeatures.competitors}</div>
......@@ -505,9 +505,6 @@ const MultipleResult = () => {
</Box>
</Box>
......
This diff is collapsed.
import React, { useEffect, useState } from "react";
import Box from "@mui/material/Box";
import { makeStyles } from "@mui/styles";
import Grow from "@mui/material/Grow";
import { red } from "@mui/material/colors";
import { BsFilePlus } from "react-icons/bs";
import { GiPathDistance } from "react-icons/gi";
import { MdWork } from "react-icons/md";
import { IoMdSchool } from "react-icons/io";
import { HiShoppingBag } from "react-icons/hi";
import { RiRestaurantFill } from "react-icons/ri";
import { GoPrimitiveDot } from "react-icons/go";
import DirectionsTransitFilledSharpIcon from "@mui/icons-material/DirectionsTransitFilledSharp";
import LocationOnRoundedIcon from "@mui/icons-material/LocationOnRounded";
import ApartmentRoundedIcon from "@mui/icons-material/ApartmentRounded";
import StarRoundedIcon from "@mui/icons-material/StarRounded";
import { useSelector } from "react-redux";
import {
useLoadScript,
GoogleMap,
MarkerF,
InfoWindow,
} from "@react-google-maps/api";
const UseStyles = makeStyles(() => ({
titleTxt: {
color: "#231D4F",
fontSize: "25px",
fontWeight: "600",
marginTop: "10px",
},
subTxt: {
color: "#888888",
fontSize: "14px",
fontWeight: "400",
marginBottom: "10px",
},
featuresBoxFlex: {
width: "100%",
height: "100%",
boxSizing: "border-box",
display: "flex",
justifyContent: "center",
flexDirection: "column",
alignItems: "flex-start",
color: (themeColor) =>
themeColor.status == "light" ? "#3e3d3d" : "#f5f5f5",
},
featuresBox: {
width: "100%",
height: "100%",
// backgroundColor: themeColor => themeColor.status == 'dark' ? '#3e3d3d' : '#f5f5f5',
borderRadius: "30px",
boxSizing: "border-box",
overflow: "hidden",
padding: "20px",
display: "flex",
justifyContent: "center",
flexWrap: "wrap",
gap: "10px",
},
features: {
flex: "2 5 12rem",
width: "fit-content",
height: "fit-content",
whiteSpace: "pre-wrap",
backgroundColor: (themeColor) =>
themeColor.status == "dark" ? "#4c4c4c" : "#e8e8e8",
borderRadius: "8px",
boxSizing: "border-box",
display: "flex",
flexDirection: "column",
gap: "10px",
alignItems: "center",
padding: "10px",
paddingInline: "15px",
boxShadow: "0px 0px 5px 0px rgba(234,234,234,0.2)",
color: "#272830",
fontSize: "16px",
fontWeight: "600",
marginTop: "10px",
},
countTxt:{
color: "#231D4F",
fontSize: "26px",
fontWeight: "600",
marginBottom: "10px",
}
}));
const ResultsFD = () => {
const themeColor = useSelector((state) => state.theme.value);
const factorDetails = useSelector((state)=>state.factorDetails.value);
const classes = UseStyles(themeColor);
const [center, setCenter] = useState({
lat: 60.192059,
lng: 24.945831,
});
const [position, setPosition] = useState({
lat: 60.192059,
lng: 24.945831,
});
const [zoom, setZoom] = useState(9);
const { isLoaded } = useLoadScript({
// Enter your own Google Maps API key
googleMapsApiKey: "AIzaSyC_mV5GkYx8ULNDqXgwBobTczkM7j6T0uc",
});
const [checked, setChecked] = useState(true);
useEffect(() => {
console.log(factorDetails);
}, [factorDetails]);
return (
<Box
sx={{
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
backgroundColor: "#E4E6F1",
paddingBlock: "50px",
paddingInline: "250px",
}}
>
<Box
sx={{
display: "flex",
alignItems: "center",
justifyContent: "center",
padding: "35px",
backgroundColor: "#FFFFFF",
width: "100%",
height: "100%",
borderRadius: "1rem",
boxSizing: "border-box",
}}
>
<Box
sx={{
width: "100%",
display: "flex",
flexDirection: "column",
alignItems: "flex-start",
justifyContent: "flex-start",
}}
>
<div className={classes.titleTxt}>Simple, transparent pricing</div>
<div className={classes.subTxt}>No contracts. No surprise fees.</div>
<Box className={classes.featuresBoxFlex}>
<Box className={classes.featuresBox}>
<Grow
in={checked}
style={{ transformOrigin: "0 0 0" }}
{...(checked ? { timeout: 500 } : {})}
>
<div className={classes.features}>
<LocationOnRoundedIcon style={{ color: "#df5e52" ,fontSize:"30px"}} />
Attractiveness Places
<div className={classes.countTxt}>
{factorDetails?.attractionPlacesCount}
</div>
</div>
</Grow>
<Grow
in={checked}
style={{ transformOrigin: "0 0 0" }}
{...(checked ? { timeout: 800 } : {})}
>
<div className={classes.features}>
<DirectionsTransitFilledSharpIcon
style={{ color: "#2f9f48" ,fontSize:"30px"}}
/>
Transportation Modes
<div className={classes.countTxt}>
{factorDetails?.transportationModesCount}
</div>
</div>
</Grow>
<Grow
in={checked}
style={{ transformOrigin: "0 0 0" }}
{...(checked ? { timeout: 1100 } : {})}
>
<div className={classes.features}>
<ApartmentRoundedIcon style={{ color: "#ce7c39" ,fontSize:"30px"}} />
Nearby Hotel Count
<div className={classes.countTxt}>
{factorDetails?.nearByHotelCount}
</div>
</div>
</Grow>
<Grow
in={checked}
style={{ transformOrigin: "0 0 0" }}
{...(checked ? { timeout: 1400 } : {})}
>
<div className={classes.features}>
<StarRoundedIcon style={{ color: "#e2da5f",fontSize:"30px" }} />
Nearby Hotel Reviews
<div className={classes.countTxt}>
{factorDetails?.nearByHotelReviewCount}
</div>
</div>
</Grow>
<Grow
in={checked}
style={{ transformOrigin: "0 0 0" }}
{...(checked ? { timeout: 500 } : {})}
>
<div className={classes.features}>
<GiPathDistance
style={{ color: "#df5e52",fontSize:"30px" }}
/>
DistanceTo The City
<div className={classes.countTxt}>
{factorDetails?.DistanceToCity}km
</div>
</div>
</Grow>
<Grow
in={checked}
style={{ transformOrigin: "0 0 0" }}
{...(checked ? { timeout: 800 } : {})}
>
<div className={classes.features}>
<HiShoppingBag
style={{ color: "#2f9f48",fontSize:"30px" }}
/>
Shopping Malls
<div className={classes.countTxt}>
{factorDetails?.ShoppingMallsCount}
</div>
</div>
</Grow>
<Grow
in={checked}
style={{ transformOrigin: "0 0 0" }}
{...(checked ? { timeout: 1100 } : {})}
>
<div className={classes.features}>
<IoMdSchool style={{ color: "#ce7c39",fontSize:"30px" }} />
Education Related Places
<div className={classes.countTxt}>
{factorDetails?.EducationRelatedPlacesCount}
</div>
</div>
</Grow>
<Grow
in={checked}
style={{ transformOrigin: "0 0 0" }}
{...(checked ? { timeout: 1400 } : {})}
>
<div className={classes.features}>
<MdWork style={{ color: "#4e4c2e",fontSize:"30px"}} />
Work Places
<div className={classes.countTxt}>
{factorDetails?.WorkPlacesCount}
</div>
</div>
</Grow>
</Box>
</Box>
<Box
sx={{
width: "100%",
height: "100%",
borderRadius: "1rem",
}}
>
{isLoaded ? (
<div>
<GoogleMap
center={center}
zoom={zoom}
mapContainerStyle={{
borderRadius: "8px",
height: "35vh",
}}
>
{position && <MarkerF position={position} />}
</GoogleMap>
</div>
) : (
<div>
Loading...
</div>
)}
</Box>
</Box>
</Box>
</Box>
);
};
export default ResultsFD;
import styled from "@emotion/styled";
import { Margin } from "@mui/icons-material";
import Button from "@mui/material/Button";
import { makeStyles } from "@mui/styles";
import { Box } from "@mui/system";
import { type } from "@testing-library/user-event/dist/type";
import React, { useEffect } from "react";
import { FiCheck } from "react-icons/fi";
import { useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import DATA from '../../assets/data/subscriptionPlan'
const UseStyles = makeStyles((theme) => ({
pricingBoxMost: {
width: "fit-content",
height: "100%",
boxSizing: "border-box",
display: "flex",
flexDirection: "column",
alignItems: "flex-start",
justifyContent: "center",
gap: "5px",
paddingInline: "25px",
backgroundColor: "#151649",
borderRadius: "20px",
paddingBlock: "28px",
boxShadow: "0px 1px 10px 0px #888888",
backgroundImage: `url(${require("../../images/priceSvg.svg").default})`,
backgroundRepeat: "no-repeat",
backgroundPosition: "right",
},
priceMonthTxtMost: {
color: "#E4E6F1",
fontSize: "1rem",
},
priceTxtMost: {
color: "#E4E6F1",
fontSize: "28px",
fontWeight: "500",
},
planDescTxtMost: {
color: "#fff",
fontSize: "14px",
marginBottom: "10px",
width: "300px",
whiteSpace: "wrap",
},
planItemsMost: {
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "row",
gap: "10px",
marginBlock: "5px",
},
planIconMost: {
color: "#E4E6F1",
backgroundColor: "#adadad3b",
padding: "3px",
borderRadius: "50%",
},
planItemTxtMost: {
color: "#E4E6F1",
fontSize: "14px",
},
planTypeTxtMost: {
color: "#E4E6F1",
fontSize: "19px",
fontWeight: "600",
},
popularTxtMost: {
color: "#dab23b",
fontSize: "10px",
fontWeight: "200",
backgroundColor: "#23206e",
paddingInline: "10px",
paddingBlock: "5px",
borderRadius: "30px",
textTransform: "Uppercase",
alignSelf: "flex-end",
},
titleTxt: {
color: "#231D4F",
fontSize: "29px",
fontWeight: "600",
marginBlock: "1rem",
},
subTxt: {
color: "#888888",
fontSize: "14px",
fontWeight: "400",
marginBottom: "1rem",
},
PlanTitleTxt: {
color: "#231D4F",
fontSize: "25px",
fontWeight: "600",
marginBlock: "1rem",
},
planIcon: {
color: "#282138",
backgroundColor: "#adadad3b",
padding: "3px",
borderRadius: "50%",
},
bodyTxt: {
marginBottom: "2px",
whiteSpace: "nowrap",
},
PlanDetailsTxt: {
color: "#231D4F",
fontSize: "25px",
fontWeight: "600",
marginBlock: "0.5rem",
marginInline: "3rem",
whiteSpace: "nowrap",
},
}));
const MostPlanButton = styled(Button)(({ theme }) => ({
width: "170px",
marginTop: "20px",
color: "#d29f1c",
borderRadius: "30px",
textTransform: "none",
fontSize: "12px",
boxSizing: "border-box",
alignSelf: "center",
paddingBlock: "8px",
/* "to left" / "to right" - affects initial color */
background: "linear-gradient(to left, #eac0732e 50%, #fbc1547c 50%) right",
backgroundSize: "200%",
transition: ".5s ease-out",
"&:hover": {
backgroundPosition: "left",
},
}));
const UserSubscriptionPlan = () => {
const classes = UseStyles();
const navigate = useNavigate();
const userInfo = useSelector((state) => state.user.userDetails);
const [predictionNo, setPredictionNo] = React.useState(0);
useEffect(() => {
for(let i=0; i<DATA.length; i++){
if(DATA[i].plan === userInfo?.subscriptionPlan){
console.log(DATA[i].plan)
setPredictionNo(DATA[i].locationPredictCount)
}
}
},[userInfo])
return (
<Box
sx={{
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
backgroundColor: "#E4E6F1",
paddingBlock: "50px",
}}
>
<div className={classes.titleTxt}>Simple, transparent pricing</div>
<div className={classes.subTxt}>No contracts. No surprise fees.</div>
<Box
sx={{
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "row-reverse",
gap: "70px",
height: "100%",
width: "100%",
padding: "2rem",
paddingInline: "13rem",
boxSizing: "border-box",
}}
>
<Box
sx={{
width: "fit-content",
height: "100%",
display: "flex",
flexDirection: "column",
alignItems: "flex-start",
justifyContent: "center",
borderRadius: "20px",
border: "1px solid #888888",
gap: "20px",
padding: "2rem",
paddingBlock: "3rem",
}}
>
<div className={classes.PlanDetailsTxt}>Your Plan Details</div>
<div className={classes.planItemsMost}>
<FiCheck className={classes.planIcon} />
<div className={classes.bodyTxt}>Status - {userInfo?.subscriptionStatus} </div>
</div>
<div className={classes.planItemsMost}>
<FiCheck className={classes.planIcon} />
<div className={classes.bodyTxt}>Prediction Limit - {userInfo?.predictionCount} </div>
</div>
<div className={classes.planItemsMost}>
<FiCheck className={classes.planIcon} />
<div className={classes.bodyTxt}>Compare Location Limit - {userInfo?.compareCount} </div>
</div>
<div className={classes.planItemsMost}>
<FiCheck className={classes.planIcon} />
<div className={classes.bodyTxt}>Location Based Limit - {userInfo?.locationPredictCount} </div>
</div>
<div className={classes.planItemsMost}>
<FiCheck className={classes.planIcon} />
<div className={classes.bodyTxt}>Activate Date - {userInfo?.subscriptionDate} </div>
</div>
<div className={classes.planItemsMost}>
<FiCheck className={classes.planIcon} />
<div className={classes.bodyTxt}>Expire Date - {(userInfo?.subscriptionEndDate)}</div>
</div>
</Box>
{DATA.map((item, index) => (
item.plan === userInfo.subscriptionPlan && (
<Box className={classes.pricingBoxMost} key={index}>
<div className={classes.popularTxtMost}>{item.plan}</div>
<div className={classes.priceMonthTxtMost}>
<span className={classes.priceTxtMost}>{item.price}$</span> /{item.type}
</div>
<div className={classes.planTypeTxtMost}>{item.plan}</div>
<div className={classes.planDescTxtMost}>
{item.description}
</div>
{item.features.map((feature, i) => (
<div className={classes.planItemsMost} key={i}>
<FiCheck className={classes.planIconMost}/><div className={classes.planItemTxtMost}>{feature}</div>
</div>
))}
<MostPlanButton onClick={()=> navigate("/Pricing") }> Change Plan </MostPlanButton>
</Box>)))}
</Box>
</Box>
);
};
export default UserSubscriptionPlan;
......@@ -21,7 +21,6 @@ export const businessSlice = createSlice({
temp.push(state.value[i])
}
// state.value.push(action.payload)
console.log("temppppppppppppppppppppppppppppppppppppppppppp", temp)
state.value = temp;
state.value[0] = action.payload
},
......@@ -37,8 +36,6 @@ export const businessSlice = createSlice({
}
temp.push(state.value[i])
}
// state.value.push(action.payload)
// console.log("temppppppppppppppppppppppppppppppppppppppppppp", temp)
state.value = temp;
state.value[0] = action.payload
},
......
import { createSlice } from '@reduxjs/toolkit'
export const factorDetailsSlice = createSlice({
name: "factorDetails",
initialState: {
value: []
},
reducers: {
factorDetailsInfo: (state, action) => {
state.value = action.payload
}
}
});
export const { factorDetailsInfo } = factorDetailsSlice.actions;
export default factorDetailsSlice.reducer;
\ No newline at end of file
import { createSlice } from '@reduxjs/toolkit';
import api from '../api';
import { createSlice } from "@reduxjs/toolkit";
import api from "../api";
export const userSlice = createSlice({
name: "user",
initialState: {
value: [],
userDetails: [],
name: "user",
initialState: {
value: [],
userDetails: [],
},
reducers: {
login: (state, action) => {
state.value.push(action.payload);
},
reducers: {
login: (state, action) => {
console.log("action.payload", action.payload)
state.value.push(action.payload)
},
register: (state, action) => {
state.value.push(action.payload)
},
userInfo: (state, action) => {
state.userDetails.push(action.payload)
},
updateUser: (state, action) => {
const updateSubscription = async ()=>{
await api.put(`/users/updateUser/`, action.payload);
}
if(action.payload){
state.userDetails.push(updateSubscription())
}
},
logout: (state) => {
state.value = [];
state.userDetails = null;
},
}
register: (state, action) => {
state.value.push(action.payload);
},
userInfo: (state, action) => {
state.userDetails = action.payload;
},
updateUser: (state, action) => {
console.log(action.payload);
},
logout: (state) => {
state.value = [];
state.userDetails = [];
},
},
});
export const { login: login, register: register, logout:logout,userInfo:userInfo } = userSlice.actions;
export default userSlice.reducer;
\ No newline at end of file
export const {
login: login,
register: register,
logout: logout,
userInfo: userInfo,
updateUser: updateUser,
} = userSlice.actions;
export default userSlice.reducer;
import api from "../api";
export const UpdateLocationPredicCount = (uid,count) => async (dispatch) => {
try {
const { data } = await api
.put(`/user/updateUser/`,{
id:uid,
locationPredicCount:count
});
console.log(data)
} catch (error) {
console.log(error);
}
}
\ No newline at end of file
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