diff --git a/src/App.js b/src/App.js index ba4e4e8..c3e98bb 100644 --- a/src/App.js +++ b/src/App.js @@ -2,7 +2,6 @@ import Routes from 'routes'; import ThemeCustomization from 'themes'; import Locales from 'components/Locales'; -// import RTLLayout from 'components/RTLLayout'; import ScrollTop from 'components/ScrollTop'; import Snackbar from 'components/@extended/Snackbar'; import Notistack from 'components/third-party/Notistack'; @@ -12,9 +11,6 @@ import { generateToken, initFirebaseNotificationListener } from 'firebase_notifi import InternetStatus from 'components/updateNetworkStatus'; import useInactivityLogout from 'hooks/useInactivityLogout'; -// auth-provider -// import { JWTProvider as AuthProvider } from 'contexts/JWTContext'; - // ==============================|| APP - THEME, ROUTER, LOCAL ||============================== // const App = () => { @@ -45,21 +41,13 @@ const App = () => { <> - {/* */} - {/* */} - <> - - {/* - */} - - - - {/* */} + + + - {/* */} ); diff --git a/src/components/@extended/progress/CircularWithLabel.js b/src/components/@extended/progress/CircularWithLabel.js deleted file mode 100644 index 4348dfc..0000000 --- a/src/components/@extended/progress/CircularWithLabel.js +++ /dev/null @@ -1,32 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { Box, CircularProgress, Typography } from '@mui/material'; - -// ==============================|| PROGRESS - CIRCULAR LABEL ||============================== // - -export default function CircularWithLabel({ value, ...others }) { - return ( - - - - {`${Math.round(value)}%`} - - - ); -} - -CircularWithLabel.propTypes = { - value: PropTypes.number -}; diff --git a/src/components/@extended/progress/CircularWithPath.js b/src/components/@extended/progress/CircularWithPath.js deleted file mode 100644 index 2e85f3a..0000000 --- a/src/components/@extended/progress/CircularWithPath.js +++ /dev/null @@ -1,65 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { Box, CircularProgress, Typography, circularProgressClasses } from '@mui/material'; - -// ==============================|| PROGRESS - CIRCULAR PATH ||============================== // - -export default function CircularWithPath({ value, size, variant, thickness, showLabel, pathColor, sx, ...others }) { - return ( - - - {showLabel && ( - - - {value ? `${Math.round(value)}%` : '0%'} - - - )} - - - ); -} - -CircularWithPath.propTypes = { - value: PropTypes.number, - size: PropTypes.number, - variant: PropTypes.string, - thickness: PropTypes.number, - showLabel: PropTypes.bool, - pathColor: PropTypes.string, - sx: PropTypes.array, - others: PropTypes.array -}; diff --git a/src/components/@extended/progress/LinearWithIcon.js b/src/components/@extended/progress/LinearWithIcon.js deleted file mode 100644 index c1da65a..0000000 --- a/src/components/@extended/progress/LinearWithIcon.js +++ /dev/null @@ -1,22 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { Box, LinearProgress } from '@mui/material'; - -// ==============================|| PROGRESS - LINEAR ICON ||============================== // - -export default function LinearWithIcon({ icon, value, ...others }) { - return ( - - - - - {icon} - - ); -} - -LinearWithIcon.propTypes = { - icon: PropTypes.node, - value: PropTypes.number -}; diff --git a/src/components/@extended/progress/LinearWithLabel.js b/src/components/@extended/progress/LinearWithLabel.js deleted file mode 100644 index 46adb2d..0000000 --- a/src/components/@extended/progress/LinearWithLabel.js +++ /dev/null @@ -1,23 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { Box, LinearProgress, Typography } from '@mui/material'; - -// ==============================|| PROGRESS - LINEAR WITH LABEL ||============================== // - -export default function LinearWithLabel({ value, ...others }) { - return ( - - - - - - {`${Math.round(value)}%`} - - - ); -} - -LinearWithLabel.propTypes = { - value: PropTypes.number -}; diff --git a/src/components/RTLLayout.js b/src/components/RTLLayout.js deleted file mode 100644 index 60e7bbd..0000000 --- a/src/components/RTLLayout.js +++ /dev/null @@ -1,37 +0,0 @@ -import PropTypes from 'prop-types'; -import { useEffect } from 'react'; - -// material-ui -import { CacheProvider } from '@emotion/react'; -import createCache from '@emotion/cache'; - -// third-party -import rtlPlugin from 'stylis-plugin-rtl'; - -// project import -import { ThemeDirection } from 'config'; -import useConfig from 'hooks/useConfig'; - -// ==============================|| RTL LAYOUT ||============================== // - -const RTLLayout = ({ children }) => { - const { themeDirection } = useConfig(); - - useEffect(() => { - document.dir = themeDirection; - }, [themeDirection]); - - const cacheRtl = createCache({ - key: themeDirection === ThemeDirection.RTL ? 'rtl' : 'css', - prepend: true, - stylisPlugins: themeDirection === ThemeDirection.RTL ? [rtlPlugin] : [] - }); - - return {children}; -}; - -RTLLayout.propTypes = { - children: PropTypes.node -}; - -export default RTLLayout; diff --git a/src/components/ScrollX.js b/src/components/ScrollX.js deleted file mode 100644 index eb4d863..0000000 --- a/src/components/ScrollX.js +++ /dev/null @@ -1,10 +0,0 @@ -// material-ui -import { styled } from '@mui/material/styles'; - -const ScrollX = styled('div')({ - width: '100%', - overflowX: 'auto', - display: 'block' -}); - -export default ScrollX; diff --git a/src/components/cards/ComponentHeader.js b/src/components/cards/ComponentHeader.js deleted file mode 100644 index 20178bb..0000000 --- a/src/components/cards/ComponentHeader.js +++ /dev/null @@ -1,49 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { Box, Grid, Link, Stack, Typography } from '@mui/material'; - -// assets -import { GlobalOutlined, NodeExpandOutlined } from '@ant-design/icons'; - -// ==============================|| COMPONENTS - BREADCRUMBS ||============================== // - -const ComponentHeader = ({ title, caption, directory, link }) => ( - - - {title} - {caption && ( - - {caption} - - )} - - - {directory && ( - - - - {directory} - - - )} - {link && ( - - - - {link} - - - )} - - -); - -ComponentHeader.propTypes = { - title: PropTypes.string, - caption: PropTypes.string, - directory: PropTypes.string, - link: PropTypes.string -}; - -export default ComponentHeader; diff --git a/src/components/cards/e-commerce/FloatingCart.js b/src/components/cards/e-commerce/FloatingCart.js deleted file mode 100644 index 75fe8d6..0000000 --- a/src/components/cards/e-commerce/FloatingCart.js +++ /dev/null @@ -1,52 +0,0 @@ -// material-ui -import { useTheme } from '@mui/material/styles'; -import { Fab, Badge } from '@mui/material'; - -// project import - -// assets - -// ==============================|| CART ITEMS - FLOATING BUTTON ||============================== // - -const FloatingCart = ({ element, count = 0, onClick, sx }) => { - const theme = useTheme(); - - // const cart = useSelector((state) => state.cart); - // const totalQuantity = sum(cart.checkout.products.map((item) => item.quantity)); - - return ( - - - {element} - - - ); -}; - -export default FloatingCart; diff --git a/src/components/cards/e-commerce/ProductCard.js b/src/components/cards/e-commerce/ProductCard.js deleted file mode 100644 index d1e3b15..0000000 --- a/src/components/cards/e-commerce/ProductCard.js +++ /dev/null @@ -1,176 +0,0 @@ -import PropTypes from 'prop-types'; -import { useEffect, useState } from 'react'; -import { Link } from 'react-router-dom'; - -// material-ui -import { useTheme } from '@mui/material/styles'; -import { Box, Button, CardContent, CardMedia, Chip, Divider, Grid, Rating, Stack, Typography } from '@mui/material'; - -// project import -import MainCard from 'components/MainCard'; -import IconButton from 'components/@extended/IconButton'; -import SkeletonProductPlaceholder from 'components/cards/skeleton/ProductPlaceholder'; -import { useDispatch, useSelector } from 'store'; -import { addProduct } from 'store/reducers/cart'; -import { openSnackbar } from 'store/reducers/snackbar'; - -// assets -import { HeartOutlined, HeartFilled } from '@ant-design/icons'; - -const prodImage = require.context('assets/images/e-commerce', true); - -// ==============================|| PRODUCT CARD ||============================== // - -const ProductCard = ({ id, color, name, brand, offer, isStock, image, description, offerPrice, salePrice, rating }) => { - const theme = useTheme(); - const dispatch = useDispatch(); - - const prodProfile = image && prodImage(`./${image}`); - const [productRating] = useState(rating); - const [wishlisted, setWishlisted] = useState(false); - const cart = useSelector((state) => state.cart); - - const addCart = () => { - dispatch(addProduct({ id, name, image, salePrice, offerPrice, color, size: 8, quantity: 1, description }, cart.checkout.products)); - dispatch( - openSnackbar({ - open: true, - message: 'Add To Cart Success', - variant: 'alert', - alert: { - color: 'success' - }, - close: false - }) - ); - }; - - const addToFavourite = () => { - setWishlisted(!wishlisted); - dispatch( - openSnackbar({ - open: true, - message: 'Added to favourites', - variant: 'alert', - alert: { - color: 'success' - }, - close: false - }) - ); - }; - - const [isLoading, setLoading] = useState(true); - useEffect(() => { - setLoading(false); - }, []); - - return ( - <> - {isLoading ? ( - - ) : ( - - - - - - {!isStock && } - {offer && } - - {wishlisted ? ( - - ) : ( - - )} - - - - - - - - - {name} - - - {brand} - - - - - - - - ${offerPrice} - {salePrice && ( - - ${salePrice} - - )} - - - - ({productRating?.toFixed(1)}) - - - - - - - - - - )} - - ); -}; - -ProductCard.propTypes = { - id: PropTypes.number, - color: PropTypes.string, - name: PropTypes.string, - brand: PropTypes.string, - isStock: PropTypes.bool, - image: PropTypes.string, - description: PropTypes.string, - offerPrice: PropTypes.number, - salePrice: PropTypes.number, - offer: PropTypes.string, - rating: PropTypes.number -}; - -export default ProductCard; diff --git a/src/components/cards/e-commerce/ProductReview.js b/src/components/cards/e-commerce/ProductReview.js deleted file mode 100644 index bf45f2f..0000000 --- a/src/components/cards/e-commerce/ProductReview.js +++ /dev/null @@ -1,52 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { Grid, Rating, Stack, Typography } from '@mui/material'; - -// project imports -import Avatar from 'components/@extended/Avatar'; - -// assets -import { StarFilled, StarOutlined } from '@ant-design/icons'; - -const avatarImage = require.context('assets/images/users', true); - -// ==============================|| PRODUCT DETAILS - REVIEW ||============================== // - -const ProductReview = ({ avatar, date, name, rating, review }) => ( - - - - - - - {name} - - - {date} - - } - emptyIcon={} - precision={0.1} - readOnly - /> - - {review} - - - -); - -ProductReview.propTypes = { - avatar: PropTypes.string, - date: PropTypes.string, - name: PropTypes.string, - rating: PropTypes.number, - review: PropTypes.string -}; - -export default ProductReview; diff --git a/src/components/cards/skeleton/ProductPlaceholder.js b/src/components/cards/skeleton/ProductPlaceholder.js deleted file mode 100644 index 3002169..0000000 --- a/src/components/cards/skeleton/ProductPlaceholder.js +++ /dev/null @@ -1,44 +0,0 @@ -// material-ui -import { CardContent, Grid, Skeleton, Stack } from '@mui/material'; - -// project import -import MainCard from 'components/MainCard'; - -// ===========================|| SKELETON - PRODUCT CARD ||=========================== // - -const ProductPlaceholder = () => ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -); - -export default ProductPlaceholder; diff --git a/src/components/cards/statistics/AnalyticEcommerce.js b/src/components/cards/statistics/AnalyticEcommerce.js deleted file mode 100644 index 5610371..0000000 --- a/src/components/cards/statistics/AnalyticEcommerce.js +++ /dev/null @@ -1,66 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { Box, Chip, Grid, Stack, Typography } from '@mui/material'; - -// project import -import MainCard from 'components/MainCard'; - -// assets -import { FallOutlined, RiseOutlined } from '@ant-design/icons'; - -// ==============================|| STATISTICS - ECOMMERCE CARD ||============================== // - -const AnalyticEcommerce = ({ color = 'primary', title, count, percentage, isLoss, extra }) => ( - - - - {title} - - - - - {count} - - - {percentage && ( - - - {!isLoss && } - {isLoss && } - - } - label={`${percentage}%`} - sx={{ ml: 1.25, pl: 1 }} - size="small" - /> - - )} - - - - - You made an extra{' '} - - {extra} - {' '} - this year - - - -); - -AnalyticEcommerce.propTypes = { - title: PropTypes.string, - count: PropTypes.string, - percentage: PropTypes.number, - isLoss: PropTypes.bool, - color: PropTypes.string, - extra: PropTypes.string -}; - -export default AnalyticEcommerce; diff --git a/src/components/cards/statistics/AnalyticsDataCard.js b/src/components/cards/statistics/AnalyticsDataCard.js deleted file mode 100644 index 9d96fec..0000000 --- a/src/components/cards/statistics/AnalyticsDataCard.js +++ /dev/null @@ -1,56 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { Box, Chip, Stack, Typography } from '@mui/material'; - -// project import -import MainCard from 'components/MainCard'; - -// assets -import { RiseOutlined, FallOutlined } from '@ant-design/icons'; - -// ==============================|| STATISTICS - ECOMMERCE CARD ||============================== // - -const AnalyticsDataCard = ({ color = 'primary', title, count, percentage, isLoss, children }) => ( - - - - - {title} - - - - {count} - - {percentage && ( - - {!isLoss && } - {isLoss && } - - } - label={`${percentage}%`} - sx={{ ml: 1.25, pl: 1 }} - size="small" - /> - )} - - - - {children} - -); - -AnalyticsDataCard.propTypes = { - title: PropTypes.string, - count: PropTypes.string, - percentage: PropTypes.number, - isLoss: PropTypes.bool, - color: PropTypes.string, - children: PropTypes.node -}; - -export default AnalyticsDataCard; diff --git a/src/components/nearle_components/StatusChip.js b/src/components/nearle_components/StatusChip.js deleted file mode 100644 index 6950687..0000000 --- a/src/components/nearle_components/StatusChip.js +++ /dev/null @@ -1,74 +0,0 @@ -import PropTypes from 'prop-types'; -import { Chip } from '@mui/material'; - -// ==============================|| STATUS CHIP (Doormile-style soft badge) ||============================== // -// One consistent soft-filled chip for every lifecycle status across orders, -// deliveries, riders, tenants, invoices. Colour encodes meaning; the chip stays -// quiet (soft bg + readable dark text) so tables don't turn into a rainbow. - -// Soft background + readable foreground per semantic tone. -const TONE = { - amber: { bg: '#FEF3C7', fg: '#92400E' }, - indigo: { bg: '#E0E7FF', fg: '#3730A3' }, - cyan: { bg: '#CFFAFE', fg: '#155E75' }, - violet: { bg: '#EDE9FE', fg: '#5B21B6' }, - teal: { bg: '#CCFBF1', fg: '#115E59' }, - emerald: { bg: '#D1FAE5', fg: '#065F46' }, - red: { bg: '#FEE2E2', fg: '#991B1B' }, - orange: { bg: '#FFEDD5', fg: '#9A3412' }, - sky: { bg: '#E0F2FE', fg: '#075985' }, - slate: { bg: '#F1F5F9', fg: '#475569' }, - brand: { bg: '#F1E6F7', fg: '#5B1F73' } -}; - -// Status keyword -> tone + display label. -const MAP = { - pending: { tone: 'amber', label: 'Pending' }, - created: { tone: 'sky', label: 'Created' }, - assigned: { tone: 'indigo', label: 'Assigned' }, - accepted: { tone: 'indigo', label: 'Accepted' }, - arrived: { tone: 'cyan', label: 'Arrived' }, - picked: { tone: 'violet', label: 'Picked' }, - 'picked-up':{ tone: 'violet', label: 'Picked Up' }, - started: { tone: 'cyan', label: 'Started' }, - active: { tone: 'teal', label: 'Active' }, - 'in-transit': { tone: 'teal', label: 'In Transit' }, - delivered: { tone: 'emerald', label: 'Delivered' }, - completed: { tone: 'emerald', label: 'Completed' }, - skipped: { tone: 'orange', label: 'Skipped' }, - failed: { tone: 'red', label: 'Failed' }, - cancelled: { tone: 'red', label: 'Cancelled' }, - // riders / tenants - online: { tone: 'emerald', label: 'Online' }, - offline: { tone: 'slate', label: 'Offline' }, - inactive: { tone: 'slate', label: 'Inactive' }, - idle: { tone: 'amber', label: 'Idle' }, - unknown: { tone: 'slate', label: 'Unknown' }, - // invoices - paid: { tone: 'emerald', label: 'Paid' }, - unpaid: { tone: 'amber', label: 'Unpaid' }, - open: { tone: 'sky', label: 'Open' }, - overdue: { tone: 'red', label: 'Overdue' }, - prepaid: { tone: 'emerald', label: 'Prepaid' }, - cod: { tone: 'amber', label: 'COD' } -}; - -export default function StatusChip({ status, label, size = 'small', sx }) { - const key = String(status || '').toLowerCase().trim().replace(/\s+/g, '-'); - const cfg = MAP[key] || { tone: 'slate', label: status || '—' }; - const tone = TONE[cfg.tone] || TONE.slate; - return ( - - ); -} - -StatusChip.propTypes = { - status: PropTypes.string, - label: PropTypes.node, - size: PropTypes.string, - sx: PropTypes.object -}; diff --git a/src/components/nearle_components/TitleCard.js b/src/components/nearle_components/TitleCard.js deleted file mode 100644 index cfcaf38..0000000 --- a/src/components/nearle_components/TitleCard.js +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react'; -import { Stack, Typography, Box } from '@mui/material'; - -const TitleCard = ({ sx, title, children, starticon }) => { - return ( - - - - {starticon && starticon} - {title} - - {children} - - - ); -}; - -export default TitleCard; diff --git a/src/contexts/JWTContext.js b/src/contexts/JWTContext.js deleted file mode 100644 index 3183b16..0000000 --- a/src/contexts/JWTContext.js +++ /dev/null @@ -1,147 +0,0 @@ -import PropTypes from 'prop-types'; -import { createContext, useEffect, useReducer } from 'react'; - -// third-party -import { Chance } from 'chance'; -import jwtDecode from 'jwt-decode'; - -// reducer - state management -import { LOGIN, LOGOUT } from 'store/reducers/actions'; -import authReducer from 'store/reducers/auth'; - -// project import -import Loader from 'components/Loader'; -import axios from 'utils/axios'; - -const chance = new Chance(); - -// constant -const initialState = { - isLoggedIn: false, - isInitialized: false, - user: null - -}; - -const verifyToken = (serviceToken) => { - if (!serviceToken) { - return false; - } - const decoded = jwtDecode(serviceToken); - /** - * Property 'exp' does not exist on type '(token: string, options?: JwtDecodeOptions | undefined) => T'. - */ - return decoded.exp > Date.now() / 1000; -}; - -const setSession = (serviceToken) => { - if (serviceToken) { - localStorage.setItem('serviceToken', serviceToken); - axios.defaults.headers.common.Authorization = `Bearer ${serviceToken}`; - } else { - localStorage.removeItem('serviceToken'); - delete axios.defaults.headers.common.Authorization; - } -}; - -// ==============================|| JWT CONTEXT & PROVIDER ||============================== // - -const JWTContext = createContext(null); - -export const JWTProvider = ({ children }) => { - const [state, dispatch] = useReducer(authReducer, initialState); - - useEffect(() => { - const init = async () => { - console.log(verifyToken) - // try { - // const serviceToken = window.localStorage.getItem('serviceToken'); - // if (serviceToken && verifyToken(serviceToken)) { - // setSession(serviceToken); - // const response = await axios.get('/api/account/me'); - // const { user } = response.data; - // dispatch({ - // type: LOGIN, - // payload: { - // isLoggedIn: true, - // user - // } - // }); - // } else { - // dispatch({ - // type: LOGOUT - // }); - // } - // } catch (err) { - // console.error(err); - // dispatch({ - // type: LOGOUT - // }); - // } - }; - - init(); - }, []); - - const login = async (email, password) => { - const response = await axios.post('/api/account/login', { email, password }); - const { serviceToken, user } = response.data; - setSession(serviceToken); - dispatch({ - type: LOGIN, - payload: { - isLoggedIn: true, - user - } - }); - }; - - const register = async (email, password, firstName, lastName) => { - // todo: this flow need to be recode as it not verified - const id = chance.bb_pin(); - const response = await axios.post('/api/account/register', { - id, - email, - password, - firstName, - lastName - }); - let users = response.data; - - if (window.localStorage.getItem('users') !== undefined && window.localStorage.getItem('users') !== null) { - const localUsers = window.localStorage.getItem('users'); - users = [ - ...JSON.parse(localUsers), - { - id, - email, - password, - name: `${firstName} ${lastName}` - } - ]; - } - - window.localStorage.setItem('users', JSON.stringify(users)); - }; - - const logout = () => { - setSession(null); - dispatch({ type: LOGOUT }); - }; - - const resetPassword = async () => {}; - - const updateProfile = () => {}; - - if (state.isInitialized !== undefined && !state.isInitialized) { - return ; - } - - return {children}; -}; - -JWTProvider.propTypes = { - children: PropTypes.node -}; - -export default JWTContext; diff --git a/src/hooks/useAuth.js b/src/hooks/useAuth.js deleted file mode 100644 index aaa30b8..0000000 --- a/src/hooks/useAuth.js +++ /dev/null @@ -1,16 +0,0 @@ -import { useContext } from 'react'; - -// auth provider -import AuthContext from 'contexts/JWTContext'; - -// ==============================|| AUTH HOOKS ||============================== // - -const useAuth = () => { - const context = useContext(AuthContext); - - if (!context) throw new Error('context must be use inside provider'); - - return context; -}; - -export default useAuth; diff --git a/src/hooks/usePagination.js b/src/hooks/usePagination.js deleted file mode 100644 index bab5f5d..0000000 --- a/src/hooks/usePagination.js +++ /dev/null @@ -1,29 +0,0 @@ -import { useState } from 'react'; - -// ==============================|| CARD - PAGINATION ||============================== // - -export default function usePagination(data, itemsPerPage) { - const [currentPage, setCurrentPage] = useState(1); - const maxPage = Math.ceil(data.length / itemsPerPage); - - function currentData() { - const begin = (currentPage - 1) * itemsPerPage; - const end = begin + itemsPerPage; - return data.slice(begin, end); - } - - function next() { - setCurrentPage((currentPage) => Math.min(currentPage + 1, maxPage)); - } - - function prev() { - setCurrentPage((currentPage) => Math.max(currentPage - 1, 1)); - } - - function jump(page) { - const pageNumber = Math.max(1, page); - setCurrentPage(() => Math.min(pageNumber, maxPage)); - } - - return { next, prev, jump, currentData, currentPage, maxPage }; -} diff --git a/src/hooks/useScriptRef.js b/src/hooks/useScriptRef.js deleted file mode 100644 index 1ff4dde..0000000 --- a/src/hooks/useScriptRef.js +++ /dev/null @@ -1,18 +0,0 @@ -import { useEffect, useRef } from 'react'; - -// ==============================|| ELEMENT REFERENCE HOOKS ||============================== // - -const useScriptRef = () => { - const scripted = useRef(true); - - useEffect( - () => () => { - scripted.current = false; - }, - [] - ); - - return scripted; -}; - -export default useScriptRef; diff --git a/src/layout/MainLayout/Drawer/DrawerContent/Navigation/NavCollapse.js b/src/layout/MainLayout/Drawer/DrawerContent/Navigation/NavCollapse.js index 4b5bf95..c333288 100644 --- a/src/layout/MainLayout/Drawer/DrawerContent/Navigation/NavCollapse.js +++ b/src/layout/MainLayout/Drawer/DrawerContent/Navigation/NavCollapse.js @@ -27,7 +27,7 @@ import Transitions from 'components/@extended/Transitions'; import useConfig from 'hooks/useConfig'; import { dispatch, useSelector } from 'store'; import { activeItem } from 'store/reducers/menu'; -import { MenuOrientation, ThemeMode } from 'config'; +import { MenuOrientation } from 'config'; // assets import { BorderOutlined, DownOutlined, UpOutlined, RightOutlined } from '@ant-design/icons'; diff --git a/src/layout/MainLayout/Drawer/DrawerContent/Navigation/navitemdemo.js b/src/layout/MainLayout/Drawer/DrawerContent/Navigation/navitemdemo.js deleted file mode 100644 index f92350a..0000000 --- a/src/layout/MainLayout/Drawer/DrawerContent/Navigation/navitemdemo.js +++ /dev/null @@ -1,99 +0,0 @@ -import PropTypes from 'prop-types'; -import { forwardRef, useEffect } from 'react'; -import { Link } from 'react-router-dom'; - -// material-ui -import { useTheme } from '@mui/material/styles'; -import { useMediaQuery, Avatar, Chip, ListItemButton, ListItemText, Typography } from '@mui/material'; - -// project imports -import { ThemeMode } from 'config'; -import { dispatch, useSelector } from 'store'; -import { activeComponent, openComponentDrawer } from 'store/reducers/menu'; - -// ==============================|| NAVIGATION - LIST ITEM ||============================== // - -const NavItem = ({ item }) => { - const theme = useTheme(); - const matchesMD = useMediaQuery(theme.breakpoints.down('md')); - - const menu = useSelector((state) => state.menu); - const { openComponent } = menu; - - let itemTarget = '_self'; - if (item.target) { - itemTarget = '_blank'; - } - - let listItemProps = { component: forwardRef((props, ref) => ) }; - if (item?.external) { - listItemProps = { component: 'a', href: item.url, target: itemTarget }; - } - - const itemHandler = (id) => { - dispatch(activeComponent({ openComponent: id })); - if (matchesMD) dispatch(openComponentDrawer({ componentDrawerOpen: false })); - }; - - // active menu item on page load - useEffect(() => { - const currentIndex = document.location.pathname - .toString() - .split('/') - .findIndex((id) => id === item.id); - if (currentIndex > -1) { - dispatch(activeComponent({ openComponent: item.id })); - } - // eslint-disable-next-line - }, []); - - const textColor = theme.palette.mode === ThemeMode.DARK ? 'grey.400' : 'text.primary'; - const iconSelectedColor = theme.palette.mode === ThemeMode.DARK ? 'text.primary' : 'primary.main'; - - return ( - itemHandler(item.id)} - selected={openComponent === item.id} - sx={{ - pl: 4, - py: 1, - mb: 0.5, - '&:hover': { - bgcolor: theme.palette.mode === ThemeMode.DARK ? 'divider' : 'primary.lighter' - }, - '&.Mui-selected': { - bgcolor: theme.palette.mode === ThemeMode.DARK ? 'divider' : 'primary.lighter', - borderRight: `2px solid ${theme.palette.primary.main}`, - '&:hover': { - bgcolor: theme.palette.mode === ThemeMode.DARK ? 'divider' : 'primary.lighter' - } - } - }} - > - - {item.title} - - } - /> - {item.chip && ( - {item.chip.avatar}} - /> - )} - - ); -}; - -NavItem.propTypes = { - item: PropTypes.object -}; - -export default NavItem; diff --git a/src/layout/MainLayout/Drawer/DrawerHeader/index.js b/src/layout/MainLayout/Drawer/DrawerHeader/index.js index c1c0313..4485d8a 100644 --- a/src/layout/MainLayout/Drawer/DrawerHeader/index.js +++ b/src/layout/MainLayout/Drawer/DrawerHeader/index.js @@ -13,9 +13,6 @@ import useConfig from 'hooks/useConfig'; import logo from 'assets/images/doormile-logo.png' import logo1 from 'assets/images/doormile-mark.png' -// doormile-logo.png is a white asset; this recolours it to brand red (#C01227) for the light sidebar background. -const DOORMILE_RED_FILTER = 'brightness(0) saturate(100%) invert(14%) sepia(85%) saturate(4649%) hue-rotate(345deg) brightness(97%) contrast(92%)'; - // ==============================|| DRAWER HEADER ||============================== // const DrawerHeader = ({ open }) => { @@ -37,8 +34,6 @@ const DrawerHeader = ({ open }) => { paddingLeft: isHorizontal ? { xs: '24px', lg: '0' } : open ? '24px' : 0 }} > - {/* */} - {(open) && a(c, '18'); const ring = (c) => a(c, '26'); const edge = (c) => a(c, '55'); -const pillFieldSx = (color) => ({ - cursor: 'pointer', - '& .MuiOutlinedInput-root': { - borderRadius: '10px', - bgcolor: '#ffffff', - fontWeight: 600, - color: DT.textPrimary, - paddingRight: '8px', - cursor: 'pointer', - transition: 'border-color 0.15s, box-shadow 0.15s, background-color 0.2s', - '& fieldset': { borderColor: '#e2e8f0', borderWidth: 1 }, - '&:hover fieldset': { borderColor: '#cbd5e1' }, - '&.Mui-focused': { boxShadow: `0 0 0 3px ${ring(color)}` }, - '&.Mui-focused fieldset': { borderColor: '#C01227', borderWidth: 1.5 } - }, - '& .MuiAutocomplete-endAdornment .MuiSvgIcon-root': { color: color } -}); - // Status palette — drives the pill tabs and per-row badges. const STATUS_META = { active: { label: 'Active', color: '#10b981', icon: MdCheckCircle, statusKey: 'active' }, @@ -202,7 +184,7 @@ const Clients1 = () => { const [latlong, setLatlong] = useState({}); const [editClient, setEditClient] = useState({}); const [page, setPage] = useState(0); - const [tabStatus, setTabStatus] = useState('Active'); + const [, setTabStatus] = useState('Active'); const handleChangePage = (event, newPage) => { setPage(newPage); @@ -1785,14 +1767,6 @@ const Clients1 = () => { variant="outlined" fullWidth value={latlong.lng} - // onChange={(e) => { - // setLongi(e.target.value.toString()) - // setEditClient({ - // ...editClient, - // longitude: - // e.target.value.toString(), - // }); - // }} /> diff --git a/src/pages/nearle/clients/createclient.js b/src/pages/nearle/clients/createclient.js index e44eb07..ceb5c0e 100644 --- a/src/pages/nearle/clients/createclient.js +++ b/src/pages/nearle/clients/createclient.js @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; // material-ui import { useTheme } from '@mui/material/styles'; -import { Box, Button, FormLabel, Grid, InputLabel, MenuItem, Select, Stack, TextField, Typography, useMediaQuery } from '@mui/material'; +import { Button, Grid, InputLabel, MenuItem, Select, Stack, TextField, Typography, useMediaQuery } from '@mui/material'; // third-party // import { PatternFormat } from 'react-number-format'; @@ -55,8 +55,6 @@ const Createclient = () => { const [loading, setLoading] = useState(false); useEffect(() => { - // fetchprofiledetails(localStorage.getItem('appuserid')); - // fetchprofiledetails(181); if (localStorage.getItem('tenantid')) { fetchtenantinfo(localStorage.getItem('tenantid')); } @@ -93,41 +91,6 @@ const Createclient = () => { // console.log(alertmessage) }; - const fetchprofiledetails = async (userid) => { - if (userid) { - setLoading(true); - try { - await axios - .get(`${process.env.REACT_APP_URL2}/tenants/getclient?id=${userid}`) - .then((res) => { - console.log(res); - if (res.data.message === 'Successful') { - let res1 = res.data.details; - setMobilenumber(res1.contactno); - setEmailaddress(res1.primaryemail); - setAddress(res1.address); - setCity(res1.city); - setZipcode(res1.postcode); - setState(res1.state); - setSuburb(res1.suburb); - setLatlong({ - lat: res1.latitude, - lng: res1.longitude - }); - } - setLoading(false); - }) - .catch((err) => { - console.log(err); - setLoading(false); - }); - } catch (err) { - console.log(err); - setLoading(false); - } - } - }; - const fetchtenantinfo = async (tid) => { setLoading(true); await axios @@ -256,10 +219,6 @@ const Createclient = () => { autoHideDuration: 2000 }); navigate('/clients'); - // setTimeout(()=>{ - // fetchprofiledetails(localStorage.getItem('appuserid')); - - // },2000) } else if (res.data.message == 'Customer Already available') { enqueueSnackbar('Customer Already available', { variant: 'error', diff --git a/src/pages/nearle/customers/customers.js b/src/pages/nearle/customers/customers.js index 7eca508..0f0cc18 100644 --- a/src/pages/nearle/customers/customers.js +++ b/src/pages/nearle/customers/customers.js @@ -36,8 +36,6 @@ import { MdLocationOn, MdEdit, MdGroups, - MdHowToReg, - MdPlace, MdOutlineGroups, MdOutlineHowToReg, MdOutlinePlace @@ -273,14 +271,6 @@ export default function Customers() { } }, [address]); - // useEffect(() => { - // selectedCustomer && - // setLatlong({ - // lat: selectedCustomer.latitude, - // lng: selectedCustomer.longitude - // }); - // }, [selectedCustomer]); - // ==============================|| getallcustomers (customers) ||============================== // const { diff --git a/src/pages/nearle/deliveries/deliveries.js b/src/pages/nearle/deliveries/deliveries.js index 41a4cc0..e546547 100644 --- a/src/pages/nearle/deliveries/deliveries.js +++ b/src/pages/nearle/deliveries/deliveries.js @@ -18,7 +18,6 @@ import { MdStorefront, MdLocationOn, MdDirectionsBike, - MdLocalShipping, MdNotificationsActive, MdPersonPin, MdHistoryToggleOff, @@ -325,7 +324,6 @@ const Deliveries = () => { const [tabstatus, setTabstatus] = useState('Pending'); const [tabvalue, setTabvalue] = useState(0); const [open, setOpen] = useState(false); - const [datestatus, setDatestatus] = useState('Today'); const [kms, setKms] = useState(''); const [cumulativekms, setCumulativeKms] = useState(); const [deliveryamount, setDeliveryamount] = useState(); @@ -339,7 +337,6 @@ const Deliveries = () => { const tenantRef = useRef(null); const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(50); - const [totalCount, setTotalCount] = React.useState(); const [productCollapse, setProductCollapse] = useState(null); const [orderHeaderid, setOrderHeaderId] = useState(null); const [searchword, setSearchword] = useState(''); @@ -347,8 +344,6 @@ const Deliveries = () => { const [menuAnchorEl, setMenuAnchorEl] = React.useState(null); const [selectedRow, setSelectedRow] = useState(null); const [loading1, setLoading1] = useState(false); - const [anchorEl, setAnchorEl] = React.useState(null); - const [open2, setOpen2] = useState(''); const [cancelDeliveryOpen, setCancelDeliveryOpen] = useState(false); const [changeDialogOpen, setChangeDialogOpen] = useState(false); const [cancelFeed, setCancelFeed] = useState(''); @@ -488,7 +483,7 @@ const Deliveries = () => { countSourceRefetch(); // Refresh the all-statuses dataset feeding table + chips notifyRiderMutation.mutate(selectedRider.userfcmtoken); }, - onError: (err, { selectedRider, selectedRow }) => { + onError: (err, { selectedRow }) => { logger.error(`Failed to change rider for order ID ${selectedRow?.orderid}:`, err); opentoast(err.message, 'error'); setLoading1(false); @@ -524,43 +519,35 @@ const Deliveries = () => { if (i === 0) { setTabstatus('Pending'); setCurrentStatus('pending'); - setTotalCount(countData?.uncoveredLength); } if (i === 1) { setTabstatus('Assigned'); setCurrentStatus('accepted'); - setTotalCount(countData?.assignedLength); } if (i === 2) { setTabstatus('Arrived'); setCurrentStatus('arrived'); - setTotalCount(countData?.arrivedLength); } if (i === 3) { setTabstatus('Picked'); setCurrentStatus('picked'); - setTotalCount(countData?.pickedLength); } if (i === 4) { setTabstatus('Active'); setCurrentStatus('active'); - setTotalCount(countData?.activeLength); } if (i === 5) { setTabstatus('Skipped'); setCurrentStatus('skipped'); - setTotalCount(countData?.skippedLength); } if (i === 6) { setTabstatus('Delivered'); setCurrentStatus('delivered'); - setTotalCount(countData?.coveredLength); } if (i === 7) { setTabstatus('Cancelled'); setCurrentStatus('cancelled'); - setTotalCount(countData?.cancelLength); } console.log(i); setSearchword(''); @@ -807,13 +794,6 @@ const Deliveries = () => { queryKey: ['fetchCountData', appId, userid, startdate, enddate, rowsPerPage, debouncedSearch, tenantid, locationid, riderid, tabstatus], queryFn: () => fetchCountAPI(appId, userid, startdate, enddate, rowsPerPage, debouncedSearch, tenantid, locationid, riderid) }); - useEffect(() => { - console.log('countData', countData); - if (tabvalue === 0 && countData) { - setTotalCount(countData.uncoveredLength); - } - }, [countData]); - // ==============================|| fetchRidersList ||============================== // const { @@ -2597,11 +2577,6 @@ const Deliveries = () => { } else { setStartdate(dayjs(range.startDate).format('YYYY-MM-DD')); setEnddate(dayjs(range.endDate).format('YYYY-MM-DD')); - if (range.label) { - setDatestatus(range.label); - } else { - setDatestatus(''); - } } console.log(range); }} @@ -2646,11 +2621,6 @@ const Deliveries = () => { startDate: startOfMonth(addMonths(new Date(), -1)), endDate: endOfMonth(addMonths(new Date(), -1)) } - // { - // label: 'All', - // startDate: new Date(), - // endDate: addDays(new Date(), -1), - // }, ]} /> diff --git a/src/pages/nearle/dispatch/ActiveSection.js b/src/pages/nearle/dispatch/ActiveSection.js index e2a2d92..353f59d 100644 --- a/src/pages/nearle/dispatch/ActiveSection.js +++ b/src/pages/nearle/dispatch/ActiveSection.js @@ -96,7 +96,7 @@ const ActiveSection = ({ ); } - const renderActiveDeliveryCard = (o, i) => { + const renderActiveDeliveryCard = (o) => { const rid = o.rider_id || o.userid; const rider = riders.find((r) => String(r.id) === String(rid)); const color = getRiderColor(rid); diff --git a/src/pages/nearle/dispatch/Dispatch.js b/src/pages/nearle/dispatch/Dispatch.js index 532a2f4..17f0ddb 100644 --- a/src/pages/nearle/dispatch/Dispatch.js +++ b/src/pages/nearle/dispatch/Dispatch.js @@ -1,5 +1,5 @@ import React, { useState, useEffect, useMemo, useCallback, useRef } from 'react'; -import { MapContainer, TileLayer, Marker, Popup, Polyline, Tooltip, useMap, useMapEvents, ZoomControl } from 'react-leaflet'; +import { MapContainer, TileLayer, Marker, Popup, Polyline, Tooltip, useMap, ZoomControl } from 'react-leaflet'; import L from 'leaflet'; import 'leaflet/dist/leaflet.css'; // Side-effect import: patches L.Polyline so pathOptions.offset (in screen px) @@ -22,7 +22,6 @@ import { MdStraighten, MdLocationOn, MdMarkunreadMailbox, - MdMoveToInbox, MdPlace, MdTwoWheeler, MdNotes, @@ -59,7 +58,6 @@ import ProfitabilitySection from './ProfitabilitySection'; import ActiveSection from './ActiveSection'; import { fetchDeliveries, fetchAppLocations, getRiderPeriodicLogs, fetchRidersLogs, fetchBatchEfficiency } from '../../api/api'; import { - STATUS_STYLES, getStatusStyle, FINAL_STATUSES, SKIPPED_STATUSES, @@ -232,15 +230,6 @@ const getRowBatch = (r, fieldId = 'all', batches = BATCHES_DEFAULT) => { return getBatchForHour(d.hour() + d.minute() / 60, batches); }; -// Sits inside the Compare MapContainer and unpins any pinned popup whenever -// the operator clicks empty map space. Markers' click events do NOT bubble -// to the map, so this only fires on background clicks (which is what we -// want — clicking elsewhere should release the pin). -function CompareMapClickUnpin({ onUnpin }) { - useMapEvents({ click: () => onUnpin() }); - return null; -} - // Captures the Leaflet map instance for the parent component via a ref. Kept // available even after the two-map Compare layout was unified into one map, // since future per-step imperative zoom logic still needs a handle on the @@ -983,12 +972,6 @@ const ANALYSIS_BATCH_WINDOWS = [ // Tolerant field-name lookup so the Analysis card still renders cleanly even // if the API response uses slightly different keys than expected. -const analysisPick = (obj, keys) => { - for (const k of keys) { - if (obj && obj[k] != null && obj[k] !== '') return obj[k]; - } - return null; -}; const analysisFormatNum = (v) => { if (v == null) return '—'; if (typeof v === 'number') return v.toLocaleString('en-IN'); @@ -996,14 +979,6 @@ const analysisFormatNum = (v) => { if (Number.isFinite(n)) return n.toLocaleString('en-IN'); return String(v); }; -const analysisFormatKm = (v) => (v == null ? '—' : `${parseFloat(v).toFixed(1)} km`); -const analysisFormatRupees = (v) => (v == null ? '—' : `₹${parseFloat(v).toFixed(0)}`); -const analysisFormatPct = (v) => { - if (v == null) return '—'; - const n = parseFloat(v); - if (!Number.isFinite(n)) return '—'; - return `${n > 1 ? n.toFixed(1) : (n * 100).toFixed(1)}%`; -}; // Parse "HH:mm:ss" or "HH:mm" → seconds since midnight. Returns null when the // string is missing or malformed. Used to compute gantt percentages for the // rider timelines on the Analysis page — the API ships those fields as bare @@ -1163,7 +1138,6 @@ const Dispatch = ({ // Short-lived close timer for the general map order/marker popups. // Gives the cursor a ~200ms window to travel from the marker onto the popup // or vice versa without immediately triggering a close. - const activePopupMarkerRef = useRef(null); const popupHoverTimerRef = useRef(null); // Order shown in the centered popup overlay. Rendered outside the leaflet // map (see `dispatch-popup-center` overlay near the bottom of the JSX) so @@ -3150,7 +3124,7 @@ const Dispatch = ({ ? new Map(riderActualTracks.map((t) => [String(t.deliveryid), t.sequenceStep])) : null; - return ordersToRender.map((o, idx) => { + return ordersToRender.map((o) => { const rid = o.rider_id; const active = rid ? activeRiders.has(rid) : true; let color = getRiderColor(rid); @@ -3477,13 +3451,6 @@ const Dispatch = ({ return routes; }; - const toggleRider = (rid) => { - const newActive = new Set(activeRiders); - if (newActive.has(rid)) newActive.delete(rid); - else newActive.add(rid); - setActiveRiders(newActive); - }; - return (
{!embedded && ( @@ -5373,15 +5340,6 @@ const Dispatch = ({ (o) => o.deliveryid != null && String(o.deliveryid) === String(t.deliveryid) ); - const statusStyle = getStatusStyle(t.orderstatus); - const flagSvg = t.orderstatus - ? ` - - - ${isDelivered ? '' : ''} - ` - : ''; - const dropClasses = ['compare-step-pin']; if (isFocusedStep) dropClasses.push('is-focused'); if (isDelivered) dropClasses.push('is-delivered'); diff --git a/src/pages/nearle/invoice/invoicePreview.js b/src/pages/nearle/invoice/invoicePreview.js index 99c9847..4b9371b 100644 --- a/src/pages/nearle/invoice/invoicePreview.js +++ b/src/pages/nearle/invoice/invoicePreview.js @@ -9,12 +9,9 @@ import logo_nearle1 from '../../../assets/images/doormile-logo.png'; const DOORMILE_RED_FILTER = 'brightness(0) saturate(100%) invert(15%) sepia(93%) saturate(5437%) hue-rotate(346deg) brightness(81%) contrast(92%)'; import axios from 'axios'; import dayjs from 'dayjs'; -import Loader from 'components/Loader'; import { enqueueSnackbar } from 'notistack'; -import { DownloadOutlined, PrinterFilled } from '@ant-design/icons'; -import ReactToPrint, { useReactToPrint } from 'react-to-print'; -import { SearchOutlined, LeftOutlined, RightOutlined } from '@ant-design/icons'; -import ArrowBackIcon from '@mui/icons-material/ArrowBack'; +import { PrinterFilled } from '@ant-design/icons'; +import ReactToPrint from 'react-to-print'; // import jsPDF from 'jspdf'; import { useNavigate } from 'react-router-dom'; import { FaArrowLeft } from 'react-icons/fa6'; @@ -30,14 +27,9 @@ import { TableCell, TableContainer, TableHead, - TablePagination, TableRow, - Tabs, - Tab, Typography, Box, - OutlinedInput, - InputAdornment, IconButton, TextField, Tooltip, @@ -55,7 +47,6 @@ const InvoicePreview = () => { const navigate = useNavigate(); console.log('previewSelect', location.state); const componentRef = useRef(null); - const [tabletype, settabletype] = useState(true); const [paydialog, setpaydialog] = useState(false); const [refnumber, setRefnumber] = useState(''); const [remarks, setRemarks] = useState(''); diff --git a/src/pages/nearle/login.js b/src/pages/nearle/login.js index f621770..19eeb5b 100644 --- a/src/pages/nearle/login.js +++ b/src/pages/nearle/login.js @@ -1,7 +1,6 @@ import { useState, useEffect } from 'react'; -import { enqueueSnackbar, closeSnackbar } from 'notistack'; +import { enqueueSnackbar } from 'notistack'; import AnimateButton from 'components/@extended/AnimateButton'; -import OtpInput from 'react18-input-otp'; import { Box, Card, CardContent, Stack, TextField, Button, Typography, Link, FormLabel, IconButton, InputAdornment } from '@mui/material'; import { useTheme } from '@mui/material/styles'; @@ -11,7 +10,6 @@ import Loader from 'components/Loader'; import doormileLogo from 'assets/images/doormile-logo.png'; import { useSelector, useDispatch } from 'react-redux'; import { OpenToast } from 'components/third-party/OpenToast'; -import { closeGlobalToast, GlobalToast } from 'components/nearle_components/GlobalToast'; import Visibility from '@mui/icons-material/Visibility'; import VisibilityOff from '@mui/icons-material/VisibilityOff'; import { setLoginUser } from 'store/reducers/loginUserSlice'; @@ -23,18 +21,15 @@ const DOORMILE_RED_FILTER = 'brightness(0) saturate(100%) invert(15%) sepia(93%) const Login = () => { const dispatch = useDispatch(); const fcmtoken = useSelector((state) => state.fcm); - const permission = useSelector((state) => state.fcm.permission); const theme = useTheme(); const [loading, setLoading] = useState(false); let navigate = useNavigate(); - const [otp, setOtp] = useState(''); - const [currentotp, setCurrentotp] = useState(''); - const [userinfo, setUserinfo] = useState({}); + const [, setOtp] = useState(''); const [username, setUsername] = useState(''); const [passwordStatus, setPasswordStatus] = useState(0); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); - const [isPassword, setIspassword] = useState(false); + const [isPassword] = useState(false); const [showPassword, setShowPassword] = useState(false); const [showConfirmPassword, setShowConfirmPassword] = useState(false); const [userid, setUserid] = useState(0); @@ -89,7 +84,6 @@ const Login = () => { // user found, correct password else if (res.data.code == 200 && res.data.status) { OpenToast(res.data.message, 'success', 1000); - setUserinfo(res.data.details); const userinfo = res.data.details; dispatch(setLoginUser(userinfo)); localStorage.setItem('firstname', userinfo.firstname); @@ -113,21 +107,6 @@ const Login = () => { setLoading(false); } }; - const loginsuccessful = () => { - localStorage.setItem('firstname', userinfo.firstname); - localStorage.setItem('authname', userinfo.authname); - localStorage.setItem('roleid', userinfo.roleid); - localStorage.setItem('tenantid', userinfo.tenantid); - localStorage.setItem('partnerid', userinfo.partnerid); - localStorage.setItem('applocationid', userinfo.applocationid); - localStorage.setItem('userid', userinfo.userid); - localStorage.setItem('userfcmtoken', userinfo.userfcmtoken); - markSessionStart(); - closeGlobalToast(); // to close the pin snackbar - - navigate('/nearle/dispatch'); - }; - const opentoast = (message) => { enqueueSnackbar(message, { variant: 'error', @@ -287,14 +266,6 @@ const Login = () => { } loginsend(); } - // if (currentotp) { - // if (currentotp == otp) { - // loginsuccessful(); - // fetchAppLocations(); - // } else { - // opentoast('Invalid pin'); - // } - // } }} > diff --git a/src/pages/nearle/login1.js b/src/pages/nearle/login1.js index a60d320..b4f1134 100644 --- a/src/pages/nearle/login1.js +++ b/src/pages/nearle/login1.js @@ -1,6 +1,4 @@ import { useState, useEffect } from 'react'; -import { useSelector } from 'react-redux'; -// import AuthWrapper from 'sections/auth/AuthWrapper'; import { Box, Grid, @@ -39,7 +37,7 @@ const Login = () => { const isMobile = useMediaQuery(theme.breakpoints.down('md')); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); - const [alertmessage, setAlertmessage] = useState(''); + const [, setAlertmessage] = useState(''); const [checkusername, setCheckusername] = useState(false); // const [toast, setToast] = useState(false); const [loading, setLoading] = useState(false); @@ -107,11 +105,8 @@ const Login = () => { // setCheckusername(false); // } }) - .catch((err) => { - // if (err.response.data.message === 'No user found') { - + .catch(() => { setCheckusername(true); - // } }); } catch (err) { console.log(err); @@ -278,10 +273,6 @@ const Login = () => { Login} /> - - {/* - - */}
{ ); }; -export default Login1; +export default Login; diff --git a/src/pages/nearle/orders/OrdersPreview.js b/src/pages/nearle/orders/OrdersPreview.js index b973473..66a0c6d 100644 --- a/src/pages/nearle/orders/OrdersPreview.js +++ b/src/pages/nearle/orders/OrdersPreview.js @@ -17,7 +17,7 @@ import { Backdrop, IconButton } from '@mui/material'; -import React, { Fragment, useEffect, useMemo, useState } from 'react'; +import React, { Fragment, useEffect, useState } from 'react'; import { useTheme } from '@mui/material/styles'; import useMediaQuery from '@mui/material/useMediaQuery'; import { MobileCard, MobileCardList, MobileField, MobileFieldGrid } from 'components/nearle_components/MobileCard'; @@ -32,7 +32,7 @@ import Loader from 'components/Loader'; import CircularLoader from 'components/CircularLoader'; import { Empty } from 'antd'; import HoverSocialCard from 'components/cards/statistics/HoverSocialCard'; -import { DashboardFilled, OpenAIFilled } from '@ant-design/icons'; +import { DashboardFilled } from '@ant-design/icons'; import { MdDirectionsBike } from 'react-icons/md'; import { FaMapLocationDot } from 'react-icons/fa6'; import { HiOutlineArrowLeft } from 'react-icons/hi'; @@ -234,9 +234,7 @@ const OrdersPreview = () => { const { data: paymentModes = [], - isLoading: paymentModesLoading, - isError: paymentModesError, - error: paymentModesErrorMessage + isLoading: paymentModesLoading } = useQuery({ queryKey: ['paymentmodes'], queryFn: fetchPaymentType @@ -246,24 +244,13 @@ const OrdersPreview = () => { const { data: ridersList = [], - isLoading: ridersListLoading, - isError: ridersListError, - error: ridersListErrorMessage, - refetch: ridersListRefetch + isLoading: ridersListLoading } = useQuery({ queryKey: ['ridersList', appId], // Unique key for caching & re-fetching queryFn: fetchRidersList, enabled: appId !== 0 // Ensures query runs only when appId is valid }); - const getRiderName = async (userid) => { - await ridersList.map((rider) => { - if (rider.userid == userid) { - return rider.firstname; - } - }); - }; - // ======================================================= || notifyRiderMutation || ======================================================= const notifyRiderMutation = useMutation({ diff --git a/src/pages/nearle/orders/createorder1.js b/src/pages/nearle/orders/createorder1.js index 4ea79d4..f986ed8 100644 --- a/src/pages/nearle/orders/createorder1.js +++ b/src/pages/nearle/orders/createorder1.js @@ -9,7 +9,6 @@ import { Button, TextField, Autocomplete, - Chip, Divider, DialogTitle, DialogContent, @@ -19,7 +18,6 @@ import { IconButton, Switch, OutlinedInput, - FormGroup, FormControlLabel, Box, Card, @@ -28,7 +26,7 @@ import { import CloseIcon from '@mui/icons-material/Close'; import { calculateDrivingDistance, calculateTotalCharge } from '../../../utils/distance'; import { Empty } from 'antd'; -import { FaPhoneAlt, FaBox, FaBoxes, FaTruck, FaArrowRight, FaArrowLeft, FaCheck, FaRoute, FaMoneyBillWave, FaChartLine, FaReceipt, FaPaperPlane } from 'react-icons/fa'; +import { FaPhoneAlt, FaBox, FaBoxes, FaArrowRight, FaArrowLeft, FaCheck, FaRoute, FaMoneyBillWave, FaChartLine, FaReceipt, FaPaperPlane } from 'react-icons/fa'; import { GiDoorHandle } from 'react-icons/gi'; import { FaLandmarkDome } from 'react-icons/fa6'; import ClearIcon from '@mui/icons-material/Clear'; @@ -39,8 +37,6 @@ import axios from 'axios'; import { useTheme } from '@mui/material/styles'; import Geocode from 'react-geocode'; import Loader from 'components/Loader'; -import * as geolib from 'geolib'; -import MainCard from 'components/MainCard'; import { FaUser } from 'react-icons/fa6'; import { DatePicker } from '@mui/x-date-pickers/DatePicker'; import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; @@ -50,7 +46,7 @@ import dayjs from 'dayjs'; import { enqueueSnackbar } from 'notistack'; var utc = require('dayjs/plugin/utc'); dayjs.extend(utc); -import { SearchOutlined, CloseOutlined, CalendarOutlined, ClockCircleOutlined, FileTextOutlined, MessageOutlined } from '@ant-design/icons'; +import { SearchOutlined, CalendarOutlined, ClockCircleOutlined, FileTextOutlined, MessageOutlined } from '@ant-design/icons'; import MyLocationIcon from '@mui/icons-material/MyLocation'; import HighlightOffIcon from '@mui/icons-material/HighlightOff'; import { OpenToast } from 'components/third-party/OpenToast'; @@ -58,7 +54,6 @@ import { MapContainer, TileLayer, Marker, Polyline, useMap } from 'react-leaflet import L from 'leaflet'; import 'leaflet/dist/leaflet.css'; import './OrdersRedesign.css'; -import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward'; import AnimateButton from 'components/@extended/AnimateButton'; const pickupIcon = typeof window !== 'undefined' ? new L.Icon({ @@ -192,14 +187,12 @@ const Createorder1 = () => { const tenantRef = useRef(null); const [inputValue1, setInputValue1] = React.useState(''); const [inputValue2, setInputValue2] = React.useState(''); - const [tenanatLocoId, setTenanatLocoId] = useState(localStorage.getItem('locationid')); - const [isLocation, setIsLocation] = useState(false); const textFieldRef1 = useRef(null); const textFieldRef1a = useRef(null); const textFieldRef2 = useRef(null); const [appId, setAppId] = useState(0); const [open, setOpen] = useState(false); - const [clientdetail, setClientdetail] = useState([]); + const [, setClientdetail] = useState([]); const [startdate, setStartdate] = useState(dayjs().format('MM-DD-YYYY')); // const [starttime, setStatrttime] = useState(`${dayjs().format('MM-DD-YYYY')} 08:00:00`); const [starttime, setStatrttime] = useState(); @@ -224,16 +217,15 @@ const Createorder1 = () => { const [minKm, setMinKm] = useState(0); const [totalCharge, setTotalCharge] = useState(0); const [subCat, setSubCat] = useState([]); - const [subCatName, setSubCatName] = useState('Select '); + const [, setSubCatName] = useState('Select '); const [subCatId, setSubCatId] = useState(0); - const [weight, setWeight] = useState(''); + const [weight] = useState(''); const [tenantid, setTenantid] = useState(0); const [locationid, setLocationid] = useState(0); - const [selectedCatChip, setSelectedCatChip] = useState(null); const [isCustomerOpen, setIsCustomerOpen] = useState(false); const [searchCustList, setSearchCustList] = useState(''); const [customerlist, setCustomerlist] = useState([]); - const [defaultPickup, setDefaultPickup] = useState(null); + const [, setDefaultPickup] = useState(null); const [pickCust, setPickCust] = useState(null); const [dropCust, setDropCust] = useState(null); const [pickordrop, setpickordrop] = useState(0); // 1 ->pick 2 -> drop @@ -330,20 +322,6 @@ const Createorder1 = () => { appId && fetchtenantinfolist(); }, [appId]); - const handleChipClick = (chipLabel) => { - setSelectedCatChip(chipLabel); - }; - - const chipStyle = (chipLabel) => ({ - cursor: 'pointer', - backgroundColor: selectedCatChip === chipLabel ? theme.palette.primary.main : 'default', - color: selectedCatChip === chipLabel ? '#fff' : '', - '&:hover': { - backgroundColor: selectedCatChip === chipLabel ? theme.palette.primary.main : theme.palette.primary.light, - color: '#fff' - } - }); - const fetchTenantPricing = async (id) => { try { const pricingResponse = await axios.get(`${process.env.REACT_APP_URL}/tenants/gettenantpricing/?tenantid=${id}`); @@ -473,9 +451,9 @@ const Createorder1 = () => { console.log('endtime', `${dayjs().format('MM-DD-YYYY')} ${closetime} `); let arr = []; for ( - let i = `${dayjs().format('MM-DD-YYYY')} ${opentime}`, j = 0; + let i = `${dayjs().format('MM-DD-YYYY')} ${opentime}`; dayjs(`${dayjs().format('MM-DD-YYYY')} ${closetime} `).diff(i, 'm') >= 0; - j++, i = dayjs(i).add(30, 'm') + i = dayjs(i).add(30, 'm') ) { arr.push(i); } @@ -859,7 +837,6 @@ const Createorder1 = () => { // radius: 100000 //km to m }).getBounds() }); - let arr = []; // Event listener for autocomplete place changed autocomplete.addListener('place_changed', () => { const place = autocomplete.getPlace(); diff --git a/src/pages/nearle/orders/details.js b/src/pages/nearle/orders/details.js index 07fd99c..cd9afbc 100644 --- a/src/pages/nearle/orders/details.js +++ b/src/pages/nearle/orders/details.js @@ -1,39 +1,15 @@ -import { - useEffect, - useState, - Fragment - // useReducer -} from 'react'; +import { useEffect, useState, Fragment } from 'react'; import BorderColorIcon from '@mui/icons-material/BorderColor'; -import { - // Navigate, - // useSearchParams, - useLocation, - useNavigate -} from 'react-router-dom'; +import { useLocation, useNavigate } from 'react-router-dom'; import axios from 'axios'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; -import { - // UserOutlined, - EnvironmentOutlined, - EditTwoTone - // DeleteTwoTone -} from '@ant-design/icons'; -// import WomanIcon from '@mui/icons-material/Woman'; -// import { Link } from 'react-router-dom'; -// import SoupKitchenIcon from '@mui/icons-material/SoupKitchen'; +import { EnvironmentOutlined, EditTwoTone } from '@ant-design/icons'; import DirectionsCarIcon from '@mui/icons-material/DirectionsCar'; import { KeyboardArrowUp, KeyboardArrowDown } from '@mui/icons-material'; -// import { PopupTransition } from 'components/@extended/Transitions'; -// import { useDispatch } from 'react-redux'; -// import { openSnackbar } from 'store/reducers/snackbar'; // assets import { DeleteFilled, NotificationOutlined } from '@ant-design/icons'; var utc = require('dayjs/plugin/utc'); -// import { groupBy } from "core-js/actual/array/group-by"; -// import "lodash.chunk"; -// var chunk = require('lodash.chunk'); import { Grid, Typography, @@ -79,13 +55,8 @@ import { PopupTransition } from 'components/@extended/Transitions'; import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined'; import MainCard from 'components/MainCard'; import Loader from 'components/Loader'; -// import AlertCustomerDelete from 'sections/apps/customer/AlertCustomerDelete'; import dayjs from 'dayjs'; dayjs.extend(utc); -// import { Link as RouterLink } from 'react-router-dom'; -// import PlayCircleFilled from '@mui/icons-material/PlayCircleFilled'; -// import SmileFilled from '@mui/icons-material/Mood'; -// import HeartFilled from '@mui/icons-material/Favorite'; import { useTheme } from '@mui/material/styles'; import useMediaQuery from '@mui/material/useMediaQuery'; @@ -181,23 +152,6 @@ const Details = () => { const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down('md')); - // const fetchorderdetails = async () => { - // setLoading(true); - // await axios - // .get(`${process.env.REACT_APP_URL}/orders/orderbyid/?orderheaderid=${orderheaderid}`) - - // .then((res) => { - // console.log(res); - - // setLoading(false); - // }) - // .catch((err) => { - // console.log(err); - // setLoading(false); - // }); - - // }; - const fetchorderaddons = async () => { setLoading(true); await axios @@ -249,21 +203,6 @@ const Details = () => { console.log('res'); console.log(res); setOrderarr(res.data.Details || []); - // let result = res.data.Details.find((res1) => res1.orderheaderid == searchParams.get('id')) - // orderheaderid - // console.log(result) - // setOrderaddons(result.orderaddons); - // setVenuetype(result.venuetype) - // setOtherinstructions(result.remarks) - // console.log("res"); - // let result = _.chain(res.data.Details) - - // .groupBy("shiftid") - - // .map((value, key) => ({shiftid:key, locationaddress: value[0].locationaddress, roles: value })) - // .value() - - // setcategoryarr(result); console.log('categoryarr'); setcategoryarr(res.data.Details); console.log(res.data.Details); @@ -305,15 +244,7 @@ const Details = () => { const cancelorder = async () => { await axios .put(`${process.env.REACT_APP_URL2}/orders/cancel`, { - // "Orderheaderid": parseInt(orderheaderid), - // "Tenantid": parseInt(tenantid), - // "Orderstatus": "cancelled", - // "Currentdatetime": dayjs().format('YYYY-MM-DD HH:mm:ss'), - // "Cod": false, - // "Remarks": "", orderheaderid: parseInt(orderheaderid), - // "orderdetailid":78, - // "shiftid":788, orderstatus: 'cancelled', cancelled: dayjs().format('YYYY-MM-DD HH:mm:ss'), unserviceable: invoiceeligible ? 0 : 1 @@ -443,20 +374,10 @@ const Details = () => { fetchorderaddons(); fetchorderattires(); fetchassignedcount(); - // fetchuserdetails(); console.log(location.state || ''); - // setOrderid(location.state.orderid || ''); - // setEventlocation(location.state.eventlocation || ''); - // setEventlocation(address || []); - - // setOrderdate(dayjs(location.state.orderdate.substring(0, 10)).format('MM/DD/YYYY') || ''); - // setDuedate(dayjs(location.state.orderdate.substring(0, 10)).format('MM/DD/YYYY') || '') - // setEventname(location.state.eventname || ''); - // setClientname(location.state.tenantname || '') } else { setLoading(false); } - // fetchorderdetails(); console.log(orderheaderid, tenantid); }, [orderheaderid, tenantid, assignedpendingcount]); @@ -522,12 +443,6 @@ const Details = () => { .then((res) => { console.log(res); if (res.data.message === 'Successfully created') { - // if (orderheaderid && tenantid) { - // fetchorderdetails(); - // fetchorderaddons(); - // fetchorderattires(); - // } - enqueueSnackbar('Roles assigned successfully', { variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' }, @@ -631,32 +546,6 @@ const Details = () => { }); }; - // const updateorderstatus = async () => { - - // await axios.put(`${process.env.REACT_APP_URL2}/orders/updateorderstatus`,{ - // "orderheaderid":orderheaderid, - // "tenantid":tenantid, - // "orderstatus":"processing", - // "pending":"", - // "processing":dayjs().format('YYYY-MM-DD HH:mm:ss'), - // "completed":"" - // }) - // .then((res) => { - // console.log(res) - // fetchorderdetails(); - // fetchorderaddons(); - // fetchorderattires(); - - // }) - // .catch((err) => { - // console.log(err) - // fetchorderdetails(); - // fetchorderaddons(); - // fetchorderattires(); - // }) - - // } - const fetchassignedcount = async () => { // console.log(obj1) await axios diff --git a/src/pages/nearle/orders/multipleOrders.js b/src/pages/nearle/orders/multipleOrders.js index 834226f..4898c35 100644 --- a/src/pages/nearle/orders/multipleOrders.js +++ b/src/pages/nearle/orders/multipleOrders.js @@ -55,9 +55,7 @@ import { CalendarOutlined, ClockCircleOutlined, FileTextOutlined, - InboxOutlined, - LockOutlined, - CheckCircleFilled + InboxOutlined } from '@ant-design/icons'; import { Empty } from 'antd'; import { FaUser, FaTruck, FaUsers, FaPaperPlane, FaRoute, FaMoneyBillWave, FaBoxes, FaReceipt } from 'react-icons/fa'; @@ -66,7 +64,6 @@ import { MdOutlineCloudUpload } from 'react-icons/md'; import Loader from 'components/Loader'; import CircularLoader from 'components/CircularLoader'; -import AnimateButton from 'components/@extended/AnimateButton'; import { MobileCard, MobileCardList, MobileField, MobileFieldGrid } from 'components/nearle_components/MobileCard'; import './OrdersRedesign.css'; diff --git a/src/pages/nearle/orders/orders.js b/src/pages/nearle/orders/orders.js index 5021f56..942c5e2 100644 --- a/src/pages/nearle/orders/orders.js +++ b/src/pages/nearle/orders/orders.js @@ -1,10 +1,9 @@ import * as React from 'react'; import { useState, useEffect, Fragment, useRef } from 'react'; -import { DashboardOutlined, DeleteFilled, DeleteOutlined, ShoppingCartOutlined } from '@ant-design/icons'; +import { DeleteFilled, DeleteOutlined, ShoppingCartOutlined } from '@ant-design/icons'; import { Empty } from 'antd'; import dayjs from 'dayjs'; import { useQuery, useMutation, useInfiniteQuery } from '@tanstack/react-query'; -import HoverSocialCard from 'components/cards/statistics/HoverSocialCard'; import { useTheme } from '@mui/material/styles'; import { CloseOutlined } from '@ant-design/icons'; import { PopupTransition } from 'components/@extended/Transitions'; @@ -12,9 +11,7 @@ import CircularLoader from 'components/CircularLoader'; import Loader from 'components/Loader'; import { KeyboardArrowDownOutlined, KeyboardArrowUpOutlined } from '@mui/icons-material'; -import { PiMapPinLineDuotone } from 'react-icons/pi'; import { - MdOutlineDateRange, MdPersonOff, MdEventBusy, MdLocalShipping, @@ -28,16 +25,11 @@ import { MdMyLocation, MdGroups, MdPlace, - MdStraighten, - MdCurrencyRupee, - MdInventory2, MdHistoryToggleOff, MdCalendarMonth } from 'react-icons/md'; -import { VscArchive } from 'react-icons/vsc'; import DateFilterDialog from 'components/DateFilterDialog'; import DebounceSearchBar from 'components/nearle_components/DebounceSearchBar'; -import TitleCard from 'components/nearle_components/TitleCard'; import MainCard from 'components/MainCard'; import { OpenToast } from 'components/third-party/OpenToast'; import { OrdersTableSkeleton } from './OrdersTableSkeleton'; @@ -46,11 +38,6 @@ import PageHeader from 'components/nearle_components/PageHeader'; import StatCard from 'components/nearle_components/StatCard'; import AiImage from '../../../assets/images/aiImage.png'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; -import EnergySavingsLeafIcon from '@mui/icons-material/EnergySavingsLeaf'; -import DirectionsBikeOutlinedIcon from '@mui/icons-material/DirectionsBikeOutlined'; -import WarningIcon from '@mui/icons-material/Warning'; -import BoltIcon from '@mui/icons-material/Bolt'; -import { ArrowRightAltOutlined } from '@mui/icons-material'; import { HiOutlineArrowLeft } from 'react-icons/hi'; import { IoReload } from 'react-icons/io5'; @@ -62,8 +49,6 @@ import { Avatar, Button, Grid, - Tabs, - Tab, IconButton, Stack, TextField, @@ -89,9 +74,6 @@ import { SpeedDialAction, Badge, Divider, - AccordionDetails, - AccordionSummary, - Accordion, Paper, Box } from '@mui/material'; @@ -118,7 +100,6 @@ import { MobileCard, MobileCardList, MobileField, MobileFieldGrid } from 'compon import { useNavigate } from 'react-router'; import CSVExport from 'components/third-party/ReactTable'; import Dispatch from '../dispatch/Dispatch'; -// import usePreventReload from 'hooks/usePreventReload'; // ============================================================================ // Design tokens — shared with deliveries / tenants / customers / pricing / @@ -255,8 +236,8 @@ const Orders = () => { const [dispatchPreviewData, setDispatchPreviewData] = useState(null); const [deliverylist, setDeliverylist] = useState([]); const [deliveryDetails, setDeliveryDetails] = useState([]); - const [zoneData, setZoneData] = useState(null); - const [metaData, setMetaData] = useState(null); + const [, setZoneData] = useState(null); + const [, setMetaData] = useState(null); const [aiMode] = useState(0); const [csvExportData, setCsvExportData] = useState([]); const [finaldeliveryList, setFinalDeliveryList] = useState([]); diff --git a/src/pages/nearle/reports/MapWithRouteGoogle.js b/src/pages/nearle/reports/MapWithRouteGoogle.js deleted file mode 100644 index e7e1e5e..0000000 --- a/src/pages/nearle/reports/MapWithRouteGoogle.js +++ /dev/null @@ -1,91 +0,0 @@ -import React, { useEffect, useRef } from 'react'; -import { LoadScriptNext, GoogleMap } from '@react-google-maps/api'; - -const containerStyle = { - width: '100%', - height: '90vh' -}; - -const MapWithRouteGoogle = ({ coordinates, additionalProps, setMapOpen }) => { - const mapRef = useRef(null); - - /** Convert coordinates to numbers */ - const numericCoordinates = coordinates - .map((c) => { - const lat = Number(c.lat); - const lng = Number(c.lng); - return isNaN(lat) || isNaN(lng) ? null : { lat, lng }; - }) - .filter(Boolean); - - if (numericCoordinates.length < 2) { - return
No route data available
; - } - - const start = numericCoordinates[0]; - const end = numericCoordinates[numericCoordinates.length - 1]; - - /** Map loaded callback */ - const onMapLoad = (map) => { - // draw markers - new window.google.maps.Marker({ - position: start, - map, - label: 'S', - title: `Start: ${additionalProps?.riderStart}` - }); - - new window.google.maps.Marker({ - position: end, - map, - label: 'E', - title: `End: ${additionalProps?.riderEnd}` - }); - - // draw rider route (point-to-point) - const route = new window.google.maps.Polyline({ - path: numericCoordinates, - geodesic: false, - strokeColor: '#1A73E8', - strokeOpacity: 1.0, - strokeWeight: 4 - }); - - route.setMap(map); - - // auto fit - const bounds = new window.google.maps.LatLngBounds(); - numericCoordinates.forEach((p) => bounds.extend(p)); - map.fitBounds(bounds); - }; - - return ( - <> - - - - - {/* Polyline and markers added via onLoad */} - - - - ); -}; - -export default MapWithRouteGoogle; diff --git a/src/pages/nearle/reports/ordersDetails.js b/src/pages/nearle/reports/ordersDetails.js index f6a837d..c78bca8 100644 --- a/src/pages/nearle/reports/ordersDetails.js +++ b/src/pages/nearle/reports/ordersDetails.js @@ -16,8 +16,6 @@ import { Divider, Grid, IconButton, - List, - ListItem, Paper, Skeleton, Stack, @@ -51,7 +49,6 @@ import { MdCheckCircle, MdCancel, MdList, - MdLocalShipping, MdStraighten, MdCurrencyRupee, MdMap, diff --git a/src/pages/nearle/requests/requests.js b/src/pages/nearle/requests/requests.js index e2ecf9f..0382b6f 100644 --- a/src/pages/nearle/requests/requests.js +++ b/src/pages/nearle/requests/requests.js @@ -242,23 +242,6 @@ const Requests = () => { // fetchroleslist(); }, []); - // useEffect(() => { - - // if (alertmessage && toast) { - // dispatch( - // openSnackbar({ - // open: true, - // message: alertmessage, - // variant: 'alert', - // anchorOrigin: { vertical: 'top', horizontal: 'right' }, - // alert: { - // color: 'error', - - // } - // }) - // ) - // } - // }, [toast]) const opentoast = (message) => { enqueueSnackbar(message, { variant: 'error', @@ -486,17 +469,6 @@ const Requests = () => { .then((res) => { console.log('res:', res); if (res.data.message === 'Update successful') { - // dispatch( - // openSnackbar({ - // open: true, - // message: 'Client Detail Updated Successfully', - // variant: 'alert', - // anchorOrigin: { vertical: 'top', horizontal: 'right' }, - // alert: { - // color: 'success' - // } - // }) - // ) enqueueSnackbar('Client Details Updated Successfully', { variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' }, @@ -626,63 +598,6 @@ const Requests = () => { } }; - // const rolepriceupdate = async () => { - // console.log('submit') - // let arr = []; - // let objcheck = false; - // rolesarr.map((val) => { - // if (!val.role || !val.cost) { - // objcheck = true; - // } - // arr.push({ - // serviceid: 0, - // tenantid: currenttenantid, - // categoryid: val.categoryid, - // subcategoryid: val.subcategoryid, - // servicecode: val.servicecode, - // servicename: val.servicename, - // unitid: val.unitid, - // unitname: val.unitname, - // serviceamount: parseFloat(val.serviceamount), - // discountid: val.discountid, - // taxpercent: val.taxpercent, - // taxamount: val.taxamount, - // servicevalue: parseFloat(val.servicevalue), - - // }) - // }) - // console.log(arr) - // if (!objcheck) { - // try { - // setLoading(true) - // // await axios.post(`${process.env.REACT_APP_URL2}/clients/createservice`, arr) - // await axios.post(`${process.env.REACT_APP_URL2}/tenants/createservice`, arr) - - // // await axios.post(`${process.env.REACT_APP_URL2}/clients/createservice`, arr) - // .then((res) => { - // console.log('res:', res); - // if (res.data.message === "Successful") { - - // enqueueSnackbar('Service created Successfully', { variant: 'success',anchorOrigin: { vertical: 'top', horizontal: 'right' }, - // autoHideDuration: 3000 }) - // } - // setLoading(false) - // }).catch((err) => { - // console.log(err) - // setLoading(false) - // }) - - // } catch (err) { - // console.log(err); - // setLoading(false) - // } - // } else { - - // enqueueSnackbar('Fill all Details', { variant: 'error',anchorOrigin: { vertical: 'top', horizontal: 'right' }, - // autoHideDuration: 2000 }) - // } - // } - const handleRequestSort = (event, property) => { const isAsc = orderBy === property && order === 'asc'; setOrder(isAsc ? 'desc' : 'asc'); @@ -811,15 +726,9 @@ const Requests = () => { +1, - // }} sx={{ width: '100%' }} onChange={(e) => setAmount(e.target.value)} /> - {/* - */} {/* @@ -918,7 +827,7 @@ const Requests = () => { ))} {!loading && - visibleRows.map((row, index) => { + visibleRows.map((row) => { const isItemSelected = isSelected(row.sno); return ( { border: '1px solid #e0e0e0', textIndent: '10px', outline: 'none' - // ':hover': { - // border: '1px solid #00b0ff !important', - // backgroundColor:'blue' - // } }} onPlaceSelected={(place) => { setAddress(place.formatted_address); @@ -1813,20 +1718,6 @@ const Requests = () => { const [searchword, setSearchword] = useState(''); const [dialogopen, setDialogopen] = useState(false); - // const [expandopen, setExpandopen] = React.useState(''); - - // const setinitial = (val)=>{ - // if(val){ - - // console.log(val); - // setClientname(val.tenantname) - // }else{ - // setClientname('') - // } - // console.log(clientname) - - // } - useEffect(() => { if (localStorage.getItem('partnerid')) { clientdetailspending(localStorage.getItem('partnerid')); @@ -1834,33 +1725,6 @@ const Requests = () => { } }, []); - useEffect(() => { - // if (searchword) { - // if (tabvalue === 0) { - // let arr = clientapproved.filter((val) => { - // return (val.tenantname.toLowerCase().includes(searchword.toLowerCase()) - // || val.primarycontact.toLowerCase().includes(searchword.toLowerCase()) - // || val.primaryemail.toLowerCase().includes(searchword.toLowerCase()) - // || val.city.toString().toLowerCase().includes(searchword.toLowerCase()) - // ) - // }) - // console.log(arr) - // setRows([...arr]) - // } - // if (tabvalue === 1) { - // let arr = clientpending.filter((val) => { - // return (val.tenantname.toLowerCase().includes(searchword.toLowerCase()) - // || val.primarycontact.toLowerCase().includes(searchword.toLowerCase()) - // || val.primaryemail.toLowerCase().includes(searchword.toLowerCase()) - // || val.city.toString().toLowerCase().includes(searchword.toLowerCase()) - // ) - // }) - // console.log(arr) - // setRows([...arr]) - // } - // } - }, [searchword, tabvalue]); - const handleChangetab = (e, i) => { setTabvalue(i); if (i === 1) setRows(clientapproved); diff --git a/src/pages/nearle/riders/createrider.js b/src/pages/nearle/riders/createrider.js index 45ac77b..01d8f1f 100644 --- a/src/pages/nearle/riders/createrider.js +++ b/src/pages/nearle/riders/createrider.js @@ -16,23 +16,8 @@ import Loader from 'components/Loader'; import Geocode from 'react-geocode'; import { enqueueSnackbar } from 'notistack'; import { useNavigate } from 'react-router'; -// import { setLocationType } from 'react-geocode'; - -// const avatarImage = require.context('assets/images/users', true); - -// styles & constant -// const ITEM_HEIGHT = 48; -// const ITEM_PADDING_TOP = 8; -// const MenuProps = { -// PaperProps: { -// style: { -// maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP -// } -// } -// }; const Createrider = () => { - // const [role, setRole] = useState(''); const [mobilenumber, setMobilenumber] = useState(''); const [emailaddress, setEmailaddress] = useState(''); const [city, setCity] = useState(''); @@ -162,12 +147,6 @@ const Createrider = () => { const createprofile = async () => { console.log('res', businessname, businessno, mobilenumber, emailaddress, address, city, zipcode); - // if (!businessname) { - // opentoast('Fill Business name') - // } else if (!businessno) { - // opentoast('Fill Registration No') - // } - // else if (!firstname) { opentoast('Fill Full name'); } else if (!mobilenumber) { diff --git a/src/pages/nearle/riders/editRider.js b/src/pages/nearle/riders/editRider.js index f965bd8..2e5c12f 100644 --- a/src/pages/nearle/riders/editRider.js +++ b/src/pages/nearle/riders/editRider.js @@ -164,38 +164,10 @@ const EditRider = () => { }); }; - // const fetchpartnerlist = async () => { - // setLoading(true); - // await axios - // .get(`${process.env.REACT_APP_URL}/partners/getpartners`) - // .then((res) => { - // console.log('fetchpartnerlist', res); - // // if (res.data.status) { - // let arr = []; - // res.data.details.map((val) => { - // arr.push({ - // ...val, - // label: val.partnername - // }); - // }); - // setPartnerlist([...arr]); - // console.log(arr); - // // } - // setLoading(false); - // }) - // .catch((err) => { - // console.log(err); - // setLoading(false); - // }); - // }; // ==============================|| fetchAppLocations ||============================== // const fetchAppLocations = async () => { try { const locationRes = await axios.get(`${process.env.REACT_APP_URL}/partners/getlocations/?userid=${userid}`); - // const updatedLocations = [ - // ...locationRes.data.details, - // { locationname: 'All', applocationid: 0 } // Add your new object here - // ]; console.log('fetchAppLocations', locationRes.data.details); setPartnerlist(locationRes.data.details); } catch (err) { diff --git a/src/pages/nearle/riders/riders.js b/src/pages/nearle/riders/riders.js index e82eab0..06e90c2 100644 --- a/src/pages/nearle/riders/riders.js +++ b/src/pages/nearle/riders/riders.js @@ -398,7 +398,7 @@ const Riders = () => { } }); - const { data: activeSubsToday, isLoading: activeSubsTodayLoading } = useQuery({ + useQuery({ queryKey: ['activeSubstitutionsToday', appId, selectedDate.format('YYYY-MM-DD')], queryFn: async () => { try { diff --git a/src/react-app-env.d.js b/src/react-app-env.d.js deleted file mode 100644 index 6431bc5..0000000 --- a/src/react-app-env.d.js +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/src/routes/LoginRoutes.js b/src/routes/LoginRoutes.js index 27856d8..939893a 100644 --- a/src/routes/LoginRoutes.js +++ b/src/routes/LoginRoutes.js @@ -1,17 +1,10 @@ import { lazy } from 'react'; // project import -// import GuestGuard from 'utils/route-guard/GuestGuard'; import CommonLayout from 'layout/CommonLayout'; import Loadable from 'components/Loadable'; // render - login -// const AuthLogin = Loadable(lazy(() => import('pages/auth/login'))); -// const AuthRegister = Loadable(lazy(() => import('pages/auth/register'))); -// const AuthForgotPassword = Loadable(lazy(() => import('pages/auth/forgot-password'))); -// const AuthCheckMail = Loadable(lazy(() => import('pages/auth/check-mail'))); -// const AuthResetPassword = Loadable(lazy(() => import('pages/auth/reset-password'))); -// const AuthCodeVerification = Loadable(lazy(() => import('pages/auth/code-verification'))); const Login = Loadable(lazy(() => import('pages/nearle/login'))); // ==============================|| AUTH ROUTING ||============================== // @@ -21,11 +14,7 @@ const LoginRoutes = { children: [ { path: '/', - element: ( - // - - // - ), + element: , children: [ { path: '/', @@ -35,35 +24,6 @@ const LoginRoutes = { path: 'login', element: } - - // { - // path: '/', - // element: - // }, - // { - // path: 'login', - // element: - // }, - // { - // path: 'register', - // element: - // }, - // { - // path: 'forgot-password', - // element: - // }, - // { - // path: 'check-mail', - // element: - // }, - // { - // path: 'reset-password', - // element: - // }, - // { - // path: 'code-verification', - // element: - // } ] } ] diff --git a/src/routes/MainRoutes.js b/src/routes/MainRoutes.js index b6d8acb..c0665e7 100644 --- a/src/routes/MainRoutes.js +++ b/src/routes/MainRoutes.js @@ -4,7 +4,6 @@ import { lazy } from 'react'; import MainLayout from 'layout/MainLayout'; import CommonLayout from 'layout/CommonLayout'; import Loadable from 'components/Loadable'; -// import AuthGuard from 'utils/route-guard/AuthGuard'; // pages routing const MaintenanceError = Loadable(lazy(() => import('pages/maintenance/404'))); @@ -12,10 +11,7 @@ const MaintenanceError500 = Loadable(lazy(() => import('pages/maintenance/500')) const MaintenanceUnderConstruction = Loadable(lazy(() => import('pages/maintenance/under-construction'))); const MaintenanceComingSoon = Loadable(lazy(() => import('pages/maintenance/coming-soon'))); -// render - sample page -// const SamplePage = Loadable(lazy(() => import('pages/extra-pages/sample-page'))); const Login = Loadable(lazy(() => import('pages/nearle/login1'))); -// const Dashboard = Loadable(lazy(() => import('pages/nearle/dashboard'))); const Tenants = Loadable(lazy(() => import('pages/nearle/clients/Tenants'))); const ClientsPricing = Loadable(lazy(() => import('pages/nearle/clientPricing/clientPricing'))); @@ -60,11 +56,7 @@ const MainRoutes = { children: [ { path: '/', - element: ( - // - - // - ), + element: , children: [ { path: 'nearle', @@ -188,11 +180,6 @@ const MainRoutes = { path: 'viewprofile', element: } - - // { - // path: 'orders/create', - // element: - // }, ] }, diff --git a/src/sections/apps/chat/ChatDrawer.js b/src/sections/apps/chat/ChatDrawer.js deleted file mode 100644 index 627c3af..0000000 --- a/src/sections/apps/chat/ChatDrawer.js +++ /dev/null @@ -1,275 +0,0 @@ -import PropTypes from 'prop-types'; -import { useState } from 'react'; -import { Link } from 'react-router-dom'; - -// material-ui -import { useTheme } from '@mui/material/styles'; -import { - Box, - Chip, - Drawer, - Grid, - InputAdornment, - List, - ListItemButton, - ListItemIcon, - ListItemText, - Menu, - MenuItem, - OutlinedInput, - Stack, - Typography, - useMediaQuery -} from '@mui/material'; - -// project imports -import UserAvatar from './UserAvatar'; -// import UserList from './UserList'; -import MainCard from 'components/MainCard'; -import IconButton from 'components/@extended/IconButton'; -import SimpleBar from 'components/third-party/SimpleBar'; - -import { ThemeMode } from 'config'; -import useAuth from 'hooks/useAuth'; - -// assets -import { - CheckCircleFilled, - ClockCircleFilled, - LogoutOutlined, - MinusCircleFilled, - RightOutlined, - SearchOutlined, - SettingOutlined -} from '@ant-design/icons'; - -// ==============================|| CHAT DRAWER ||============================== // - -function ChatDrawer({ handleDrawerOpen, openChatDrawer, setUser }) { - const theme = useTheme(); - const { user } = useAuth(); - - const matchDownLG = useMediaQuery(theme.breakpoints.down('lg')); - const drawerBG = theme.palette.mode === ThemeMode.DARK ? 'dark.main' : 'white'; - - // show menu to set current user status - const [anchorEl, setAnchorEl] = useState(); - const handleClickRightMenu = (event) => { - setAnchorEl(event?.currentTarget); - }; - - const handleCloseRightMenu = () => { - setAnchorEl(null); - }; - - // set user status on status menu click - const [status, setStatus] = useState('available'); - const handleRightMenuItemClick = (userStatus) => () => { - setStatus(userStatus); - handleCloseRightMenu(); - }; - - const [search, setSearch] = useState(''); - const handleSearch = async (event) => { - const newString = event?.target.value; - setSearch(newString); - }; - - return ( - - - - - - - Messages - - - - - - - - } - /> - - - - - - {/* */} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {user?.name} - - - {user?.role} - - - - - - - - - - - - - Active - - - - - - Away - - - - - - Do not disturb - - - - - - - - - - ); -} - -ChatDrawer.propTypes = { - handleDrawerOpen: PropTypes.func, - openChatDrawer: PropTypes.bool, - setUser: PropTypes.func -}; - -export default ChatDrawer; diff --git a/src/sections/apps/chat/ChatHistory.js b/src/sections/apps/chat/ChatHistory.js deleted file mode 100644 index e12ecd2..0000000 --- a/src/sections/apps/chat/ChatHistory.js +++ /dev/null @@ -1,119 +0,0 @@ -import PropTypes from 'prop-types'; -import { useCallback, useEffect, useRef } from 'react'; - -// material-ui -import { Card, CardContent, Grid, Stack, Typography } from '@mui/material'; - -// project imports -import UserAvatar from './UserAvatar'; -// import ChatMessageAction from './ChatMessageAction'; -import IconButton from 'components/@extended/IconButton'; -import { ThemeMode } from 'config'; - -// assets -import { EditOutlined } from '@ant-design/icons'; - -// ==============================|| CHAT MESSAGE HISTORY ||============================== // - -const ChatHistory = ({ data, theme, user }) => { - // scroll to bottom when new message is sent or received - const wrapper = useRef(document.createElement('div')); - const el = wrapper.current; - const scrollToBottom = useCallback(() => { - el.scrollIntoView(false); - }, [el]); - - useEffect(() => { - scrollToBottom(); - }, [data.length, scrollToBottom]); - - return ( - - {data.map((history, index) => ( - - {history.from !== user.name ? ( - - - - - - - {/* */} - - - - - - - - - {history.text} - - - - - - - - - - {history.time} - - - - - - ) : ( - - - - - - - - - - - {history.text} - - - - - - - - - {history.time} - - - - - )} - - ))} - - ); -}; - -ChatHistory.propTypes = { - data: PropTypes.array, - theme: PropTypes.object, - user: PropTypes.object -}; - -export default ChatHistory; diff --git a/src/sections/apps/chat/UserAvatar.js b/src/sections/apps/chat/UserAvatar.js deleted file mode 100644 index 139623d..0000000 --- a/src/sections/apps/chat/UserAvatar.js +++ /dev/null @@ -1,33 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { Badge } from '@mui/material'; - -// project imports -// import AvatarStatus from './AvatarStatus'; -import Avatar from 'components/@extended/Avatar'; - -// assets -const avatarImage = require.context('assets/images/users', true); - -// ==============================|| CHAT USER AVATAR WITH STATUS ICON ||============================== // - -const UserAvatar = ({ user }) => ( - } - anchorOrigin={{ - vertical: 'top', - horizontal: 'right' - }} - sx={{ '& .MuiBox-root': { width: 6, height: 6 }, padding: 0, minWidth: 12, '& svg': { background: '#fff', borderRadius: '50%' } }} - > - - -); - -UserAvatar.propTypes = { - user: PropTypes.object -}; - -export default UserAvatar; diff --git a/src/sections/apps/chat/UserDetails.js b/src/sections/apps/chat/UserDetails.js deleted file mode 100644 index e4b9aa2..0000000 --- a/src/sections/apps/chat/UserDetails.js +++ /dev/null @@ -1,303 +0,0 @@ -import PropTypes from 'prop-types'; -import { useState } from 'react'; - -// material-ui -import { useTheme } from '@mui/material/styles'; -import { useMediaQuery, Box, Chip, Collapse, Divider, Grid, Stack, Switch, Typography } from '@mui/material'; - -// project imports -// import AvatarStatus from './AvatarStatus'; -import MainCard from 'components/MainCard'; -import Avatar from 'components/@extended/Avatar'; -import IconButton from 'components/@extended/IconButton'; -import SimpleBar from 'components/third-party/SimpleBar'; -import { ThemeMode } from 'config'; - -// assets -import { - CloseOutlined, - DownOutlined, - FileDoneOutlined, - FileSyncOutlined, - FolderOpenOutlined, - LinkOutlined, - MessageOutlined, - MoreOutlined, - PhoneOutlined, - PictureOutlined, - RightOutlined, - VideoCameraOutlined -} from '@ant-design/icons'; - -const avatarImage = require.context('assets/images/users', true); - -// ==============================|| USER PROFILE / DETAILS ||============================== // - -const UserDetails = ({ user, onClose }) => { - const theme = useTheme(); - const matchDownLG = useMediaQuery(theme.breakpoints.down('md')); - - const [checked, setChecked] = useState(true); - if (Object.keys(user).length === 0) return ...Loading; - - let statusBGColor; - let statusColor; - if (user.online_status === 'available') { - statusBGColor = theme.palette.success.lighter; - statusColor = theme.palette.success.main; - } else if (user.online_status === 'do_not_disturb') { - statusBGColor = theme.palette.grey.A100; - statusColor = theme.palette.grey.A200; - } else { - statusBGColor = theme.palette.warning.lighter; - statusColor = theme.palette.warning.main; - } - - return ( - - - {onClose && ( - - - - )} - - - - - - {user.name} - - - {user.role} - - - - - - {/* */} - - - - - - - - - - - - - - - - - - - - - - - All File - - - 231 - - - - All Link - - - 231 - - - - - - - setChecked(!checked)} - > - - Information - - - - - - - - - - - - - Address - {user.location} - - - Email - {user.personal_email} - - - Phone - {user.personal_phone} - - - Last visited - {user.lastMessage} - - - - - - Notification - - - - - - - - - File type - - - - - - - - - - - - - - - - Document - 123 files, 193MB - - - - - - - - - - - - - - - - Photos - 53 files, 321MB - - - - - - - - - - - - - - - - Other - 49 files, 193MB - - - - - - - - - - - - - - ); -}; - -UserDetails.propTypes = { - user: PropTypes.object, - onClose: PropTypes.func -}; - -export default UserDetails; diff --git a/src/sections/auth/AuthCard.js b/src/sections/auth/AuthCard.js deleted file mode 100644 index db4eade..0000000 --- a/src/sections/auth/AuthCard.js +++ /dev/null @@ -1,39 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { useTheme } from '@mui/material/styles'; -import { Box } from '@mui/material'; - -// project import -import MainCard from 'components/MainCard'; - -// ==============================|| AUTHENTICATION - CARD WRAPPER ||============================== // - -const AuthCard = ({ children, ...other }) => { - const theme = useTheme(); - return ( - *': { - flexGrow: 1, - flexBasis: '50%' - } - }} - content={false} - {...other} - border={false} - boxShadow - shadow={theme.customShadows.z1} - > - {children} - - ); -}; - -AuthCard.propTypes = { - children: PropTypes.node -}; - -export default AuthCard; diff --git a/src/sections/auth/AuthWrapper.js b/src/sections/auth/AuthWrapper.js deleted file mode 100644 index 6ea539c..0000000 --- a/src/sections/auth/AuthWrapper.js +++ /dev/null @@ -1,55 +0,0 @@ -import PropTypes from 'prop-types'; - -// material-ui -import { Box, Grid } from '@mui/material'; - -// project import -import AuthFooter from 'components/cards/AuthFooter'; -import Logo from 'components/logo'; -import AuthCard from './AuthCard'; - -// assets -import AuthBackground from 'assets/images/auth/AuthBackground'; - -// ==============================|| AUTHENTICATION - WRAPPER ||============================== // - -const AuthWrapper = ({ children }) => ( - - - - - - - - - - {children} - - - - - - - - -); - -AuthWrapper.propTypes = { - children: PropTypes.node -}; - -export default AuthWrapper; diff --git a/src/sections/auth/auth-forms/AuthCodeVerification.js b/src/sections/auth/auth-forms/AuthCodeVerification.js deleted file mode 100644 index ae59aa2..0000000 --- a/src/sections/auth/auth-forms/AuthCodeVerification.js +++ /dev/null @@ -1,66 +0,0 @@ -import { useState } from 'react'; - -// material-ui -import { useTheme } from '@mui/material/styles'; -import { Button, Grid, Stack, Typography } from '@mui/material'; - -// third-party -import OtpInput from 'react18-input-otp'; - -// project import -import AnimateButton from 'components/@extended/AnimateButton'; -import { ThemeMode } from 'config'; - -// ============================|| STATIC - CODE VERIFICATION ||============================ // - -const AuthCodeVerification = () => { - const theme = useTheme(); - const [otp, setOtp] = useState(); - - const borderColor = theme.palette.mode === ThemeMode.DARK ? theme.palette.grey[200] : theme.palette.grey[300]; - - return ( - - - setOtp(otp)} - numInputs={4} - containerStyle={{ justifyContent: 'space-between' }} - inputStyle={{ - width: '100%', - margin: '8px', - padding: '10px', - border: `1px solid ${borderColor}`, - borderRadius: 4, - ':hover': { - borderColor: theme.palette.primary.main - } - }} - focusStyle={{ - outline: 'none', - boxShadow: theme.customShadows.primary, - border: `1px solid ${theme.palette.primary.main}` - }} - /> - - - - - - - - - Did not receive the email? Check your spam filter, or - - Resend code - - - - - ); -}; - -export default AuthCodeVerification; diff --git a/src/sections/auth/auth-forms/AuthForgotPassword.js b/src/sections/auth/auth-forms/AuthForgotPassword.js deleted file mode 100644 index c1eec45..0000000 --- a/src/sections/auth/auth-forms/AuthForgotPassword.js +++ /dev/null @@ -1,126 +0,0 @@ -import { useNavigate } from 'react-router-dom'; - -// material-ui -import { Button, FormHelperText, Grid, InputLabel, OutlinedInput, Stack, Typography } from '@mui/material'; - -// third party -import * as Yup from 'yup'; -import { Formik } from 'formik'; - -// project import -import AnimateButton from 'components/@extended/AnimateButton'; - -import useAuth from 'hooks/useAuth'; -import useScriptRef from 'hooks/useScriptRef'; -import { dispatch } from 'store'; -import { openSnackbar } from 'store/reducers/snackbar'; - -// ============================|| FIREBASE - FORGOT PASSWORD ||============================ // - -const AuthForgotPassword = () => { - const scriptedRef = useScriptRef(); - const navigate = useNavigate(); - - const { isLoggedIn, resetPassword } = useAuth(); - - return ( - <> - { - try { - await resetPassword(values.email).then( - () => { - setStatus({ success: true }); - setSubmitting(false); - dispatch( - openSnackbar({ - open: true, - message: 'Check mail for reset password link', - variant: 'alert', - alert: { - color: 'success' - }, - close: false - }) - ); - setTimeout(() => { - navigate(isLoggedIn ? '/auth/check-mail' : '/check-mail', { replace: true }); - }, 1500); - - // WARNING: do not set any formik state here as formik might be already destroyed here. You may get following error by doing so. - // Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. - // To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. - // github issue: https://github.com/formium/formik/issues/2430 - }, - (err) => { - setStatus({ success: false }); - setErrors({ submit: err.message }); - setSubmitting(false); - } - ); - } catch (err) { - console.error(err); - if (scriptedRef.current) { - setStatus({ success: false }); - setErrors({ submit: err.message }); - setSubmitting(false); - } - } - }} - > - {({ errors, handleBlur, handleChange, handleSubmit, isSubmitting, touched, values }) => ( - - - - - Email Address - - {touched.email && errors.email && ( - - {errors.email} - - )} - - - {errors.submit && ( - - {errors.submit} - - )} - - Do not forgot to check SPAM box. - - - - - - - - - )} - - - ); -}; - -export default AuthForgotPassword; diff --git a/src/sections/auth/auth-forms/AuthLogin.js b/src/sections/auth/auth-forms/AuthLogin.js deleted file mode 100644 index 058b4e8..0000000 --- a/src/sections/auth/auth-forms/AuthLogin.js +++ /dev/null @@ -1,176 +0,0 @@ -import React from 'react'; -import { Link as RouterLink } from 'react-router-dom'; - -// material-ui -import { - Button, - Checkbox, - FormControlLabel, - FormHelperText, - Grid, - Link, - InputAdornment, - InputLabel, - OutlinedInput, - Stack, - Typography -} from '@mui/material'; - -// third party -import * as Yup from 'yup'; -import { Formik } from 'formik'; - -// project import -import useAuth from 'hooks/useAuth'; -import useScriptRef from 'hooks/useScriptRef'; -import IconButton from 'components/@extended/IconButton'; -import AnimateButton from 'components/@extended/AnimateButton'; - -// assets -import { EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'; - -// ============================|| JWT - LOGIN ||============================ // - -const AuthLogin = () => { - const [checked, setChecked] = React.useState(false); - - const { login } = useAuth(); - const scriptedRef = useScriptRef(); - - const [showPassword, setShowPassword] = React.useState(false); - const handleClickShowPassword = () => { - setShowPassword(!showPassword); - }; - - const handleMouseDownPassword = (event) => { - event.preventDefault(); - }; - - return ( - <> - { - try { - await login(values.email, values.password); - if (scriptedRef.current) { - setStatus({ success: true }); - setSubmitting(false); - } - } catch (err) { - console.error(err); - if (scriptedRef.current) { - setStatus({ success: false }); - setErrors({ submit: err.message }); - setSubmitting(false); - } - } - }} - > - {({ errors, handleBlur, handleChange, handleSubmit, isSubmitting, touched, values }) => ( -
- - - - Email Address - - {touched.email && errors.email && ( - - {errors.email} - - )} - - - - - Password - - - {showPassword ? : } - - - } - placeholder="Enter password" - /> - {touched.password && errors.password && ( - - {errors.password} - - )} - - - - - - setChecked(event.target.checked)} - name="checked" - color="primary" - size="small" - /> - } - label={Keep me sign in} - /> - - Forgot Password? - - - - {errors.submit && ( - - {errors.submit} - - )} - - - - - - -
- )} -
- - ); -}; - -export default AuthLogin; diff --git a/src/sections/auth/auth-forms/AuthRegister.js b/src/sections/auth/auth-forms/AuthRegister.js deleted file mode 100644 index f9f5372..0000000 --- a/src/sections/auth/auth-forms/AuthRegister.js +++ /dev/null @@ -1,282 +0,0 @@ -import { useEffect, useState } from 'react'; -import { Link as RouterLink, useNavigate } from 'react-router-dom'; - -// material-ui -import { - Box, - Button, - FormControl, - FormHelperText, - Grid, - Link, - InputAdornment, - InputLabel, - OutlinedInput, - Stack, - Typography -} from '@mui/material'; - -// third party -import * as Yup from 'yup'; -import { Formik } from 'formik'; - -// project import -import IconButton from 'components/@extended/IconButton'; -import AnimateButton from 'components/@extended/AnimateButton'; - -import useAuth from 'hooks/useAuth'; -import useScriptRef from 'hooks/useScriptRef'; -import { dispatch } from 'store'; -import { openSnackbar } from 'store/reducers/snackbar'; -import { strengthColor, strengthIndicator } from 'utils/password-strength'; - -// assets -import { EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'; - -// ============================|| JWT - REGISTER ||============================ // - -const AuthRegister = () => { - const { register } = useAuth(); - const scriptedRef = useScriptRef(); - const navigate = useNavigate(); - - const [level, setLevel] = useState(); - const [showPassword, setShowPassword] = useState(false); - const handleClickShowPassword = () => { - setShowPassword(!showPassword); - }; - - const handleMouseDownPassword = (event) => { - event.preventDefault(); - }; - - const changePassword = (value) => { - const temp = strengthIndicator(value); - setLevel(strengthColor(temp)); - }; - - useEffect(() => { - changePassword(''); - }, []); - - return ( - <> - { - try { - await register(values.email, values.password, values.firstname, values.lastname); - if (scriptedRef.current) { - setStatus({ success: true }); - setSubmitting(false); - dispatch( - openSnackbar({ - open: true, - message: 'Your registration has been successfully completed.', - variant: 'alert', - alert: { - color: 'success' - }, - close: false - }) - ); - - setTimeout(() => { - navigate('/login', { replace: true }); - }, 1500); - } - } catch (err) { - console.error(err); - if (scriptedRef.current) { - setStatus({ success: false }); - setErrors({ submit: err.message }); - setSubmitting(false); - } - } - }} - > - {({ errors, handleBlur, handleChange, handleSubmit, isSubmitting, touched, values }) => ( -
- - - - First Name* - - {touched.firstname && errors.firstname && ( - - {errors.firstname} - - )} - - - - - Last Name* - - {touched.lastname && errors.lastname && ( - - {errors.lastname} - - )} - - - - - Company - - {touched.company && errors.company && ( - - {errors.company} - - )} - - - - - Email Address* - - {touched.email && errors.email && ( - - {errors.email} - - )} - - - - - Password - { - handleChange(e); - changePassword(e.target.value); - }} - endAdornment={ - - - {showPassword ? : } - - - } - placeholder="******" - inputProps={{}} - /> - {touched.password && errors.password && ( - - {errors.password} - - )} - - - - - - - - - {level?.label} - - - - - - - - By Signing up, you agree to our   - - Terms of Service - -   and   - - Privacy Policy - - - - {errors.submit && ( - - {errors.submit} - - )} - - - - - - -
- )} -
- - ); -}; - -export default AuthRegister; diff --git a/src/sections/auth/auth-forms/AuthResetPassword.js b/src/sections/auth/auth-forms/AuthResetPassword.js deleted file mode 100644 index e39671d..0000000 --- a/src/sections/auth/auth-forms/AuthResetPassword.js +++ /dev/null @@ -1,201 +0,0 @@ -import { useEffect, useState } from 'react'; -import { useNavigate } from 'react-router-dom'; - -// material-ui -import { - Box, - Button, - FormControl, - FormHelperText, - Grid, - InputAdornment, - InputLabel, - OutlinedInput, - Stack, - Typography -} from '@mui/material'; - -// third party -import * as Yup from 'yup'; -import { Formik } from 'formik'; - -// project import -import IconButton from 'components/@extended/IconButton'; -import AnimateButton from 'components/@extended/AnimateButton'; - -import useAuth from 'hooks/useAuth'; -import useScriptRef from 'hooks/useScriptRef'; -import { dispatch } from 'store'; -import { openSnackbar } from 'store/reducers/snackbar'; -import { strengthColor, strengthIndicator } from 'utils/password-strength'; - -// assets -import { EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'; - -// ============================|| STATIC - RESET PASSWORD ||============================ // - -const AuthResetPassword = () => { - const scriptedRef = useScriptRef(); - const navigate = useNavigate(); - - const { isLoggedIn } = useAuth(); - - const [level, setLevel] = useState(); - const [showPassword, setShowPassword] = useState(false); - const handleClickShowPassword = () => { - setShowPassword(!showPassword); - }; - - const handleMouseDownPassword = (event) => { - event.preventDefault(); - }; - - const changePassword = (value) => { - const temp = strengthIndicator(value); - setLevel(strengthColor(temp)); - }; - - useEffect(() => { - changePassword(''); - }, []); - - return ( - yup.parent.password === confirmPassword) - })} - onSubmit={async (values, { setErrors, setStatus, setSubmitting }) => { - try { - // password reset - if (scriptedRef.current) { - setStatus({ success: true }); - setSubmitting(false); - - dispatch( - openSnackbar({ - open: true, - message: 'Successfuly reset password.', - variant: 'alert', - alert: { - color: 'success' - }, - close: false - }) - ); - - setTimeout(() => { - navigate(isLoggedIn ? '/auth/login' : '/login', { replace: true }); - }, 1500); - } - } catch (err) { - console.error(err); - if (scriptedRef.current) { - setStatus({ success: false }); - setErrors({ submit: err.message }); - setSubmitting(false); - } - } - }} - > - {({ errors, handleBlur, handleChange, handleSubmit, isSubmitting, touched, values }) => ( -
- - - - Password - { - handleChange(e); - changePassword(e.target.value); - }} - endAdornment={ - - - {showPassword ? : } - - - } - placeholder="Enter password" - /> - {touched.password && errors.password && ( - - {errors.password} - - )} - - - - - - - - - {level?.label} - - - - - - - - Confirm Password - - {touched.confirmPassword && errors.confirmPassword && ( - - {errors.confirmPassword} - - )} - - - - {errors.submit && ( - - {errors.submit} - - )} - - - - - - -
- )} -
- ); -}; - -export default AuthResetPassword; diff --git a/src/sections/auth/auth-forms/FirebaseSocial.js b/src/sections/auth/auth-forms/FirebaseSocial.js deleted file mode 100644 index 2d92f3b..0000000 --- a/src/sections/auth/auth-forms/FirebaseSocial.js +++ /dev/null @@ -1,82 +0,0 @@ -// material-ui -import { useTheme } from '@mui/material/styles'; -import { useMediaQuery, Button, Stack } from '@mui/material'; - -// project import -import useAuth from 'hooks/useAuth'; - -// assets -import Google from 'assets/images/icons/google.svg'; -import Twitter from 'assets/images/icons/twitter.svg'; -import Facebook from 'assets/images/icons/facebook.svg'; - -// ==============================|| FIREBASE - SOCIAL BUTTON ||============================== // - -const FirebaseSocial = () => { - const theme = useTheme(); - const matchDownSM = useMediaQuery(theme.breakpoints.down('sm')); - - const { firebaseFacebookSignIn, firebaseGoogleSignIn, firebaseTwitterSignIn } = useAuth(); - const googleHandler = async () => { - try { - await firebaseGoogleSignIn(); - } catch (err) { - console.error(err); - } - }; - - const twitterHandler = async () => { - try { - await firebaseTwitterSignIn(); - } catch (err) { - console.error(err); - } - }; - - const facebookHandler = async () => { - try { - await firebaseFacebookSignIn(); - } catch (err) { - console.error(err); - } - }; - - return ( - - - - - - ); -}; - -export default FirebaseSocial; diff --git a/src/sections/widget/data/ApplicationSales.js b/src/sections/widget/data/ApplicationSales.js deleted file mode 100644 index 5c4020e..0000000 --- a/src/sections/widget/data/ApplicationSales.js +++ /dev/null @@ -1,68 +0,0 @@ -import { Link as RouterLink } from 'react-router-dom'; - -// material-ui -import { Link, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography } from '@mui/material'; - -// project imports -import MainCard from 'components/MainCard'; - -// table data -function createData(name, designation, product, date, badgeText, badgeType) { - return { name, designation, product, date, badgeText, badgeType }; -} - -const rows = [ - createData('Materially', 'Powerful Admin Theme', '16,300', '$53', '$15,652'), - createData('Photoshop', 'Design Software', '26,421', '$35', '$8,785'), - createData('Guruable', 'Best Admin Template', '8,265', '$98', '$9,652'), - createData('Flatable', 'Admin App', '10,652', '$20', '$7,856') -]; -// =========================|| DATA WIDGET - APPLICATION SALES ||========================= // - -const ApplicationSales = () => ( - - View all - - } - > - - - - - Application - Sales - Avg. Price - - Total - - - - - {rows.map((row, index) => ( - - {/* - - {row.name} - - - {row.designation} - - - {row.product} - {row.date} - - {row.badgeText} - */} - - ))} - -
-
-
-); - -export default ApplicationSales; diff --git a/src/sections/widget/data/TasksCard.js b/src/sections/widget/data/TasksCard.js deleted file mode 100644 index 742bd5c..0000000 --- a/src/sections/widget/data/TasksCard.js +++ /dev/null @@ -1,175 +0,0 @@ -import { Link as RouterLink } from 'react-router-dom'; - -// material-ui -import { CardContent, Grid, Link, Typography } from '@mui/material'; - -// project imports -import MainCard from 'components/MainCard'; -import Avatar from 'components/@extended/Avatar'; - -// assets -import { TwitterCircleFilled, ClockCircleFilled, BugFilled, MobileFilled, WarningFilled } from '@ant-design/icons'; - -// ==============================|| DATA WIDGET - TASKS CARD ||============================== // - -const TasksCard = () => ( - - View all - - } - > - - *': { - position: 'relative', - zIndex: '5' - }, - '&:after': { - content: '""', - position: 'absolute', - top: 10, - left: 38, - width: 2, - height: '100%', - background: '#ebebeb', - zIndex: '1' - } - }} - > - - - - - - - - - - - - 8:50 - - - - - You’re getting more and more followers, keep it up! - - - - - - - - - - - - - - - - - - Sat, 5 Mar - - - - - Design mobile Application - - - - - - - - - - - - - - - - - - Sun, 17 Feb - - - - - - Jenny - {' '} - assign you a task{' '} - - Mockup Design - - . - - - - - - - - - - - - - - - - - - Sat, 18 Mar - - - - - Design logo - - - - - - - - - - - - - - - - - - Sat, 22 Mar - - - - - Design mobile Application - - - - - - - - - -); - -export default TasksCard; diff --git a/src/utils/password-strength.js b/src/utils/password-strength.js deleted file mode 100644 index 2f510ae..0000000 --- a/src/utils/password-strength.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Password validator for login pages - */ - -// has number -const hasNumber = (number) => new RegExp(/[0-9]/).test(number); - -// has mix of small and capitals -const hasMixed = (number) => new RegExp(/[a-z]/).test(number) && new RegExp(/[A-Z]/).test(number); - -// has special chars -const hasSpecial = (number) => new RegExp(/[!#@$%^&*)(+=._-]/).test(number); - -// set color based on password strength -export const strengthColor = (count) => { - if (count < 2) return { label: 'Poor', color: 'error.main' }; - if (count < 3) return { label: 'Weak', color: 'warning.main' }; - if (count < 4) return { label: 'Normal', color: 'warning.dark' }; - if (count < 5) return { label: 'Good', color: 'success.main' }; - if (count < 6) return { label: 'Strong', color: 'success.dark' }; - return { label: 'Poor', color: 'error.main' }; -}; - -// password strength indicator -export const strengthIndicator = (number) => { - let strengths = 0; - if (number.length > 5) strengths += 1; - if (number.length > 7) strengths += 1; - if (hasNumber(number)) strengths += 1; - if (hasSpecial(number)) strengths += 1; - if (hasMixed(number)) strengths += 1; - return strengths; -}; diff --git a/src/utils/password-validation.js b/src/utils/password-validation.js deleted file mode 100644 index 885562d..0000000 --- a/src/utils/password-validation.js +++ /dev/null @@ -1,21 +0,0 @@ -function isNumber(value) { - return new RegExp('^(?=.*[0-9]).+$').test(value); -} - -function isLowercaseChar(value) { - return new RegExp('^(?=.*[a-z]).+$').test(value); -} - -function isUppercaseChar(value) { - return new RegExp('^(?=.*[A-Z]).+$').test(value); -} - -function isSpecialChar(value) { - return new RegExp('^(?=.*[-+_!@#$%^&*.,?]).+$').test(value); -} - -function minLength(value) { - return value.length > 7; -} - -export { isNumber, isLowercaseChar, isUppercaseChar, isSpecialChar, minLength }; diff --git a/src/utils/route-guard/AuthGuard.js b/src/utils/route-guard/AuthGuard.js deleted file mode 100644 index cf7ceff..0000000 --- a/src/utils/route-guard/AuthGuard.js +++ /dev/null @@ -1,34 +0,0 @@ -import PropTypes from 'prop-types'; -import { useEffect } from 'react'; -import { useLocation, useNavigate } from 'react-router-dom'; - -// project import -import useAuth from 'hooks/useAuth'; - -// ==============================|| AUTH GUARD ||============================== // - -const AuthGuard = ({ children }) => { - const { isLoggedIn } = useAuth(); - const navigate = useNavigate(); - const location = useLocation(); - - useEffect(() => { - if (!isLoggedIn) { - navigate('login', { - state: { - from: location.pathname - }, - replace: true - }); - navigate('login', { replace: true }); - } - }, [isLoggedIn, navigate, location]); - - return children; -}; - -AuthGuard.propTypes = { - children: PropTypes.node -}; - -export default AuthGuard; diff --git a/src/utils/route-guard/GuestGuard.js b/src/utils/route-guard/GuestGuard.js deleted file mode 100644 index 5b9ea6b..0000000 --- a/src/utils/route-guard/GuestGuard.js +++ /dev/null @@ -1,34 +0,0 @@ -import PropTypes from 'prop-types'; -import { useEffect } from 'react'; -import { useLocation, useNavigate } from 'react-router-dom'; - -// project import -import { APP_DEFAULT_PATH } from 'config'; -import useAuth from 'hooks/useAuth'; - -// ==============================|| GUEST GUARD ||============================== // - -const GuestGuard = ({ children }) => { - const { isLoggedIn } = useAuth(); - const navigate = useNavigate(); - const location = useLocation(); - - useEffect(() => { - if (isLoggedIn) { - navigate(location?.state?.from ? location?.state?.from : APP_DEFAULT_PATH, { - state: { - from: '' - }, - replace: true - }); - } - }, [isLoggedIn, navigate, location]); - - return children; -}; - -GuestGuard.propTypes = { - children: PropTypes.node -}; - -export default GuestGuard;