diff --git a/package.json b/package.json
index 1f140a9..045fe72 100644
--- a/package.json
+++ b/package.json
@@ -6,6 +6,7 @@
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
+ "@floating-ui/react": "^0.26.9",
"@fortawesome/fontawesome-free": "^6.4.0",
"@hookform/resolvers": "^3.3.4",
"@mui/icons-material": "^5.14.5",
@@ -57,6 +58,7 @@
"react-table": "^7.8.0",
"react-transition-group": "^4.4.5",
"react-virtualized": "^9.22.5",
+ "recharts": "^2.12.3",
"sass": "^1.69.7",
"shortid": "^2.2.16",
"slick-carousel": "^1.8.1",
diff --git a/src/App.js b/src/App.js
index 20a69a0..e176420 100644
--- a/src/App.js
+++ b/src/App.js
@@ -5,23 +5,19 @@ import Main from './Main';
import {
FormProvider,
ModalProvider,
- PopoverProvider,
UserProvider,
useMode,
CollectionProvider,
CardProvider,
DeckProvider,
CartProvider,
- CardImagesProvider,
ChartProvider,
StatisticsProvider,
SidebarProvider,
AppContextProvider,
useAuthContext,
- usePageContext,
ErrorBoundary,
ConfiguratorProvider,
- VisibilityProvider,
} from './context';
import { ThemeProvider } from 'styled-components';
import { SnackbarProvider, useSnackbar } from 'notistack';
@@ -37,14 +33,10 @@ const App = () => {
const navigate = useNavigate();
const { resetLogoutTimer, logout, authUser, userId, isLoggedIn } =
useAuthContext();
- const { returnDisplay } = usePageContext();
const { isLoading, isPageLoading, error } = useLoading();
- // useEffect(() => {
- // if (!isLoggedIn && !isPageLoading) navigate('/login');
- // }, [isLoggedIn, navigate, isPageLoading]);
if (isPageLoading || error) {
- return returnDisplay();
+ return
Loading...
;
}
return (
@@ -53,37 +45,29 @@ const App = () => {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Main.jsx b/src/Main.jsx
index f58dade..b4768d0 100644
--- a/src/Main.jsx
+++ b/src/Main.jsx
@@ -1,17 +1,19 @@
import React, { Suspense, lazy } from 'react';
import { Route, Routes } from 'react-router-dom';
import { useMediaQuery } from '@mui/material';
-import PrivateRoute from './components/reusable/PrivateRoute';
+import PrivateRoute from './layout/PrivateRoute.jsx';
import LoginDialog from './components/dialogs/LoginDialog';
import { useAuthContext, useConfiguratorContext, useMode } from './context';
-import PageLayout from './layout/Containers/PageLayout.jsx';
+import PageLayout from './layout/REUSABLE_COMPONENTS/PageLayout.jsx';
import Navigation from './layout/navigation/Navigation.jsx';
-import LoadingIndicator from './components/reusable/indicators/LoadingIndicator.js';
+import LoadingIndicator from './layout/LoadingIndicator.js';
import Configurator from './layout/REUSABLE_COMPONENTS/Configurator/index.jsx';
-import { useCardStoreHook } from './context/hooks/useCardStore.jsx';
-import { AppContainer } from './pages/pageStyles/StyledComponents.jsx';
+import { CSSTransition, TransitionGroup } from 'react-transition-group';
+import LoadingOverlay from './layout/LoadingOverlay.jsx';
+import SelectionErrorDialog from './components/dialogs/SelectionErrorDialog.jsx';
+import useDialogState from './context/hooks/useDialogState.jsx';
+import useSelectedCollection from './context/MAIN_CONTEXT/CollectionContext/useSelectedCollection.jsx';
-// Define all routes in a single array including the component name for laziness
const ROUTE_CONFIG = [
{ path: '/', componentName: 'HomePage', isPrivate: false },
{ path: '/home', componentName: 'HomePage', isPrivate: false },
@@ -29,7 +31,6 @@ const ROUTE_CONFIG = [
{ path: '*', componentName: 'NotFoundPage', isPrivate: false },
];
-// Dynamically import page components based on route configuration
const LazyRoute = ({ componentName, ...rest }) => {
const Component = lazy(() => import(`./pages/${componentName}`));
return ;
@@ -39,6 +40,8 @@ const Main = () => {
const isMobileView = useMediaQuery(theme.breakpoints.down('sm'));
const { isLoggedIn } = useAuthContext();
const { isConfiguratorOpen, toggleConfigurator } = useConfiguratorContext();
+ const { dialogState, openDialog, closeDialog } = useDialogState({});
+ const { selectedCollection } = useSelectedCollection();
return (
<>
{!isLoggedIn ? (
@@ -49,27 +52,40 @@ const Main = () => {
backgroundColor: '#3D3D3D',
}}
>
-
+
{isConfiguratorOpen && }
- }>
-
- {ROUTE_CONFIG.map(({ path, componentName, isPrivate }, index) => (
-
-
-
- ) : (
-
+
+
+ }>
+
+ {ROUTE_CONFIG.map(
+ ({ path, componentName, isPrivate }, index) => (
+
+
+
+ ) : (
+
+ )
+ }
+ />
)
- }
- />
- ))}
-
-
+ )}
+
+
+
+
+ {dialogState.isSelectionErrorDialogOpen && (
+ closeDialog('isSelectionErrorDialogOpen')}
+ selectedValue={selectedCollection?.name}
+ />
+ )}
)}
>
diff --git a/src/assets/animations/Cube.jsx b/src/assets/animations/Cube.jsx
deleted file mode 100644
index 9812023..0000000
--- a/src/assets/animations/Cube.jsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import React from 'react';
-import { Canvas } from '@react-three/fiber';
-
-const Cube = () => {
- return (
-
- {/* eslint-disable-next-line react/no-unknown-property */}
-
-
-
- );
-};
-
-export default Cube;
diff --git a/src/assets/animations/NavMotion.jsx b/src/assets/animations/NavMotion.jsx
deleted file mode 100644
index e807625..0000000
--- a/src/assets/animations/NavMotion.jsx
+++ /dev/null
@@ -1,48 +0,0 @@
-// third party
-import { motion } from 'framer-motion';
-
-// types
-import PropTypes from 'prop-types';
-
-// ==============================|| ANIMATION FOR CONTENT ||============================== //
-
-const NavMotion = ({ children }) => {
- const motionVariants = {
- initial: {
- opacity: 0,
- scale: 0.99,
- },
- in: {
- opacity: 1,
- scale: 1,
- },
- out: {
- opacity: 0,
- scale: 1.01,
- },
- };
-
- const motionTransition = {
- type: 'tween',
- ease: 'anticipate',
- duration: 0.4,
- };
-
- return (
-
- {children}
-
- );
-};
-
-NavMotion.propTypes = {
- children: PropTypes.node,
-};
-
-export default NavMotion;
diff --git a/src/assets/animations/SplashPage3.jsx b/src/assets/animations/SplashPage3.jsx
deleted file mode 100644
index 24c0878..0000000
--- a/src/assets/animations/SplashPage3.jsx
+++ /dev/null
@@ -1,28 +0,0 @@
-// SplashPage.js
-import React from 'react';
-import { Box, Typography } from '@mui/material';
-import CardStormAnimation from './CardStormAnimation';
-
-const SplashPage3 = () => {
- return (
-
-
- Welcome to the Card Storm
-
-
- {/* Include the Card Animation */}
-
-
- );
-};
-
-export default SplashPage3;
diff --git a/src/assets/animations/ThreeJsCube.js b/src/assets/animations/ThreeJsCube.js
deleted file mode 100644
index 3c0435c..0000000
--- a/src/assets/animations/ThreeJsCube.js
+++ /dev/null
@@ -1,54 +0,0 @@
-import React, { useEffect } from 'react';
-import * as THREE from 'three';
-
-const ThreeJsCube = () => {
- useEffect(() => {
- // Three.js code for rendering the cube
- const scene = new THREE.Scene();
- const camera = new THREE.PerspectiveCamera(
- 75,
- window.innerWidth / window.innerHeight,
- 0.1,
- 1000
- );
- const renderer = new THREE.WebGLRenderer();
-
- // Set the size of the rendering window
- renderer.setSize(window.innerWidth, window.innerHeight);
-
- // Append the renderer to the container
- document
- .getElementById('threejs-container')
- .appendChild(renderer.domElement);
-
- // Create a cube with a basic material
- const geometry = new THREE.BoxGeometry();
- const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 }); // Green color
- const cube = new THREE.Mesh(geometry, material);
-
- // Add the cube to the scene
- scene.add(cube);
-
- // Position the camera
- camera.position.z = 5;
-
- // Create an animation loop
- const animate = () => {
- requestAnimationFrame(animate);
-
- // Rotate the cube
- cube.rotation.x += 0.01;
- cube.rotation.y += 0.01;
-
- // Render the scene with the camera
- renderer.render(scene, camera);
- };
-
- // Start the animation loop
- animate();
- }, []);
-
- return ;
-};
-
-export default ThreeJsCube;
diff --git a/src/assets/animations/ZenEnso.jsx b/src/assets/animations/ZenEnso.jsx
deleted file mode 100644
index e659de6..0000000
--- a/src/assets/animations/ZenEnso.jsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import React, { useRef, useEffect } from 'react';
-import * as THREE from 'three';
-
-const ZenEnso = () => {
- const mountRef = useRef(null);
-
- useEffect(() => {
- const width = mountRef.current.clientWidth;
- const height = mountRef.current.clientHeight;
- const scene = new THREE.Scene();
- scene.background = new THREE.Color(0xffffff);
- const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
- camera.position.z = 5;
-
- const renderer = new THREE.WebGLRenderer();
- renderer.setSize(width, height);
- mountRef.current.appendChild(renderer.domElement);
-
- const points = [];
- const detail = 100;
- const radius = 2;
- const incompleteFactor = 0.85; // Making the circle incomplete
- const variance = 0.2; // Increased randomness
-
- for (let i = 0; i <= detail * incompleteFactor; i++) {
- const ratio = i / detail;
- const angle = 2 * Math.PI * ratio;
- const randomVariance = 1 + Math.random() * variance - variance / 2;
- const x = radius * Math.cos(angle) * randomVariance;
- const y = radius * Math.sin(angle) * randomVariance;
- points.push(new THREE.Vector3(x, y, 0));
- }
-
- const geometry = new THREE.BufferGeometry().setFromPoints(points);
- const material = new THREE.LineBasicMaterial({
- color: 0x000000,
- linewidth: 2,
- }); // Slight width
- const enso = new THREE.Line(geometry, material);
-
- scene.add(enso);
-
- const animate = () => {
- requestAnimationFrame(animate);
- enso.rotation.z += 0.01; // Rotation
- renderer.render(scene, camera);
- };
-
- animate();
-
- return () => {
- mountRef.current.removeChild(renderer.domElement);
- };
- }, []);
-
- return ;
-};
-
-export default ZenEnso;
diff --git a/src/assets/css/index.css b/src/assets/css/index.css
index 5ff2073..234d377 100644
--- a/src/assets/css/index.css
+++ b/src/assets/css/index.css
@@ -23,6 +23,24 @@ html {
scroll-behavior: smooth;
}
+.fade-enter {
+ opacity: 0;
+}
+
+.fade-enter-active {
+ opacity: 1;
+ transition: opacity 300ms ease-in;
+}
+
+.fade-exit {
+ opacity: 1;
+}
+
+.fade-exit-active {
+ opacity: 0;
+ transition: opacity 300ms ease-in;
+}
+
/* @media (min-width: 1440px) {
html {
zoom: 1.5;
@@ -147,7 +165,7 @@ button {
/* padding: 60px; */
}
-.hero-section-container {
+/* .hero-section-container {
background: rgba(189, 181, 181, 0.1);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(20px);
@@ -155,9 +173,32 @@ button {
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 25px;
/* padding: 30px 0px; */
- width: '100vw';
+/* width: '100vw'; */
+/* width: min(1200px, 100%); */
+/* } */
+.hero-section-container {
+ background: rgba(189, 181, 181, 0.1);
+ box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
+ backdrop-filter: blur(5px);
+ -webkit-backdrop-filter: blur(20px);
+ border: 1px solid rgba(255, 255, 255, 0.3);
+ border-radius: 25px;
+ /* padding: 30px 0px; */
+ /* width: '100vw'; */
/* width: min(1200px, 100%); */
}
+.hero-section-container-left {
+ position: absolute;
+ top: 20px; /* Adjust as needed */
+ left: 20px; /* Adjust as needed */
+ width: 200px; /* Adjust as needed */
+ height: 100px; /* Adjust as needed */
+ /* background-color: rgba(255, 255, 255, 0.8); Semi-transparent white */
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ z-index: 2; /* Ensure it's above the swiper slides */
+}
/* .hero-section h1 {
font-size: 3.5rem;
@@ -216,6 +257,14 @@ button {
width: 100vw; /* Adjust based on your design needs */
overflow: hidden; /* Prevent overflow */
}
+
+/* .swiper-wrapper {
+ display: flex; /* Ensure the slides are in a row */
+/* transition: transform 0.3s; /* Smooth transition */
+/* align-items: center;
+ justify-content: center;
+} */
+
.swiper-scrollbar {
--swipeer-scrollbar-bottom: 0;
--swipeer-scrollbar-drag-bg-color: #dda3b6;
@@ -241,14 +290,14 @@ button {
@media (max-width: 500px) {
.swiper_container {
- height: 47rem;
+ /* height: 47rem; */
}
.swiper-slide {
width: 28rem !important;
- height: 36rem !important;
+ /* height: 36rem !important; */
}
.swiper-slide img {
- width: 28rem !important;
+ /* width: 28rem !important; */
height: 36rem !important;
}
}
@@ -259,13 +308,13 @@ button {
}
.swiper-slide {
width: 30rem;
- height: 36rem;
+ /* height: 36rem; */
/* height: auto; */
/* Adjust the height as needed */
}
.swiper-slide img {
width: 30rem;
- height: 36rem;
+ /* height: 36rem; */
}
}
@@ -333,7 +382,7 @@ button {
}
.swiper-slide-active {
- transform: scale(2); /* Make the active slide larger */
+ transform: scale(8); /* Make the active slide larger */
transition: transform 0.3s; /* Smooth transition */
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Add a shadow */
}
diff --git a/src/assets/currentlyUnused/AddCollectionForm.jsx b/src/assets/currentlyUnused/AddCollectionForm.jsx
new file mode 100644
index 0000000..80ca8ea
--- /dev/null
+++ b/src/assets/currentlyUnused/AddCollectionForm.jsx
@@ -0,0 +1,35 @@
+// import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline';
+// import RCZodForm from './reusable/RCZodForm';
+
+// const AddCollectionForm = () => {
+// // Assuming 'addCollectionForm' is the key/name for this form schema in your context
+// const schemaName = 'addCollectionForm';
+// const buttonLabel = 'Create Collection';
+// const startIcon = ;
+// const addCollectionFields = [
+// {
+// name: 'name',
+// label: 'Name',
+// type: 'text',
+// required: true,
+// },
+// {
+// name: 'description',
+// label: 'Description',
+// type: 'text',
+// required: true,
+// multiline: true,
+// rows: 4,
+// },
+// ];
+// return (
+//
+// );
+// };
+
+// export default AddCollectionForm;
diff --git a/src/assets/currentlyUnused/AddDeckForm.jsx b/src/assets/currentlyUnused/AddDeckForm.jsx
new file mode 100644
index 0000000..95d6071
--- /dev/null
+++ b/src/assets/currentlyUnused/AddDeckForm.jsx
@@ -0,0 +1,39 @@
+// import React from 'react';
+// import { useFormContext } from '../../context';
+// import RCZodForm from './RCZodForm';
+// import SaveIcon from '@mui/icons-material/Save';
+
+// const AddDeckForm = () => {
+// const { setFormSchema } = useFormContext();
+// const formId = 'addDeckForm'; // Assuming this is the formId for creating decks
+// const fields = [
+// { name: 'name', label: 'Name', type: 'text', required: true },
+// {
+// name: 'description',
+// label: 'Description',
+// type: 'text',
+// required: true,
+// multiline: true,
+// },
+// ];
+
+// const handleSubmit = (data) => {
+// console.log('Add Deck Data:', data);
+// };
+
+// React.useEffect(() => {
+// setFormSchema(formId);
+// }, [setFormSchema, formId]);
+
+// return (
+// }
+// />
+// );
+// };
+
+// export default AddDeckForm;
diff --git a/src/assets/animations/CardDeckAnimation.js b/src/assets/currentlyUnused/CardDeckAnimation.js
similarity index 100%
rename from src/assets/animations/CardDeckAnimation.js
rename to src/assets/currentlyUnused/CardDeckAnimation.js
diff --git a/src/assets/currentlyUnused/CardImagesContext/CardImagesContext.jsx b/src/assets/currentlyUnused/CardImagesContext/CardImagesContext.jsx
new file mode 100644
index 0000000..0dd2c1c
--- /dev/null
+++ b/src/assets/currentlyUnused/CardImagesContext/CardImagesContext.jsx
@@ -0,0 +1,114 @@
+// import React, { createContext, useContext, useEffect, useState } from 'react';
+
+// const CardImagesContext = createContext();
+
+// export const useCardImages = () => useContext(CardImagesContext);
+
+// const fetchWrapper = async (url, method, body = null) => {
+// const options = {
+// method,
+// headers: {
+// 'Content-Type': 'application/json',
+// // 'Access-Control-Allow-Origin': '*',
+// // crossOrigin: 'anonymous',
+// },
+// ...(body && { body: JSON.stringify(body) }),
+// };
+
+// try {
+// const response = await fetch(url, options);
+// if (!response.ok) {
+// // We handle non-ok responses immediately
+// throw new Error(`API request failed with status ${response.status}`);
+// }
+// // updateLastRequestTime(method); // Assumed to be a function that updates some kind of state
+// return await response.json(); // Directly returning the JSON response
+// } catch (error) {
+// console.error(`Fetch failed: ${error}`);
+// console.trace();
+// throw error; // Re-throwing the error for upstream catch blocks to handle
+// }
+// };
+
+// export const CardImagesProvider = ({ children }) => {
+// const [cards, setCards] = useState([]);
+// const [images, setImages] = useState([]); // [
+// const [randomCardImage, setRandomCardImage] = useState(null);
+// const [imageSrc, setImageSrc] = useState(null);
+// const [isLoading, setIsLoading] = useState(false);
+// const [error, setError] = useState(null);
+// // const BASE_API_URL = 'http://localhost:3001/api/card-image';
+// const BASE_API_URL = `${process.env.REACT_APP_SERVER}/api/card-image`;
+
+// // Function to download card images
+// const downloadCardImages = async () => {
+// setIsLoading(true);
+// try {
+// const response = await fetchWrapper(BASE_API_URL + '/download', 'GET');
+// const fetchedCards = response.data;
+// const imageUrls = fetchedCards
+// .map((card) => {
+// if (card.card_images && card.card_images.length > 0) {
+// return card.card_images[0].image_url + '?dummy=' + Date.now();
+// }
+// return null; // or some placeholder image URL
+// })
+// .filter(Boolean); // Remove any nulls
+
+// setCards(fetchedCards);
+// setImages(imageUrls); // Set all image URLs at once
+// } catch (error) {
+// console.error('Error in downloadCardImages:', error);
+// setError(error.message);
+// } finally {
+// setIsLoading(false);
+// }
+// };
+
+// // useEffect(() => {
+// // downloadCardImages();
+// // }, []);
+
+// // Handle random card image selection
+// useEffect(() => {
+// if (cards && cards.length > 0) {
+// const randomCardIndex = Math.floor(Math.random() * cards.length);
+// const randomCard = cards[randomCardIndex];
+// if (
+// randomCard &&
+// randomCard.card_images &&
+// randomCard.card_images.length > 0
+// ) {
+// setRandomCardImage(randomCard.card_images[0].image_url);
+// }
+// }
+// }, [cards]); // Dependency on cards means this will rerun when cards are fetched/updated
+
+// useEffect(() => {
+// if (images && images.length > 0) {
+// const randomCard = images[Math.floor(Math.random() * images.length)];
+// if (randomCard.card_images && randomCard.card_images.length > 0) {
+// setRandomCardImage(randomCard.card_images[0].image_url);
+// }
+// }
+// }, [images]);
+
+// return (
+//
+// {children}
+//
+// );
+// };
diff --git a/src/assets/currentlyUnused/CardImagesContext/useCardManager.jsx b/src/assets/currentlyUnused/CardImagesContext/useCardManager.jsx
new file mode 100644
index 0000000..8c2c4e3
--- /dev/null
+++ b/src/assets/currentlyUnused/CardImagesContext/useCardManager.jsx
@@ -0,0 +1,39 @@
+// import { useState } from 'react';
+
+// const useCardManager = (initialCards = []) => {
+// const [cards, setCards] = useState(initialCards);
+
+// // General function to update a card
+// const updateCard = (cardId, updatedData) => {
+// setCards((currentCards) =>
+// currentCards.map((card) =>
+// card.id === cardId ? { ...card, ...updatedData } : card
+// )
+// );
+// };
+
+// // Add a new card
+// const addCard = (newCardData) => {
+// setCards([...cards, newCardData]);
+// };
+
+// // General utility to update a specific field of a card
+// const updateField = (cardId, field, value) => {
+// updateCard(cardId, { [field]: value });
+// };
+
+// // Update a nested field like priceHistory or card_images
+// const updateNestedField = (cardId, field, newValue) => {
+// const card = cards.find((card) => card.id === cardId);
+// updateCard(cardId, { [field]: [...card[field], newValue] });
+// };
+
+// return {
+// cards,
+// addCard,
+// updateCard: updateField, // for updating single fields
+// updateNestedField, // for updating nested fields like arrays
+// };
+// };
+
+// export default useCardManager;
diff --git a/src/assets/currentlyUnused/CardImagesContext/useCardVariantManager.jsx b/src/assets/currentlyUnused/CardImagesContext/useCardVariantManager.jsx
new file mode 100644
index 0000000..88a8f22
--- /dev/null
+++ b/src/assets/currentlyUnused/CardImagesContext/useCardVariantManager.jsx
@@ -0,0 +1,73 @@
+// import { useState } from 'react';
+
+// const useCardVariantManager = (initialCards = []) => {
+// const [cards, setCards] = useState(initialCards);
+
+// // Function to identify the variant index
+// const findVariantIndex = (cardId, setCode) =>
+// cards.findIndex(
+// (card) => card.id === cardId && card.card_set.set_code === setCode
+// );
+
+// // Function to determine overlay based on rarity
+// const getOverlayByRarity = (rarity) => {
+// // Define overlays for different rarities
+// const overlays = {
+// Common: 'commonOverlay',
+// Rare: 'rareOverlay',
+// 'Ultra Rare': 'ultraRareOverlay',
+// // ... other rarities
+// };
+// return overlays[rarity] || 'defaultOverlay';
+// };
+
+// // Function to update a specific variant field
+// const updateVariantField = (cardId, setCode, field, value) => {
+// const index = findVariantIndex(cardId, setCode);
+// if (index < 0) return; // Variant not found
+
+// const updatedCards = [...cards];
+// updatedCards[index] = {
+// ...updatedCards[index],
+// [field]: value,
+// // Update overlay based on rarity
+// overlay: getOverlayByRarity(updatedCards[index].card_set.set_rarity),
+// };
+// setCards(updatedCards);
+// };
+
+// // Function to add a new variant
+// const addVariant = (cardId, newVariantData) => {
+// const updatedCards = [...cards];
+// updatedCards.push({
+// ...newVariantData,
+// id: cardId,
+// // Assign overlay based on rarity
+// overlay: getOverlayByRarity(newVariantData.card_set.set_rarity),
+// });
+// setCards(updatedCards);
+// };
+
+// // Function to update nested fields like priceHistory for a specific variant
+// const updateNestedField = (cardId, setCode, field, newValue) => {
+// const index = findVariantIndex(cardId, setCode);
+// if (index < 0) return; // Variant not found
+
+// const updatedCards = [...cards];
+// const variant = updatedCards[index];
+// updatedCards[index] = {
+// ...variant,
+// [field]: [...variant[field], newValue],
+// };
+// setCards(updatedCards);
+// };
+
+// return {
+// cards,
+// addVariant,
+// updateVariantField,
+// updateNestedField,
+// };
+// };
+
+// export default useCardVariantManager;
diff --git a/src/assets/animations/CardStormAnimation.jsx b/src/assets/currentlyUnused/CardStormAnimation.jsx
similarity index 100%
rename from src/assets/animations/CardStormAnimation.jsx
rename to src/assets/currentlyUnused/CardStormAnimation.jsx
diff --git a/src/context/MISC_CONTEXT/CombinedContext/CombinedProvider.jsx b/src/assets/currentlyUnused/CombinedContext/CombinedProvider.jsx
similarity index 100%
rename from src/context/MISC_CONTEXT/CombinedContext/CombinedProvider.jsx
rename to src/assets/currentlyUnused/CombinedContext/CombinedProvider.jsx
diff --git a/src/context/MISC_CONTEXT/CombinedContext/helpers.jsx b/src/assets/currentlyUnused/CombinedContext/helpers.jsx
similarity index 100%
rename from src/context/MISC_CONTEXT/CombinedContext/helpers.jsx
rename to src/assets/currentlyUnused/CombinedContext/helpers.jsx
diff --git a/src/assets/currentlyUnused/LoginForm.jsx b/src/assets/currentlyUnused/LoginForm.jsx
new file mode 100644
index 0000000..68ab149
--- /dev/null
+++ b/src/assets/currentlyUnused/LoginForm.jsx
@@ -0,0 +1,36 @@
+// import React from 'react';
+// import LoginIcon from '@mui/icons-material/Login';
+// import PersonIcon from '@mui/icons-material/Person';
+// import LockIcon from '@mui/icons-material/Lock';
+// import RCZodForm from './reusable/RCZodForm';
+
+// const loginFields = [
+// {
+// name: 'username',
+// label: 'Username',
+// type: 'text',
+// icon: ,
+// field: 'username',
+// },
+// {
+// name: 'password',
+// label: 'Password',
+// type: 'password',
+// icon: ,
+// field: 'password',
+// },
+// ];
+
+// const LoginForm = () => {
+// const startIcon = ;
+// return (
+//
+// );
+// };
+
+// export default LoginForm;
diff --git a/src/assets/currentlyUnused/PageContext/PageContext.jsx b/src/assets/currentlyUnused/PageContext/PageContext.jsx
new file mode 100644
index 0000000..3a5b9f7
--- /dev/null
+++ b/src/assets/currentlyUnused/PageContext/PageContext.jsx
@@ -0,0 +1,67 @@
+// import React, {
+// createContext,
+// useState,
+// useContext,
+// useEffect,
+// useMemo,
+// } from 'react';
+// import LoadingIndicator from '../../../layout/LoadingIndicator';
+// import ErrorIndicator from '../../../layout/ErrorIndicator';
+// import SplashPage2 from '../../../layout/REUSABLE_COMPONENTS/SplashPage2';
+// // import useSnackBar from '../../hooks/useSnackBar';
+// import { defaultContextValue } from '../../constants';
+// import { useLoading } from '../../hooks/useLoading';
+
+// const PageContext = createContext(defaultContextValue.PAGE_CONTEXT);
+
+// export const PageProvider = ({ children }) => {
+// const {
+// isLoading,
+// isAnyLoading,
+// startLoading,
+// stopLoading,
+// setError,
+// error,
+// clearLoading,
+// } = useLoading();
+// const returnDisplay = () => {
+// if (error) {
+// return ;
+// }
+// if (isLoading('isPageLoading')) {
+// return ;
+// } else if (isAnyLoading()) {
+// return ;
+// }
+// return null;
+// };
+// const contextValue = useMemo(
+// () => ({
+// startLoading,
+// stopLoading,
+// setError,
+// error,
+// isLoading,
+// clearLoading,
+// returnDisplay,
+// // You can expose any additional functionalities from useLoading as needed.
+// }),
+// [
+// startLoading,
+// stopLoading,
+// setError,
+// error,
+// isLoading,
+// clearLoading,
+// returnDisplay,
+// ]
+// );
+
+// return (
+//
+// {children}{' '}
+//
+// );
+// };
+
+// export const usePageContext = () => useContext(PageContext);
diff --git a/src/assets/currentlyUnused/ProfileForm.jsx b/src/assets/currentlyUnused/ProfileForm.jsx
new file mode 100644
index 0000000..4dd6dc3
--- /dev/null
+++ b/src/assets/currentlyUnused/ProfileForm.jsx
@@ -0,0 +1,75 @@
+// import React, { useState, useEffect } from 'react';
+// import PropTypes from 'prop-types';
+// import { TextField, Button } from '@mui/material';
+// import { useFormContext } from '../../context';
+// import FormField from './reusable/FormField';
+
+// const ProfileForm = ({ userName, name, age, status, onSave }) => {
+// const { forms, handleChange, handleSubmit } = useFormContext();
+// const profileValues = forms?.updateUserDataForm || {};
+// const formType = 'updateUserDataForm';
+// const handleFormSubmit = (event) => {
+// event.preventDefault(); // Prevent the default form submission behavior
+// handleSubmit(formType)(event); // Pass the event to your form handler
+// };
+
+// return (
+//
+// );
+// };
+
+// ProfileForm.propTypes = {
+// username: PropTypes.string,
+// firstName: PropTypes.string,
+// lastName: PropTypes.string,
+
+// age: PropTypes.string,
+// status: PropTypes.string,
+// onSave: PropTypes.func.isRequired,
+// };
+
+// export default ProfileForm;
diff --git a/src/assets/currentlyUnused/SignupForm.jsx b/src/assets/currentlyUnused/SignupForm.jsx
new file mode 100644
index 0000000..4bc256f
--- /dev/null
+++ b/src/assets/currentlyUnused/SignupForm.jsx
@@ -0,0 +1,57 @@
+// import React from 'react';
+// import PersonAddIcon from '@mui/icons-material/PersonAdd';
+// import PersonIcon from '@mui/icons-material/Person';
+// import EmailIcon from '@mui/icons-material/Email';
+// import LockIcon from '@mui/icons-material/Lock';
+// import RCZodForm from './reusable/RCZodForm';
+
+// const signupFields = [
+// {
+// name: 'firstName',
+// label: 'First Name',
+// type: 'text',
+// icon: ,
+// field: 'firstName',
+// },
+// {
+// name: 'lastName',
+// label: 'Last Name',
+// type: 'text',
+// icon: ,
+// field: 'lastName',
+// },
+// {
+// name: 'email',
+// label: 'Email',
+// type: 'email',
+// icon: ,
+// field: 'email',
+// },
+// {
+// name: 'username',
+// label: 'Username',
+// type: 'text',
+// icon: ,
+// field: 'username',
+// },
+// {
+// name: 'password',
+// label: 'Password',
+// type: 'password',
+// icon: ,
+// field: 'password',
+// },
+// ];
+
+// const SignupForm = () => {
+// return (
+// }
+// />
+// );
+// };
+
+// export default SignupForm;
diff --git a/src/assets/animations/SingleCardRowAnimation.jsx b/src/assets/currentlyUnused/SingleCardRowAnimation.jsx
similarity index 100%
rename from src/assets/animations/SingleCardRowAnimation.jsx
rename to src/assets/currentlyUnused/SingleCardRowAnimation.jsx
diff --git a/src/assets/currentlyUnused/SocketContext/SocketProvider.jsx b/src/assets/currentlyUnused/SocketContext/SocketProvider.jsx
new file mode 100644
index 0000000..46cdcc2
--- /dev/null
+++ b/src/assets/currentlyUnused/SocketContext/SocketProvider.jsx
@@ -0,0 +1,40 @@
+// import React, {
+// createContext,
+// useContext,
+// useEffect,
+// useMemo,
+// useState,
+// } from 'react';
+// import io from 'socket.io-client';
+
+// const SocketContext = createContext();
+
+// export const SocketProvider = ({ children }) => {
+// const [socket, setSocket] = useState(null);
+
+// useEffect(() => {
+// const socketInstance = io(
+// process.env.REACT_APP_SERVER || 'ws://localhost:3001',
+// {
+// transports: ['websocket'],
+// }
+// );
+// setSocket(socketInstance);
+
+// return () => {
+// socketInstance.disconnect();
+// };
+// }, []);
+
+// return (
+// {children}
+// );
+// };
+
+// export const useSocketContext = () => {
+// const context = useContext(SocketContext);
+// if (context === undefined) {
+// throw new Error('useSocketContext must be used within a SocketProvider');
+// }
+// return context;
+// };
diff --git a/src/assets/animations/SplashPage.js b/src/assets/currentlyUnused/SplashPage.js
similarity index 100%
rename from src/assets/animations/SplashPage.js
rename to src/assets/currentlyUnused/SplashPage.js
diff --git a/src/assets/currentlyUnused/TopCardsDisplay.jsx b/src/assets/currentlyUnused/TopCardsDisplay.jsx
new file mode 100644
index 0000000..4fea8c6
--- /dev/null
+++ b/src/assets/currentlyUnused/TopCardsDisplay.jsx
@@ -0,0 +1,188 @@
+// import React, { useEffect, useRef, useState } from 'react';
+// import SwipeableViews from 'react-swipeable-views';
+// import {
+// Box,
+// Button,
+// Container,
+// Grid,
+// MobileStepper,
+// useMediaQuery,
+// useTheme,
+// } from '@mui/material';
+// import { KeyboardArrowLeft, KeyboardArrowRight } from '@mui/icons-material';
+// import { useCollectionStore } from '../../../context/MAIN_CONTEXT/CollectionContext/CollectionContext';
+// import { styled } from 'styled-components';
+
+// import { MainContainer } from '../../../pages/pageStyles/StyledComponents';
+// import CarouselCard from '../../../components/cards/CarouselCard';
+// import LoadingIndicator from '../../../components/reusable/indicators/LoadingIndicator';
+// import { useMode } from '../../../context';
+
+// const StyledStepper = styled(MobileStepper)(({ theme }) => ({
+// background: theme.palette.backgroundB.dark,
+// border: `1px solid ${theme.palette.backgroundB.lighter}`,
+// borderRadius: theme.shape.borderRadiusLarge,
+// color: theme.palette.backgroundA.light,
+// overflow: 'hidden',
+// padding: theme.spacing(1),
+// height: '100%',
+// '@media (max-width: 600px)': {
+// width: '100%', // Full width on mobile screens
+// padding: theme.spacing(0.5), // Reduced padding on mobile
+// },
+// }));
+
+// const StyledCardDetails = styled(Box)(({ theme }) => ({
+// display: 'flex',
+// flexDirection: 'column',
+// justifyContent: 'center',
+// alignItems: 'center',
+// }));
+
+// const StyledSwipeableView = styled(SwipeableViews)(({ theme }) => ({
+// '@media (max-width: 600px)': {
+// width: '100%', // Full width on mobile screens
+// overflow: 'hidden', // Hide overflow on mobile
+// },
+// }));
+
+// const StyledContainer = styled(Container)(({ theme }) => ({
+// display: 'flex',
+// flexDirection: 'column',
+// // Set a maximum height to prevent expansion. Adjust according to your needs.
+// maxHeight: '100vh',
+// overflow: 'auto', // Add scroll if content exceeds container size
+// alignItems: 'center',
+// background: theme.palette.backgroundB.darker,
+// borderRadius: theme.shape.borderRadiusLarge,
+// padding: theme.spacing(3),
+// color: '#fff',
+// '@media (max-width: 600px)': {
+// padding: theme.spacing(1), // Reduced padding on mobile
+// },
+// }));
+
+// // Assuming SwipeableViews and CarouselCard do not need custom styling here
+// // If they do, use styled in a similar manner
+
+// const TopCardsDisplay = () => {
+// const { theme } = useMode();
+// const theme2 = useTheme();
+// const { selectedCollection } = useCollectionStore();
+// const [top5Cards, setTop5Cards] = useState([]);
+// const [activeStep, setActiveStep] = useState(0);
+// const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
+
+// useEffect(() => {
+// const sortedCards = selectedCollection?.cards
+// ?.map((card) => {
+// const latestPrice = card?.latestPrice?.num ?? 0;
+// const lastSavedPrice = card?.lastSavedPrice?.num ?? 0;
+// if (latestPrice === undefined) {
+// console.warn(`Price missing for card: ${card.name}`);
+// return { ...card, diff: 0 };
+// }
+// return { ...card, diff: Math.abs(latestPrice - lastSavedPrice) };
+// })
+// .sort((a, b) => b.diff - a.diff || b.price - a.price)
+// .slice(0, 5);
+// setTop5Cards(sortedCards);
+// }, [selectedCollection]);
+
+// const maxSteps = top5Cards?.length;
+// const handleNext = () => setActiveStep((prev) => prev + 1);
+// const handleBack = () => setActiveStep((prev) => prev - 1);
+// const isSmall = useMediaQuery(theme2.breakpoints.down('sm'));
+// if (!selectedCollection) {
+// return (
+//
+//
+//
+// );
+// }
+
+// return (
+//
+// {/* */}
+//
+//
+//
+// {top5Cards?.map((card, index) => (
+//
+//
+//
+// ))}
+//
+//
+// {theme.direction === 'rtl' ? (
+//
+// ) : (
+//
+// )}{' '}
+// Next
+//
+// }
+// backButton={
+//
+// }
+// />
+//
+//
+// {/* */}
+//
+// );
+// };
+
+// export default TopCardsDisplay;
diff --git a/src/assets/currentlyUnused/UpdateCollectionForm.jsx b/src/assets/currentlyUnused/UpdateCollectionForm.jsx
new file mode 100644
index 0000000..fdf6970
--- /dev/null
+++ b/src/assets/currentlyUnused/UpdateCollectionForm.jsx
@@ -0,0 +1,55 @@
+// import React, { useEffect } from 'react';
+// import { useFormContext, useMode } from '../../context';
+// import useSnackbarManager from '../../context/hooks/useSnackbarManager';
+// import RCZodForm from './reusable/RCZodForm';
+
+// const updateCollectionFields = [
+// {
+// name: 'name',
+// label: 'Name',
+// type: 'text',
+// required: true,
+// },
+// {
+// name: 'description',
+// label: 'Description',
+// type: 'text',
+// required: true,
+// multiline: true,
+// rows: 4,
+// },
+// ];
+
+// const UpdateCollectionForm = ({ collectionData }) => {
+// const { setFormSchema, onSubmit } = useFormContext();
+// const { theme } = useMode();
+// const { showSuccess, showError } = useSnackbarManager();
+
+// useEffect(() => {
+// if (collectionData) {
+// setFormSchema('updateCollectionForm', collectionData);
+// }
+// }, [collectionData, setFormSchema]);
+
+// const handleFormSubmit = async (data) => {
+// try {
+// await onSubmit(data, 'updateCollectionForm', collectionData?._id);
+// showSuccess("You've successfully updated the collection.");
+// } catch (error) {
+// showError('Failed to update collection. Please try again.');
+// }
+// };
+
+// return (
+//
+// );
+// };
+
+// export default UpdateCollectionForm;
diff --git a/src/assets/currentlyUnused/UpdateDeckForm.jsx b/src/assets/currentlyUnused/UpdateDeckForm.jsx
new file mode 100644
index 0000000..6d4fbcf
--- /dev/null
+++ b/src/assets/currentlyUnused/UpdateDeckForm.jsx
@@ -0,0 +1,65 @@
+// import React from 'react';
+// import RCZodForm from './RCZodForm';
+// import SaveIcon from '@mui/icons-material/Save';
+// import DeleteIcon from '@mui/icons-material/Delete';
+// import { useFormContext } from '../../context';
+
+// // Assume the schema is defined elsewhere and imported here
+// // import { updateDeckFormSchema } from './yourSchemaDefinitions';
+
+// const updateDeckFields = [
+// {
+// name: 'name',
+// label: 'Name',
+// type: 'text',
+// icon: null, // No icons used for these fields
+// },
+// {
+// name: 'description',
+// label: 'Description',
+// type: 'text',
+// multiline: true,
+// rows: 4,
+// icon: null,
+// },
+// ];
+
+// const UpdateDeckForm = ({ selectedDeck }) => {
+// const { onSubmit } = useFormContext(); // Assuming useFormContext provides onSubmit
+
+// // Placeholder for the submission logic within the component or from props
+// const handleSubmit = (data) => {
+// console.log('Submitting update deck data:', data);
+// onSubmit(data, 'updateDeckForm'); // This should align with your context action
+// };
+
+// // Placeholder for the deletion logic within the component or from props
+// const handleDelete = () => {
+// console.log('Deleting deck:', selectedDeck._id);
+// // Here you would call a context function or similar to delete the deck
+// onSubmit({ _id: selectedDeck._id, delete: true }, 'updateDeckForm');
+// };
+
+// return (
+// }
+// additionalButtons={[
+// {
+// label: 'Delete Deck',
+// onClick: handleDelete,
+// startIcon: ,
+// color: 'error',
+// variant: 'contained',
+// disabled: !selectedDeck,
+// },
+// ]}
+// defaultValues={selectedDeck} // Assuming this prop is structured correctly for the form
+// />
+// );
+// };
+
+// export default UpdateDeckForm;
diff --git a/src/assets/currentlyUnused/collectionUtility.jsx b/src/assets/currentlyUnused/collectionUtility.jsx
new file mode 100644
index 0000000..5c22c81
--- /dev/null
+++ b/src/assets/currentlyUnused/collectionUtility.jsx
@@ -0,0 +1,21 @@
+// /* eslint-disable @typescript-eslint/no-empty-function */
+// export const calculateCollectionValue = (collection) => {
+// if (!collection) return 0;
+
+// const cards = collection?.cards;
+
+// if (!Array.isArray(cards)) {
+// console.warn('Invalid collection format', collection, cards);
+// return 0;
+// }
+
+// return cards.reduce((totalValue, card) => {
+// const cardPrice = card?.price || 0;
+// const cardQuantity = card?.quantity || 0;
+// return totalValue + cardPrice * cardQuantity;
+// }, 0);
+// };
+
+// export const shouldFetchCollections = (prevUserId, currentUserId) => {
+// return prevUserId !== currentUserId && currentUserId != null;
+// };
diff --git a/src/assets/themes/colors/Azure.jsx b/src/assets/currentlyUnused/colors/Azure.jsx
similarity index 100%
rename from src/assets/themes/colors/Azure.jsx
rename to src/assets/currentlyUnused/colors/Azure.jsx
diff --git a/src/assets/themes/colors/Cyan.jsx b/src/assets/currentlyUnused/colors/Cyan.jsx
similarity index 100%
rename from src/assets/themes/colors/Cyan.jsx
rename to src/assets/currentlyUnused/colors/Cyan.jsx
diff --git a/src/assets/themes/colors/Dark.jsx b/src/assets/currentlyUnused/colors/Dark.jsx
similarity index 100%
rename from src/assets/themes/colors/Dark.jsx
rename to src/assets/currentlyUnused/colors/Dark.jsx
diff --git a/src/assets/themes/colors/DeepPurple.jsx b/src/assets/currentlyUnused/colors/DeepPurple.jsx
similarity index 100%
rename from src/assets/themes/colors/DeepPurple.jsx
rename to src/assets/currentlyUnused/colors/DeepPurple.jsx
diff --git a/src/assets/themes/colors/Default.jsx b/src/assets/currentlyUnused/colors/Default.jsx
similarity index 100%
rename from src/assets/themes/colors/Default.jsx
rename to src/assets/currentlyUnused/colors/Default.jsx
diff --git a/src/assets/themes/colors/Indigo.jsx b/src/assets/currentlyUnused/colors/Indigo.jsx
similarity index 100%
rename from src/assets/themes/colors/Indigo.jsx
rename to src/assets/currentlyUnused/colors/Indigo.jsx
diff --git a/src/assets/themes/colors/Light.jsx b/src/assets/currentlyUnused/colors/Light.jsx
similarity index 100%
rename from src/assets/themes/colors/Light.jsx
rename to src/assets/currentlyUnused/colors/Light.jsx
diff --git a/src/assets/themes/colors/LightBlue.jsx b/src/assets/currentlyUnused/colors/LightBlue.jsx
similarity index 100%
rename from src/assets/themes/colors/LightBlue.jsx
rename to src/assets/currentlyUnused/colors/LightBlue.jsx
diff --git a/src/context/MAIN_CONTEXT/CollectionContext/helpers.jsx b/src/assets/currentlyUnused/helpers.jsx
similarity index 100%
rename from src/context/MAIN_CONTEXT/CollectionContext/helpers.jsx
rename to src/assets/currentlyUnused/helpers.jsx
diff --git a/src/assets/currentlyUnused/menuItemsData.jsx b/src/assets/currentlyUnused/menuItemsData.jsx
new file mode 100644
index 0000000..fc5a409
--- /dev/null
+++ b/src/assets/currentlyUnused/menuItemsData.jsx
@@ -0,0 +1,137 @@
+// import React, { useCallback, useState } from 'react';
+// import {
+// Home as HomeIcon,
+// Store as StoreIcon,
+// ShoppingCart as CartIcon,
+// Assessment as CollectionIcon,
+// Person as ProfileIcon,
+// } from '@mui/icons-material';
+// import DeckBuilderIcon from '../REUSABLE_COMPONENTS/icons/DeckBuilderIcon';
+// import { Badge } from '@mui/material';
+// import { useCartStore } from '../../context/MAIN_CONTEXT/CartContext/CartContext';
+// import { IconButton } from '@mui/joy';
+// import MenuIcon from '@mui/icons-material/Menu';
+
+// // const iconWrapper = (icon) => {
+// // return (
+// //
+// // {icon}
+// //
+// // );
+// // };
+// export const getMenuItemsData = ({
+// isLoggedIn,
+// cartCardQuantity,
+// // iconColor,
+// // isOpen,
+// // setIsOpen,
+// }) => {
+// // const { cartCardQuantity } = useCartStore();
+// // const [isOpen, setIsOpen] = useState(false); // Manage open state locally
+// // const toggleSidebar = useCallback(() => setIsOpen(!isOpen), [isOpen]);
+// // const iconColor = isMobileView ? theme.palette.primary.main : 'white';
+
+// try {
+// const baseMenuItems = [
+// {
+// name: 'Menu',
+// icon: ,
+// to: '/',
+// requiresLogin: false,
+// },
+// { name: 'Home', icon: , to: '/home', requiresLogin: false },
+// {
+// name: 'Deck',
+// // icon: ,
+// icon: ,
+// to: '/deckbuilder',
+// requiresLogin: false,
+// },
+// {
+// name: 'Collection',
+// icon: ,
+// to: '/collection',
+// requiresLogin: !isLoggedIn,
+// },
+// {
+// name: 'Store',
+// icon: ,
+// to: '/store',
+// requiresLogin: !isLoggedIn,
+// },
+// {
+// name: 'Cart',
+// icon: (
+//
+//
+//
+// ),
+// to: '/cart',
+// requiresLogin: !isLoggedIn,
+// },
+// {
+// name: 'Profile',
+// icon: ,
+// to: '/profile',
+// requiresLogin: isLoggedIn,
+// },
+// // {
+// // name: 'Login',
+// // icon: ,
+// // to: '/login',
+// // requiresLogin: false,
+// // },
+// ];
+
+// if (isLoggedIn) {
+// return baseMenuItems.map((item) => ({
+// ...item,
+// requiresLogin: false,
+// }));
+// }
+
+// // Processed menu items
+// const processedMenuItems = isLoggedIn
+// ? baseMenuItems.map((item) => ({ ...item, requiresLogin: false }))
+// : baseMenuItems;
+
+// return {
+// baseMenuItems,
+// menuItems: processedMenuItems,
+// };
+// } catch (error) {
+// console.error('An error occurred in getMenuItemsData:', error);
+// return {
+// baseMenuItems: [],
+// menuItems: [],
+// };
+// }
+// };
+
+// export default getMenuItemsData;
diff --git a/src/assets/currentlyUnused/useCollectionStats.jsx b/src/assets/currentlyUnused/useCollectionStats.jsx
new file mode 100644
index 0000000..d4de332
--- /dev/null
+++ b/src/assets/currentlyUnused/useCollectionStats.jsx
@@ -0,0 +1,84 @@
+// import { useEffect, useState } from 'react';
+// import useSelectedCollection from './useSelectedCollection';
+
+// const useCollectionStats = () => {
+// const { allCollections } = useSelectedCollection();
+// const [collectionStats, setCollectionStats] = useState({});
+// const [metaStats, setMetaStats] = useState({});
+// const totals = [];
+// const quantities = [];
+// useEffect(() => {
+// const stats = {};
+// for (const collection of allCollections) {
+// const {
+// totalPrice,
+// totalQuantity, // Fixed typo from 'toalQuantity' to 'totalQuantity'
+// nivoChartData,
+// newNivoChartData,
+// nivoTestData,
+// averagedChartData,
+// chartData,
+// muiChartData,
+// name,
+// descriptions,
+// lastUpdated,
+// collectionPriceHistory,
+// dailyCollectionPriceHistory,
+// createdAt,
+// collectionStatistics,
+// id, // Assuming 'id' is available in 'collection' for mapping
+// } = collection;
+
+// const { avgPrice, highPoint, lowPoint, percentageChange, priceChange } =
+// collectionStatistics;
+
+// totals.push(totalPrice);
+// quantities.push(totalQuantity);
+
+// stats[collection.id] = {
+// totalPrice,
+// totalQuantity,
+// nivoChartData,
+// newNivoChartData,
+// nivoTestData,
+// averagedChartData,
+// chartData,
+// muiChartData,
+// name,
+// descriptions,
+// lastUpdated,
+// collectionPriceHistory,
+// dailyCollectionPriceHistory,
+// createdAt,
+// avgPrice,
+// highPoint,
+// lowPoint,
+// percentageChange,
+// priceChange,
+// collectionStatistics,
+// };
+// }
+
+// setCollectionStats(stats);
+// console.log('COLLECTION STATS RECORDED: ', stats);
+// }, []); // Dependency array ensures this effect runs only when allCollections changes
+
+// const calculateAndSetMetaStats = () => {
+// const metaStats = {};
+// metaStats.totalValue = totals.reduce((acc, total) => acc + total, 0);
+// metaStats.totalQuantity = quantities.reduce(
+// (acc, quantity) => acc + quantity,
+// 0
+// );
+// setMetaStats(metaStats);
+// console.log('META STATS RECORDED: ', metaStats);
+// return metaStats;
+// };
+
+// useEffect(() => {
+// calculateAndSetMetaStats();
+// }, []);
+// return { collectionStats, metaStats };
+// };
+
+// export default useCollectionStats;
diff --git a/src/assets/themes/GlobalStyles.js b/src/assets/themes/GlobalStyles.js
index cd518fd..1c12c75 100644
--- a/src/assets/themes/GlobalStyles.js
+++ b/src/assets/themes/GlobalStyles.js
@@ -24,10 +24,6 @@ const MyGlobalStyles = () => (
textDecoration: 'none', // remove underline from all links
color: 'inherit', // links will inherit their parent color
},
- // '*::-webkit-scrollbar': {
- // visibility: 'hidden',
- // // width: '8px',
- // },
'*::-webkit-scrollbar-track': {
backgroundColor: 'gray.200',
},
@@ -35,29 +31,6 @@ const MyGlobalStyles = () => (
backgroundColor: 'gray.500',
borderRadius: '20px',
},
- // h1: {
- // fontSize: '2.5rem', // styling for h1 tags
- // fontWeight: 'bold',
- // },
- // h2: {
- // fontSize: '2rem', // styling for h2 tags
- // fontWeight: 'bold',
- // },
- // h3: {
- // fontSize: '1.75rem', // styling for h3 tags
- // },
- // h4: {
- // fontSize: '1.5rem', // styling for h4 tags
- // },
- // h5: {
- // fontSize: '1.25rem', // styling for h5 tags
- // },
- // h6: {
- // fontSize: '1rem', // styling for h6 tags
- // },
- // p: {
- // fontSize: '1rem', // styling for p tags
- // },
}}
/>
);
diff --git a/src/assets/themes/base/colors.jsx b/src/assets/themes/base/colors.jsx
index 3bd6619..3bd79c6 100644
--- a/src/assets/themes/base/colors.jsx
+++ b/src/assets/themes/base/colors.jsx
@@ -15,9 +15,15 @@ import {
text,
divider,
action,
+ primary,
+ secondary,
} from './customColorPalettes';
const colors = {
chartTheme: chartTheme,
+ background: {
+ default: '#f0f2f5',
+ paper: '#fff',
+ },
// PRIMARY COLORS
backgroundA,
backgroundD: {
@@ -67,9 +73,6 @@ const colors = {
qcr: hexToRgba(rarity.qcr, 0.5),
// Add more rarities as needed
},
- background: {
- default: '#f0f2f5',
- },
// TEXT COLORS
text,
// DIVIDER COLORS
@@ -117,20 +120,9 @@ const colors = {
focus: '#05386B',
},
- primary: {
- main: '#5CDB95',
- focus: '#379683',
- },
+ primary,
- // primary: {
- // main: '#e91e63',
- // focus: '#e91e63',
- // },
-
- secondary: {
- main: '#7b809a',
- focus: '#8f93a9',
- },
+ secondary,
light: {
main: '#f0f2f5',
focus: '#f0f2f5',
@@ -182,6 +174,9 @@ const colors = {
error: {
main: '#EF5350',
state: '#E53935',
+ dark: '#C62828',
+ darker: '#D32F2F',
+ evenDarker: '#DC143C',
},
light: {
diff --git a/src/assets/themes/base/customColorPalettes.jsx b/src/assets/themes/base/customColorPalettes.jsx
index 931a134..21ca42f 100644
--- a/src/assets/themes/base/customColorPalettes.jsx
+++ b/src/assets/themes/base/customColorPalettes.jsx
@@ -1,8 +1,10 @@
import hexToRgba from '../functions/hexToRgba';
const error = {
+ light: '#e57373',
main: '#f44336',
focus: '#f44336',
dark: '#d32f2f',
+ darkest: '#7f2e2eff', // --persian-plum--
contrastText: '#fff',
hoverContrastText: '#111',
};
@@ -112,7 +114,6 @@ const backgroundF = {
lighter: hexToRgba(backgroundE.lighter, 0.4),
lightest: hexToRgba(backgroundE.lightest, 0.3),
};
-
const backgroundG = {
darkest: '#073b4cff', // --midnight-green--
darker: '#0c637fff', // --cerulean--
@@ -133,7 +134,6 @@ const backgroundGSecondary = {
lightest: '#facbb0ff', // --navajo-white--
contrastText: '#fff',
};
-
const grey = {
darkest: '#141414',
darkert: '#292929',
@@ -145,18 +145,23 @@ const grey = {
evenLighter: '#c2c2c2',
contrastText: '#e0e0e0',
};
-
const primary = {
darkest: '#040509',
darker: '#040509',
dark: '#040509',
default: '#f2f0f0',
+ main: '#5CDB95',
+ focus: '#379683',
light: '#141b2d',
lighter: '#1F2A40',
lightest: '#727681',
- evenLighter: '#a1a4ab',
+ evenLighter: '#8c8c8c',
contrastText: '#e0e0e0',
};
+const secondary = {
+ main: '#8c8c8c',
+ focus: '#8f93a9',
+};
const greenAccent = {
darkest: '#0f2922', // Assuming this is the darkest
@@ -169,7 +174,6 @@ const greenAccent = {
evenLighter: '#b7ebde', // Even lighter than the lightest
contrastText: '#dbf5ee', // Most contrasting or lightest, could be adjusted
};
-
const redAccent = {
darkest: '#2c100f',
darker: '#58201e',
@@ -181,7 +185,6 @@ const redAccent = {
evenLighter: '#f1b9b7',
contrastText: '#f8dcdb',
};
-
const blueAccent = {
darkest: '#151632',
darker: '#2a2d64',
@@ -193,7 +196,6 @@ const blueAccent = {
evenLighter: '#c3c6fd',
contrastText: '#e1e2fe',
};
-
const chartTheme = {
primary,
grey,
@@ -201,7 +203,6 @@ const chartTheme = {
redAccent,
blueAccent,
};
-
const rarity = {
common: '#C0C0C0', // Silver
uncommon: '#B8860B', // DarkGoldenRod
@@ -218,7 +219,6 @@ const rarity = {
qcr: '#FF4500', // OrangeRed
// Add more rarities as needed
};
-
export {
chartTheme,
backgroundA,
@@ -237,6 +237,8 @@ export {
text,
divider,
action,
+ primary,
+ secondary,
};
// error: {
// main: colorsA.redAccent[500],
diff --git a/src/assets/themes/base/typography.jsx b/src/assets/themes/base/typography.jsx
index 846a45e..7bd293d 100644
--- a/src/assets/themes/base/typography.jsx
+++ b/src/assets/themes/base/typography.jsx
@@ -5,32 +5,16 @@ import colors from './colors';
const { dark } = colors;
-// const baseProperties = {
-// fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
-// fontWeightLighter: 100,
-// fontWeightLight: 300,
-// fontWeightRegular: 400,
-// fontWeightMedium: 600,
-// fontWeightBold: 700,
-// fontSizeXXS: pxToRem(10.4),
-// fontSizeXS: pxToRem(12),
-// fontSizeSM: pxToRem(14),
-// fontSizeMD: pxToRem(16),
-// fontSizeLG: pxToRem(18),
-// fontSizeXL: pxToRem(20),
-// fontSize2XL: pxToRem(24),
-// fontSize3XL: pxToRem(30),
-// };
const baseProperties = {
- // fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
fontFamily: 'Poppins, sans-serif',
fontWeightLighter: 100,
fontWeightLight: 300,
fontWeightRegular: 400,
fontWeightMedium: 600,
fontWeightBold: 700,
- // Define font sizes as functions to include responsive behavior
- fontSizeXXS: () => `clamp(${pxToRem(8)}, 1vw, ${pxToRem(10)})`,
+
+ fontSize3XS: () => `clamp(${pxToRem(6)}, 1vw, ${pxToRem(8)})`,
+ fontSize2XS: () => `clamp(${pxToRem(8)}, 1vw, ${pxToRem(10)})`,
fontSizeXS: () => `clamp(${pxToRem(10)}, 1.25vw, ${pxToRem(12)})`,
fontSizeSM: () => `clamp(${pxToRem(12)}, 1.5vw, ${pxToRem(14)})`,
fontSizeMD: () => `clamp(${pxToRem(14)}, 1.75vw, ${pxToRem(16)})`,
@@ -38,17 +22,15 @@ const baseProperties = {
fontSizeXL: () => `clamp(${pxToRem(18)}, 2.25vw, ${pxToRem(20)})`,
fontSize2XL: () => `clamp(${pxToRem(20)}, 2.5vw, ${pxToRem(24)})`,
fontSize3XL: () => `clamp(${pxToRem(24)}, 2.75vw, ${pxToRem(30)})`,
+ fontSize4XL: () => `clamp(${pxToRem(30)}, 3vw, ${pxToRem(36)})`,
+ fontSize5XL: () => `clamp(${pxToRem(36)}, 3.25vw, ${pxToRem(42)})`,
+ fontSize6XL: () => `clamp(${pxToRem(42)}, 3.5vw, ${pxToRem(48)})`,
};
-// const baseHeadingProperties = {
-// fontFamily: baseProperties.fontFamily,
-// color: dark.main,
-// fontWeight: baseProperties.fontWeightBold,
-// };
+
const baseHeadingProperties = {
fontFamily: baseProperties.fontFamily,
color: dark.main,
fontWeight: baseProperties.fontWeightBold,
- // Include responsive font sizes in base properties
fontSize: baseProperties.fontSizeXL(), // Call the function for default size
'@media (max-width:600px)': {
fontSize: baseProperties.fontSizeMD(), // Adjust size for smaller screens
@@ -72,53 +54,76 @@ const typography = {
h1: {
...baseHeadingProperties,
- fontSize: baseProperties.fontSize3XL(),
+ fontSize: baseProperties.fontSize6XL(),
'@media (max-width:900px)': {
- fontSize: baseProperties.fontSize2XL(),
+ fontSize: baseProperties.fontSize5XL(),
},
},
h2: {
- fontSize: baseProperties.fontSize2XL(),
...baseHeadingProperties,
+ fontSize: baseProperties.fontSize5XL(),
+ '@media (max-width:900px)': {
+ fontSize: baseProperties.fontSize4XL(),
+ },
},
h3: {
- fontSize: baseProperties.fontSizeXL(),
...baseHeadingProperties,
+ fontSize: baseProperties.fontSize4XL(),
'@media (max-width:600px)': {
- fontSize: baseProperties.fontSizeLG(),
+ fontSize: baseProperties.fontSize3XL(),
},
},
- // h2: {
- // fontSize: pxToRem(36),
- // lineHeight: 1.3,
- // ...baseHeadingProperties,
- // },
-
- // h3: {
- // fontSize: pxToRem(30),
- // lineHeight: 1.375,
- // ...baseHeadingProperties,
- // },
-
h4: {
- fontSize: pxToRem(24),
- lineHeight: 1.375,
...baseHeadingProperties,
+ fontSize: baseProperties.fontSize3XL(),
+ '@media (max-width:600px)': {
+ fontSize: baseProperties.fontSize2XL(),
+ },
},
h5: {
- fontSize: pxToRem(20),
- lineHeight: 1.375,
...baseHeadingProperties,
+ fontSize: baseProperties.fontSize2XL(),
+ '@media (max-width:600px)': {
+ fontSize: baseProperties.fontSizeXL(),
+ },
},
h6: {
- fontSize: pxToRem(16),
- lineHeight: 1.625,
...baseHeadingProperties,
+ fontSize: baseProperties.fontSizeXL(),
+ '@media (max-width:600px)': {
+ fontSize: baseProperties.fontSizeLG(),
+ },
+ },
+
+ p1: {
+ fontFamily: baseProperties.fontFamily,
+ fontWeight: baseProperties.fontWeightLight,
+ fontSize: baseProperties.fontSizeSM(),
+ lineHeight: 1.5,
+ '@media (max-width:600px)': {
+ fontSize: baseProperties.fontSizeXS(),
+ },
+ '@media (max-width:900px)': {
+ fontSize: baseProperties.fontSizeSM(),
+ },
+ },
+
+ p2: {
+ fontFamily: baseProperties.fontFamily,
+ fontWeight: baseProperties.fontWeightLight,
+ fontSize: baseProperties.fontSizeSM(),
+ lineHeight: 1.5,
+ '@media (max-width:600px)': {
+ fontSize: baseProperties.fontSizeXS(),
+ },
+ '@media (max-width:900px)': {
+ fontSize: baseProperties.fontSizeSM(),
+ },
},
subtitle1: {
@@ -210,10 +215,146 @@ const typography = {
},
lineHeight: {
- sm: 1.25,
- md: 1.5,
+ xs: 1.25,
+ sm: 1.5,
+ md: 1.75,
lg: 2,
+ xl: 2,
},
};
export default typography;
+
+// /**
+// * Typography used in theme
+// * @param {JsonObject} theme theme customization object
+// */
+
+// export default function themeTypography(theme) {
+// return {
+// fontFamily: theme?.customization?.fontFamily,
+// h6: {
+// fontWeight: 500,
+// color: theme.heading,
+// fontSize: '0.75rem',
+// },
+// h5: {
+// fontSize: '0.875rem',
+// color: theme.heading,
+// fontWeight: 500,
+// },
+// h4: {
+// fontSize: '1rem',
+// color: theme.heading,
+// fontWeight: 600,
+// },
+// h3: {
+// fontSize: '1.25rem',
+// color: theme.heading,
+// fontWeight: 600,
+// },
+// h2: {
+// fontSize: '1.5rem',
+// color: theme.heading,
+// fontWeight: 700,
+// },
+// h1: {
+// fontSize: '2.125rem',
+// color: theme.heading,
+// fontWeight: 700,
+// },
+// subtitle1: {
+// fontSize: '0.875rem',
+// fontWeight: 500,
+// color: theme.textDark,
+// },
+// subtitle2: {
+// fontSize: '0.75rem',
+// fontWeight: 400,
+// color: theme.darkTextSecondary,
+// },
+// caption: {
+// fontSize: '0.75rem',
+// color: theme.darkTextSecondary,
+// fontWeight: 400,
+// },
+// body1: {
+// fontSize: '0.875rem',
+// fontWeight: 400,
+// lineHeight: '1.334em',
+// },
+// body2: {
+// letterSpacing: '0em',
+// fontWeight: 400,
+// lineHeight: '1.5em',
+// color: theme.darkTextPrimary,
+// },
+// button: {
+// textTransform: 'capitalize',
+// },
+// customInput: {
+// marginTop: 1,
+// marginBottom: 1,
+// '& > label': {
+// top: 23,
+// left: 0,
+// color: theme.grey500,
+// '&[data-shrink="false"]': {
+// top: 5,
+// },
+// },
+// '& > div > input': {
+// padding: '30.5px 14px 11.5px !important',
+// },
+// '& legend': {
+// display: 'none',
+// },
+// '& fieldset': {
+// top: 0,
+// },
+// },
+// mainContent: {
+// backgroundColor: theme.background,
+// width: '100%',
+// minHeight: 'calc(100vh - 88px)',
+// flexGrow: 1,
+// padding: '20px',
+// marginTop: '88px',
+// marginRight: '20px',
+// borderRadius: `${theme?.customization?.borderRadius}px`,
+// },
+// menuCaption: {
+// fontSize: '0.875rem',
+// fontWeight: 500,
+// color: theme.heading,
+// padding: '6px',
+// textTransform: 'capitalize',
+// marginTop: '10px',
+// },
+// subMenuCaption: {
+// fontSize: '0.6875rem',
+// fontWeight: 500,
+// color: theme.darkTextSecondary,
+// textTransform: 'capitalize',
+// },
+// commonAvatar: {
+// cursor: 'pointer',
+// borderRadius: '8px',
+// },
+// smallAvatar: {
+// width: '22px',
+// height: '22px',
+// fontSize: '1rem',
+// },
+// mediumAvatar: {
+// width: '34px',
+// height: '34px',
+// fontSize: '1.2rem',
+// },
+// largeAvatar: {
+// width: '44px',
+// height: '44px',
+// fontSize: '1.5rem',
+// },
+// };
+// }
diff --git a/src/assets/themes/components/index.jsx b/src/assets/themes/components/index.jsx
index d4f730c..faf74cc 100644
--- a/src/assets/themes/components/index.jsx
+++ b/src/assets/themes/components/index.jsx
@@ -20,83 +20,10 @@ const cssbaseline = {
`,
};
-// const container = {
-// styleOverrides: {
-// root: {
-// margin: 0,
-// padding: 0,
-// },
-// },
-// };
-
-const listItemButton = {
- styleOverrides: {
- root: {
- color: '#4cceac',
- paddingTop: '10px',
- paddingBottom: '10px',
- '&.Mui-selected': {
- color: '#3da58a',
- backgroundColor: '#4cceac',
- '&:hover': {
- backgroundColor: '#3da58a',
- },
- '& .MuiListItemIcon-root': {
- color: '#3da58a',
- },
- },
- '&:hover': {
- backgroundColor: '#3da58a',
- color: '#3da58a',
- '& .MuiListItemIcon-root': {
- color: '#3da58a',
- },
- },
- },
- },
-};
-
-const outlinedInput = {
- styleOverrides: {
- root: {
- background: '#ffffff',
- borderRadius: '4px',
- '& .MuiOutlinedInput-notchedOutline': {
- borderColor: '#333',
- },
- '&:hover $notchedOutline': {
- borderColor: '#4cceac',
- },
- '&.MuiInputBase-multiline': {
- padding: '1px',
- },
- },
-
- input: {
- fontWeight: 500,
- background: '#ffffff',
- padding: '15.5px 14px',
- borderRadius: '4px',
- '&.MuiInputBase-inputSizeSmall': {
- padding: '10px 14px',
- '&.MuiInputBase-inputAdornedStart': {
- paddingLeft: 0,
- },
- },
- },
- inputAdornedStart: {
- paddingLeft: '4px',
- },
- notchedOutline: {
- borderRadius: '4px',
- },
- },
-};
-
export const components = {
MuiCssBaseline: cssbaseline,
MuiButton: button,
- MuiListItemButton: listItemButton,
+ // MuiListItemButton: listItemButton,
MuiContainer: container,
MuiDivider: divider,
@@ -104,7 +31,7 @@ export const components = {
MuiTableCell: tableCell,
MuiTableHead: tableHead,
- MuiOutlinedInput: outlinedInput,
+ // MuiOutlinedInput: outlinedInput,
MuiInput: input,
MuiInputLabel: inputLabel,
@@ -114,64 +41,3 @@ export const components = {
};
export default components;
-// MuiListItemButton: {
-// styleOverrides: {
-// root: {
-// color: colorsA.greenAccent[500],
-// paddingTop: '10px',
-// paddingBottom: '10px',
-// '&.Mui-selected': {
-// color: colorsA.greenAccent[200],
-// backgroundColor: colorsA.greenAccent[300],
-// '&:hover': {
-// backgroundColor: colorsA.greenAccent[700],
-// },
-// '& .MuiListItemIcon-root': {
-// color: colorsA.greenAccent[400],
-// },
-// },
-// '&:hover': {
-// backgroundColor: colorsA.greenAccent[400],
-// color: colorsA.greenAccent[200],
-// '& .MuiListItemIcon-root': {
-// color: colors.greenAccent[400],
-// },
-// },
-// },
-// },
-// },
-// MuiOutlinedInput: {
-// styleOverrides: {
-// root: {
-// background: backgroundA.default,
-// borderRadius: `${themeColors?.borderRadius}px`,
-// '& .MuiOutlinedInput-notchedOutline': {
-// borderColor: themeColors.colors?.grey400,
-// },
-// '&:hover $notchedOutline': {
-// borderColor: themeColors?.primaryLight,
-// },
-// '&.MuiInputBase-multiline': {
-// padding: 1,
-// },
-// },
-// input: {
-// fontWeight: 500,
-// background: backgroundA.default,
-// padding: '15.5px 14px',
-// borderRadius: `${themeColors?.borderRadius}px`,
-// '&.MuiInputBase-inputSizeSmall': {
-// padding: '10px 14px',
-// '&.MuiInputBase-inputAdornedStart': {
-// paddingLeft: 0,
-// },
-// },
-// },
-// inputAdornedStart: {
-// paddingLeft: 4,
-// },
-// notchedOutline: {
-// borderRadius: `${themeColors?.customization?.borderRadius}px`,
-// },
-// },
-// },
diff --git a/src/assets/themes/styleOverride/compStyleOverride.jsx b/src/assets/themes/styleOverride/compStyleOverride.jsx
deleted file mode 100644
index e5b65ab..0000000
--- a/src/assets/themes/styleOverride/compStyleOverride.jsx
+++ /dev/null
@@ -1,187 +0,0 @@
-export default function componentStyleOverrides(theme) {
- const bgColor = theme.colors?.grey50;
- return {
- MuiButton: {
- styleOverrides: {
- root: {
- fontWeight: 500,
- borderRadius: '4px',
- },
- },
- },
- MuiPaper: {
- defaultProps: {
- elevation: 0,
- },
- styleOverrides: {
- root: {
- backgroundImage: 'none',
- },
- rounded: {
- borderRadius: `${theme?.customization?.borderRadius}px`,
- },
- },
- },
- MuiCardHeader: {
- styleOverrides: {
- root: {
- color: theme.colors?.textDark,
- padding: '24px',
- },
- title: {
- fontSize: '1.125rem',
- },
- },
- },
- MuiCardContent: {
- styleOverrides: {
- root: {
- padding: '24px',
- },
- },
- },
- MuiCardActions: {
- styleOverrides: {
- root: {
- padding: '24px',
- },
- },
- },
- MuiListItemButton: {
- styleOverrides: {
- root: {
- color: theme.darkTextPrimary,
- paddingTop: '10px',
- paddingBottom: '10px',
- '&.Mui-selected': {
- color: theme.menuSelected,
- backgroundColor: theme.menuSelectedBack,
- '&:hover': {
- backgroundColor: theme.menuSelectedBack,
- },
- '& .MuiListItemIcon-root': {
- color: theme.menuSelected,
- },
- },
- '&:hover': {
- backgroundColor: theme.menuSelectedBack,
- color: theme.menuSelected,
- '& .MuiListItemIcon-root': {
- color: theme.menuSelected,
- },
- },
- },
- },
- },
- MuiListItemIcon: {
- styleOverrides: {
- root: {
- color: theme.darkTextPrimary,
- minWidth: '36px',
- },
- },
- },
- MuiListItemText: {
- styleOverrides: {
- primary: {
- color: theme.textDark,
- },
- },
- },
- MuiInputBase: {
- styleOverrides: {
- input: {
- color: theme.textDark,
- '&::placeholder': {
- color: theme.darkTextSecondary,
- fontSize: '0.875rem',
- },
- },
- },
- },
- MuiOutlinedInput: {
- styleOverrides: {
- root: {
- background: bgColor,
- borderRadius: `${theme?.customization?.borderRadius}px`,
- '& .MuiOutlinedInput-notchedOutline': {
- borderColor: theme.colors?.grey400,
- },
- '&:hover $notchedOutline': {
- borderColor: theme.colors?.primaryLight,
- },
- '&.MuiInputBase-multiline': {
- padding: 1,
- },
- },
- input: {
- fontWeight: 500,
- background: bgColor,
- padding: '15.5px 14px',
- borderRadius: `${theme?.customization?.borderRadius}px`,
- '&.MuiInputBase-inputSizeSmall': {
- padding: '10px 14px',
- '&.MuiInputBase-inputAdornedStart': {
- paddingLeft: 0,
- },
- },
- },
- inputAdornedStart: {
- paddingLeft: 4,
- },
- notchedOutline: {
- borderRadius: `${theme?.customization?.borderRadius}px`,
- },
- },
- },
- MuiSlider: {
- styleOverrides: {
- root: {
- '&.Mui-disabled': {
- color: theme.colors?.grey300,
- },
- },
- mark: {
- backgroundColor: theme.paper,
- width: '4px',
- },
- valueLabel: {
- color: theme?.colors?.primaryLight,
- },
- },
- },
- MuiDivider: {
- styleOverrides: {
- root: {
- borderColor: theme.divider,
- opacity: 1,
- },
- },
- },
- MuiAvatar: {
- styleOverrides: {
- root: {
- color: theme.colors?.primaryDark,
- background: theme.colors?.primary200,
- },
- },
- },
- MuiChip: {
- styleOverrides: {
- root: {
- '&.MuiChip-deletable .MuiChip-deleteIcon': {
- color: 'inherit',
- },
- },
- },
- },
- MuiTooltip: {
- styleOverrides: {
- tooltip: {
- color: theme.paper,
- background: theme.colors?.grey700,
- },
- },
- },
- };
-}
diff --git a/src/assets/themes/themeSettings.jsx b/src/assets/themes/themeSettings.jsx
index 7d2f144..678147c 100644
--- a/src/assets/themes/themeSettings.jsx
+++ b/src/assets/themes/themeSettings.jsx
@@ -1,12 +1,5 @@
-import { tokens } from './tokens';
-// import themeTypography from './typography/typography';
-// import themeColors from '../scss/_theme-vars.modules.scss';
-import DeckOfCardsIcon from '../../components/reusable/icons/DeckOfCardsIcon';
-import MoneyIcon from '../../components/reusable/icons/MoneyIcon';
-import ChartsIcon from '../../components/reusable/icons/ChartsIcon';
import colors from './base/colors';
import components from './components/index';
-import { backgroundA, backgroundC } from './base/customColorPalettes';
import borders from './base/borders';
import boxShadows from './base/boxShadows';
import typography from './base/typography';
@@ -15,27 +8,10 @@ import hexToRgb from './functions/hexToRgb';
import linearGradient from './functions/linearGradient';
import pxToRem from './functions/pxToRem';
import rgba from './functions/rgba';
+import breakpoints from './base/breakpoints';
+import Transitions from './Transitions';
export const themeSettings = (mode) => {
- const colorsA = tokens(mode);
- const specialBreakpoints = {
- isSmUp: (breakpoints) => breakpoints.up('sm'),
- isMdUp: (breakpoints) => breakpoints.up('md'),
- isLgUp: (breakpoints) => breakpoints.up('lg'),
- isXlUp: (breakpoints) => breakpoints.up('xl'),
- isSmDown: (breakpoints) => breakpoints.down('sm'),
- isMdDown: (breakpoints) => breakpoints.down('md'),
- isLgDown: (breakpoints) => breakpoints.down('lg'),
- isXlDown: (breakpoints) => breakpoints.down('xl'),
-
- isXSmall: (breakpoints) => breakpoints.down('xs'),
- isSmall: (breakpoints) => breakpoints.down('sm'),
- isSmallMedium: (breakpoints) => breakpoints.up('sm'),
- isMedium: (breakpoints) => breakpoints.down('md'),
- isMediumLarge: (breakpoints) => breakpoints.up('md'),
- isLarge: (breakpoints) => breakpoints.up('lg'),
- isXLarge: (breakpoints) => breakpoints.up('xl'),
- };
return {
components: components,
functions: {
@@ -47,13 +23,13 @@ export const themeSettings = (mode) => {
},
palette: {
...colors,
- ...colorsA,
mode: mode,
},
- specialBreakpoints: specialBreakpoints,
- // components,
- borders,
- boxShadows,
+ breakpoints: breakpoints.values,
+ Transitions: Transitions,
+ borders: borders,
+ boxShadows: boxShadows,
+ typography: typography,
spacing: (factor) => `${0.25 * factor}rem`,
shape: {
borderRadius: 4,
@@ -63,21 +39,19 @@ export const themeSettings = (mode) => {
appBar: 1200,
drawer: 1100,
},
- shadows: [
- 'none',
- '0px 2px 1px -1px rgba(0,0,0,0.1),0px 1px 1px 0px rgba(0,0,0,0.06),0px 1px 3px 0px rgba(0,0,0,0.04)', // example for theme.shadows[1]
- '0px 3px 1px -2px rgba(0,0,0,0.1),0px 2px 2px 0px rgba(0,0,0,0.06),0px 1px 5px 0px rgba(0,0,0,0.04)', // example for theme.shadows[2]
- '0px 3px 3px -2px rgba(0,0,0,0.1),0px 3px 4px 0px rgba(0,0,0,0.06),0px 1px 8px 0px rgba(0,0,0,0.04)', // example for theme.shadows[3]
- '0px 2px 4px -1px rgba(0,0,0,0.1),0px 4px 5px 0px rgba(0,0,0,0.06),0px 1px 10px 0px rgba(0,0,0,0.04)', // example for theme.shadows[4]
- '0px 3px 5px -1px rgba(0,0,0,0.1),0px 5px 8px 0px rgba(0,0,0,0.06),0px 1px 14px 0px rgba(0,0,0,0.04)', // example for theme.shadows[5]
- '0px 3px 5px -1px rgba(0,0,0,0.1),0px 6px 10px 0px rgba(0,0,0,0.06),0px 1px 18px 0px rgba(0,0,0,0.04)', // example for theme.shadows[6]
- '0px 4px 5px -2px rgba(0,0,0,0.1),0px 7px 10px 1px rgba(0,0,0,0.06),0px 2px 16px 1px rgba(0,0,0,0.04)', // example for theme.shadows[7]
- '0px 5px 5px -3px rgba(0,0,0,0.1),0px 8px 10px 1px rgba(0,0,0,0.06),0px 3px 14px 2px rgba(0,0,0,0.04)', // example for theme.shadows[8]
- '0px 5px 6px -3px rgba(0,0,0,0.1),0px 9px 12px 1px rgba(0,0,0,0.06),0px 3px 16px 2px rgba(0,0,0,0.04)', // example for theme.shadows[9]
- '0px 5px 15px rgba(0,0,0,0.1)', // example for theme.shadows[10]
- ],
- typography,
- // LAYOUTS
+ // shadows: [
+ // 'none',
+ // '0px 2px 1px -1px rgba(0,0,0,0.1),0px 1px 1px 0px rgba(0,0,0,0.06),0px 1px 3px 0px rgba(0,0,0,0.04)', // example for theme.shadows[1]
+ // '0px 3px 1px -2px rgba(0,0,0,0.1),0px 2px 2px 0px rgba(0,0,0,0.06),0px 1px 5px 0px rgba(0,0,0,0.04)', // example for theme.shadows[2]
+ // '0px 3px 3px -2px rgba(0,0,0,0.1),0px 3px 4px 0px rgba(0,0,0,0.06),0px 1px 8px 0px rgba(0,0,0,0.04)', // example for theme.shadows[3]
+ // '0px 2px 4px -1px rgba(0,0,0,0.1),0px 4px 5px 0px rgba(0,0,0,0.06),0px 1px 10px 0px rgba(0,0,0,0.04)', // example for theme.shadows[4]
+ // '0px 3px 5px -1px rgba(0,0,0,0.1),0px 5px 8px 0px rgba(0,0,0,0.06),0px 1px 14px 0px rgba(0,0,0,0.04)', // example for theme.shadows[5]
+ // '0px 3px 5px -1px rgba(0,0,0,0.1),0px 6px 10px 0px rgba(0,0,0,0.06),0px 1px 18px 0px rgba(0,0,0,0.04)', // example for theme.shadows[6]
+ // '0px 4px 5px -2px rgba(0,0,0,0.1),0px 7px 10px 1px rgba(0,0,0,0.06),0px 2px 16px 1px rgba(0,0,0,0.04)', // example for theme.shadows[7]
+ // '0px 5px 5px -3px rgba(0,0,0,0.1),0px 8px 10px 1px rgba(0,0,0,0.06),0px 3px 14px 2px rgba(0,0,0,0.04)', // example for theme.shadows[8]
+ // '0px 5px 6px -3px rgba(0,0,0,0.1),0px 9px 12px 1px rgba(0,0,0,0.06),0px 3px 16px 2px rgba(0,0,0,0.04)', // example for theme.shadows[9]
+ // '0px 5px 15px rgba(0,0,0,0.1)', // example for theme.shadows[10]
+ // ],
skeletonLayouts: {
tertiaryContent: {
xs: 12,
@@ -112,206 +86,24 @@ export const themeSettings = (mode) => {
},
},
};
- // MuiListItemButton: {
- // styleOverrides: {
- // root: {
- // color: colorsA.greenAccent[500],
- // paddingTop: '10px',
- // paddingBottom: '10px',
- // '&.Mui-selected': {
- // color: colorsA.greenAccent[200],
- // backgroundColor: colorsA.greenAccent[300],
- // '&:hover': {
- // backgroundColor: colorsA.greenAccent[700],
- // },
- // '& .MuiListItemIcon-root': {
- // color: colorsA.greenAccent[400],
- // },
- // },
- // '&:hover': {
- // backgroundColor: colorsA.greenAccent[400],
- // color: colorsA.greenAccent[200],
- // '& .MuiListItemIcon-root': {
- // color: colorsA.greenAccent[400],
- // },
- // },
- // },
- // },
- // },
- // MuiOutlinedInput: {
- // styleOverrides: {
- // root: {
- // background: backgroundA.default,
- // borderRadius: `${themeColors?.borderRadius}px`,
- // '& .MuiOutlinedInput-notchedOutline': {
- // borderColor: themeColors?.colors?.grey400,
- // },
- // '&:hover $notchedOutline': {
- // borderColor: themeColors?.primaryLight,
- // },
- // '&.MuiInputBase-multiline': {
- // padding: 1,
- // },
- // },
- // input: {
- // fontWeight: 500,
- // background: backgroundA.default,
- // padding: '15.5px 14px',
- // borderRadius: `${themeColors?.borderRadius}px`,
- // '&.MuiInputBase-inputSizeSmall': {
- // padding: '10px 14px',
- // '&.MuiInputBase-inputAdornedStart': {
- // paddingLeft: 0,
- // },
- // },
- // },
- // inputAdornedStart: {
- // paddingLeft: 4,
- // },
- // notchedOutline: {
- // borderRadius: `${themeColors?.customization?.borderRadius}px`,
- // },
- // },
- // },
};
-// const createColorGradient = (color1, color2, steps) => {
-// const gradient = [];
-// const stepFactor = 1 / (steps - 1);
-// for (let i = 0; i < steps; i++) {
-// gradient.push(shadeBlendConvert(i * stepFactor, color1, color2));
-// }
-// return gradient;
-// };
-
-// TODO: TEST BOTH HEAX CONVERSION FUNCTIONS
-// Utility function to convert Hex to RGBA
-// const hexToRgba = (hex, alpha = 1) => {
-// let shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
-// hex = hex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b);
-// let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
-// return result
-// ? `rgba(${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(
-// result[3],
-// 16
-// )}, ${alpha})`
-// : null;
-// };
-// function convertHexToRGBA(hex, alpha) {
-// const r = parseInt(hex.slice(1, 3), 16);
-// const g = parseInt(hex.slice(3, 5), 16);
-// const b = parseInt(hex.slice(5, 7), 16);
-
-// return `rgba(${r}, ${g}, ${b}, ${alpha})`;
-// }
-// Utility functions
-// const pxToRem = (number, baseNumber = 16) => {
-// return `${number / baseNumber}rem`;
-// };
+// specialBreakpoints: specialBreakpoints,
+// const colorsA = tokens(mode);
+// const specialBreakpoints = {
+// isSmUp: (breakpoints) => breakpoints.up('sm'),
+// isMdUp: (breakpoints) => breakpoints.up('md'),
+// isLgUp: (breakpoints) => breakpoints.up('lg'),
+// isXlUp: (breakpoints) => breakpoints.up('xl'),
+// isSmDown: (breakpoints) => breakpoints.down('sm'),
+// isMdDown: (breakpoints) => breakpoints.down('md'),
+// isLgDown: (breakpoints) => breakpoints.down('lg'),
+// isXlDown: (breakpoints) => breakpoints.down('xl'),
-// const hexToRgba = (hex, alpha = 1) => {
-// let shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
-// hex = hex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b);
-// let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
-// return result
-// ? `rgba(${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)}, ${alpha})`
-// : null;
+// isXSmall: (breakpoints) => breakpoints.down('xs'),
+// isSmall: (breakpoints) => breakpoints.down('sm'),
+// isSmallMedium: (breakpoints) => breakpoints.up('sm'),
+// isMedium: (breakpoints) => breakpoints.down('md'),
+// isMediumLarge: (breakpoints) => breakpoints.up('md'),
+// isLarge: (breakpoints) => breakpoints.up('lg'),
+// isXLarge: (breakpoints) => breakpoints.up('xl'),
// };
-
-// const rgba = (color, opacity) => {
-// return hexToRgba(color, opacity);
-// };
-
-// const linearGradient = (color, colorState, angle = 195) => {
-// return `linear-gradient(${angle}deg, ${color}, ${colorState})`;
-// };
-// chart: {
-// axis: {
-// domain: {
-// line: {
-// stroke: colors.greenAccent[800],
-// strokeWidth: 1,
-// },
-// },
-// ticks: {
-// line: {
-// stroke: colors.greenAccent[700],
-// strokeWidth: 1,
-// },
-// text: {
-// fill: colors.greenAccent[900],
-// fontSize: 12,
-// },
-// },
-// },
-// grid: {
-// line: {
-// stroke: colors.greenAccent[200],
-// strokeWidth: 1,
-// },
-// },
-// legends: {
-// text: {
-// fill: colors.greenAccent[800],
-// fontSize: 12,
-// },
-// },
-// tooltip: {
-// container: {
-// background: colors.greenAccent[100],
-// color: colors.greenAccent[800],
-// fontSize: 12,
-// borderRadius: 4,
-// boxShadow: '0 2px 4px rgba(0,0,0,0.25)',
-// },
-// },
-// points: {
-// borderColor: colors.greenAccent[800],
-// },
-// },
-// getHeaderStyle: {
-// fontWeight: 'bold',
-// color: 'text.primary',
-// marginBottom: 2, // theme.spacing(2)
-// '@media (maxWidth:599.95px)': {
-// fontSize: '1.25rem',
-// },
-// '@media (minWidth:600px) and (maxWidth:899.95px)': {
-// fontSize: '1.5rem',
-// },
-// '@media (minWidth:900px)': {
-// fontSize: '1.75rem',
-// },
-// },
-
-// getStyledGridStyle: {
-// '@media (maxWidth:599.95px)': {
-// margin: 0.5, // theme.spacing(0.5)
-// },
-// '@media (minWidth:600px) and (maxWidth:1199.95px)': {
-// margin: 1, // theme.spacing(1)
-// },
-// '@media (minWidth:1200px)': {
-// margin: 2, // theme.spacing(2)
-// },
-// '@media (minWidth:1800px)': {
-// margin: 2, // theme.spacing(2)
-// },
-// },
-
-// getStyledGridItemStyle: {
-// display: 'flex',
-// flexDirection: 'column',
-// alignItems: 'stretch',
-// '@media (maxWidth:599.95px)': {
-// padding: 1, // theme.spacing(1)
-// },
-// '@media (minWidth:600px)': {
-// padding: 0.25, // theme.spacing(0.25)
-// },
-// '@media (minWidth:1200px)': {
-// padding: 1, // theme.spacing(1)
-// },
-// '@media (minWidth:1800px)': {
-// padding: 2, // theme.spacing(2)
-// },
-// },
diff --git a/src/assets/themes/tokens.jsx b/src/assets/themes/tokens.jsx
deleted file mode 100644
index e195906..0000000
--- a/src/assets/themes/tokens.jsx
+++ /dev/null
@@ -1,132 +0,0 @@
-export const tokens = (mode) => ({
- ...(mode === 'dark'
- ? {
- grey: {
- 100: '#e0e0e0',
- 200: '#c2c2c2',
- 300: '#a3a3a3',
- 400: '#858585',
- 500: '#666666',
- 600: '#525252',
- 700: '#3d3d3d',
- 800: '#292929',
- 900: '#141414',
- },
- primary: {
- 100: '#d0d1d5',
- 200: '#a1a4ab',
- 300: '#727681',
- 400: '#1F2A40',
- 500: '#141b2d',
- 600: '#101624',
- 700: '#0c101b',
- 800: '#080b12',
- 900: '#040509',
- },
- blueGreenAccent: {
- 100: '#dbf5f2', // Lightest shade, more towards blue
- 200: '#b7ebe6',
- 300: '#93e1da',
- 400: '#6fd7ce',
- 500: '#4bcdc2', // Mid-value, a balanced blue-green
- 600: '#39a59b',
- 700: '#2b7d76',
- 800: '#1d5551',
- 900: '#0f2d28', // Darkest shade, deeper blue-green
- },
- greenAccent: {
- 100: '#dbf5ee',
- 200: '#b7ebde',
- 300: '#94e2cd',
- 400: '#70d8bd',
- 500: '#4cceac',
- 600: '#3da58a',
- 700: '#2e7c67',
- 800: '#1e5245',
- 900: '#0f2922',
- },
- redAccent: {
- 100: '#f8dcdb',
- 200: '#f1b9b7',
- 300: '#e99592',
- 400: '#e2726e',
- 500: '#db4f4a',
- 600: '#af3f3b',
- 700: '#832f2c',
- 800: '#58201e',
- 900: '#2c100f',
- },
- blueAccent: {
- 100: '#e1e2fe',
- 200: '#c3c6fd',
- 300: '#a4a9fc',
- 400: '#868dfb',
- 500: '#6870fa',
- 600: '#535ac8',
- 700: '#3e4396',
- 800: '#2a2d64',
- 900: '#151632',
- },
- }
- : {
- grey: {
- 100: '#141414',
- 200: '#292929',
- 300: '#3d3d3d',
- 400: '#525252',
- 500: '#666666',
- 600: '#858585',
- 700: '#a3a3a3',
- 800: '#c2c2c2',
- 900: '#e0e0e0',
- },
- primary: {
- 100: '#040509',
- 200: '#080b12',
- 300: '#0c101b',
- 400: '#f2f0f0', // manually changed
- 500: '#141b2d',
- 600: '#1F2A40',
- 700: '#727681',
- 800: '#a1a4ab',
- 900: '#d0d1d5',
- },
- // secondary: {
- // 100: '#ff7961',
- // 200: '#f44336',
- // },
- greenAccent: {
- 100: '#0f2922',
- 200: '#1e5245',
- 300: '#2e7c67',
- 400: '#3da58a',
- 500: '#4cceac',
- 600: '#70d8bd',
- 700: '#94e2cd',
- 800: '#b7ebde',
- 900: '#dbf5ee',
- },
- redAccent: {
- 100: '#2c100f',
- 200: '#58201e',
- 300: '#832f2c',
- 400: '#af3f3b',
- 500: '#db4f4a',
- 600: '#e2726e',
- 700: '#e99592',
- 800: '#f1b9b7',
- 900: '#f8dcdb',
- },
- blueAccent: {
- 100: '#151632',
- 200: '#2a2d64',
- 300: '#3e4396',
- 400: '#535ac8',
- 500: '#6870fa',
- 600: '#868dfb',
- 700: '#a4a9fc',
- 800: '#c3c6fd',
- 900: '#e1e2fe',
- },
- }),
-});
diff --git a/src/assets/themes/typography/typography.js b/src/assets/themes/typography/typography.js
deleted file mode 100644
index f620e1b..0000000
--- a/src/assets/themes/typography/typography.js
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Typography used in theme
- * @param {JsonObject} theme theme customization object
- */
-
-export default function themeTypography(theme) {
- return {
- fontFamily: theme?.customization?.fontFamily,
- h6: {
- fontWeight: 500,
- color: theme.heading,
- fontSize: '0.75rem',
- },
- h5: {
- fontSize: '0.875rem',
- color: theme.heading,
- fontWeight: 500,
- },
- h4: {
- fontSize: '1rem',
- color: theme.heading,
- fontWeight: 600,
- },
- h3: {
- fontSize: '1.25rem',
- color: theme.heading,
- fontWeight: 600,
- },
- h2: {
- fontSize: '1.5rem',
- color: theme.heading,
- fontWeight: 700,
- },
- h1: {
- fontSize: '2.125rem',
- color: theme.heading,
- fontWeight: 700,
- },
- subtitle1: {
- fontSize: '0.875rem',
- fontWeight: 500,
- color: theme.textDark,
- },
- subtitle2: {
- fontSize: '0.75rem',
- fontWeight: 400,
- color: theme.darkTextSecondary,
- },
- caption: {
- fontSize: '0.75rem',
- color: theme.darkTextSecondary,
- fontWeight: 400,
- },
- body1: {
- fontSize: '0.875rem',
- fontWeight: 400,
- lineHeight: '1.334em',
- },
- body2: {
- letterSpacing: '0em',
- fontWeight: 400,
- lineHeight: '1.5em',
- color: theme.darkTextPrimary,
- },
- button: {
- textTransform: 'capitalize',
- },
- customInput: {
- marginTop: 1,
- marginBottom: 1,
- '& > label': {
- top: 23,
- left: 0,
- color: theme.grey500,
- '&[data-shrink="false"]': {
- top: 5,
- },
- },
- '& > div > input': {
- padding: '30.5px 14px 11.5px !important',
- },
- '& legend': {
- display: 'none',
- },
- '& fieldset': {
- top: 0,
- },
- },
- mainContent: {
- backgroundColor: theme.background,
- width: '100%',
- minHeight: 'calc(100vh - 88px)',
- flexGrow: 1,
- padding: '20px',
- marginTop: '88px',
- marginRight: '20px',
- borderRadius: `${theme?.customization?.borderRadius}px`,
- },
- menuCaption: {
- fontSize: '0.875rem',
- fontWeight: 500,
- color: theme.heading,
- padding: '6px',
- textTransform: 'capitalize',
- marginTop: '10px',
- },
- subMenuCaption: {
- fontSize: '0.6875rem',
- fontWeight: 500,
- color: theme.darkTextSecondary,
- textTransform: 'capitalize',
- },
- commonAvatar: {
- cursor: 'pointer',
- borderRadius: '8px',
- },
- smallAvatar: {
- width: '22px',
- height: '22px',
- fontSize: '1rem',
- },
- mediumAvatar: {
- width: '34px',
- height: '34px',
- fontSize: '1.2rem',
- },
- largeAvatar: {
- width: '44px',
- height: '44px',
- fontSize: '1.5rem',
- },
- };
-}
diff --git a/src/components/buttons/actionButtons/GenericActionButtons.jsx b/src/components/buttons/actionButtons/GenericActionButtons.jsx
index aad8ca1..5700053 100644
--- a/src/components/buttons/actionButtons/GenericActionButtons.jsx
+++ b/src/components/buttons/actionButtons/GenericActionButtons.jsx
@@ -1,27 +1,17 @@
import React, { useState, useEffect, useCallback, useMemo } from 'react';
import { Box } from '@mui/material';
import MDTypography from '../../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-import AddButton from '../../../zcleanup/AddButton';
-import RemoveButton from '../../../zcleanup/RemoveButton';
-import { useModalContext } from '../../../context/UTILITIES_CONTEXT/ModalContext/ModalContext';
-import useSelectedContext from '../../../context/hooks/useSelectedContext';
-import { getContextIcon } from '../../../components/reusable/icons/index';
-// import {
-// useCollectionManager,
-// useSelectedCollection,
-// } from '../../../context/MAIN_CONTEXT/CollectionContext';
+import { getContextIcon } from '../../../layout/REUSABLE_COMPONENTS/icons/index';
import { useDeckStore } from '../../../context/MAIN_CONTEXT/DeckContext/DeckContext';
import { useCartStore } from '../../../context/MAIN_CONTEXT/CartContext/CartContext';
-import { DEFAULT_COLLECTION } from '../../../context/constants';
-import { useCardActions } from '../../../context/hooks/useCardActions';
import useCollectionManager from '../../../context/MAIN_CONTEXT/CollectionContext/useCollectionManager';
import useSelectedCollection from '../../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
import ActionButton from './ActionButton';
import { useSnackbar } from 'notistack';
-import GlassyIcon from '../../../components/reusable/icons/GlassyIcon';
+import GlassyIcon from '../../../layout/REUSABLE_COMPONENTS/icons/GlassyIcon';
import MDBox from '../../../layout/REUSABLE_COMPONENTS/MDBOX';
+import useDeckManager from '../../../context/MAIN_CONTEXT/DeckContext/useDeckManager';
-// Utility function for mapping cardSize to buttonSize
const buttonSizeMap = {
xs: 'extraSmall',
sm: 'small',
@@ -41,20 +31,11 @@ const GenericActionButtons = ({
const { enqueueSnackbar } = useSnackbar(); // Add this line to use Notistack
const { addOneToCollection, removeOneFromCollection } =
useCollectionManager();
- const { selectedCollection, allCollections, handleSelectCollection } =
- useSelectedCollection();
- const {
- addOneToDeck,
- removeOneFromDeck,
- selectedDeck,
- allDecks,
- setSelectedDeck,
- } = useDeckStore();
+ const { addOneToDeck, removeOneFromDeck } = useDeckManager();
const { addOneToCart, removeOneFromCart, cartData } = useCartStore();
const [buttonSize, setButtonSize] = useState(
buttonSizeMap[cardSize] || 'medium'
);
- const { closeModal } = useModalContext();
useEffect(() => {
setButtonSize(buttonSizeMap[cardSize] || 'medium');
}, [cardSize]);
@@ -90,10 +71,6 @@ const GenericActionButtons = ({
} else if (action === 'remove' && removeActions[currentContext]) {
removeActions[currentContext](cardData);
}
-
- // Hook into success or failure callbacks as necessary
- // onSuccess();
- // onFailure();
},
[card, context, addActions, removeActions]
);
@@ -114,10 +91,8 @@ const ActionButtons = ({
context,
page,
handleCardAction,
+ variant,
}) => {
- // console.log(
- // `ActionButtons: buttonSize: ${buttonSize}, card: ${card?.name}, context: ${context}`
- // );
const labelValue =
typeof context === 'string' ? context : context?.pageContext;
const stackDirection = buttonSize === 'extraSmall' ? 'column' : 'row';
@@ -159,17 +134,19 @@ const ActionButtons = ({
},
}}
>
-
-
-
+ {variant !== 'data-table' && (
+
+
+
+ )}
{
-// if (typeof context === 'undefined') {
-// context = 'Collection';
-// }
-// const { closeModal, isModalOpen, setModalOpen } = useModalContext();
-// const { selectedCollection, allCollections } = useSelectedContext();
-// const [buttonSize, setButtonSize] = React.useState('medium');
-
-// const labelValue =
-// typeof context === 'string' ? context : context?.pageContext;
-// useEffect(() => {
-// const buttonSizeMap = {
-// xs: 'extraSmall',
-// sm: 'small',
-// md: 'medium',
-// lg: 'large', // Adjust if there's another size you want for 'l'
-// };
-// const size = buttonSizeMap[cardSize] || 'medium'; // Default to 'medium' if size is not defined
-// setButtonSize(size);
-// }, [cardSize]);
-
-// return (
-//
-// {renderFullWidthAddButton(
-// buttonSize,
-// isModalOpen,
-// labelValue,
-// cardSize,
-// context,
-// card,
-// page,
-// onClick,
-// closeModal,
-// onSuccess,
-// onFailure
-// )}
-//
-// );
-// };
-
-// export default GenericActionButtons;
-
-// // const renderSelectionDialog = () => (
-// //
-// // );
diff --git a/src/components/buttons/other/AuthSwitch.jsx b/src/components/buttons/other/AuthSwitch.jsx
deleted file mode 100644
index 6f76bf7..0000000
--- a/src/components/buttons/other/AuthSwitch.jsx
+++ /dev/null
@@ -1,128 +0,0 @@
-import React from 'react';
-import { renderToStaticMarkup } from 'react-dom/server';
-
-import { Switch, FormControlLabel, FormControl, alpha } from '@mui/material';
-import { useFormContext, useMode } from '../../../context'; // Adjust with actual path
-import { AuthModeSwitch } from '../../../layout/REUSABLE_STYLED_COMPONENTS/SpecificStyledComponents';
-import LoginIcon from '@mui/icons-material/Login';
-import PersonAddIcon from '@mui/icons-material/PersonAdd';
-import styled from 'styled-components';
-import { useCookies } from 'react-cookie';
-const convertSvg = (svg) => {
- const markup = renderToStaticMarkup(svg);
- const encoded = encodeURIComponent(markup);
- const dataUri = `url('data:image/svg+xml;utf8,${encoded}')`;
- return dataUri;
-};
-const AuthSwitch = () => {
- // const AuthSwitch = ({ signupMode, formLabel }) => {
- const { theme } = useMode(); // Ensures theme is applied correctly
- // const colors = theme;
- const colors = theme.palette.chartTheme;
- const cookies = useCookies('colorMode');
- const mode = cookies.colorMode;
-
- const primary = colors.primary.default;
- const blue = colors.blueAccent.default;
- const green = colors.greenAccent.light;
- const lihhtgreen = colors.greenAccent.default;
- const greenliht = colors.greenAccent.light;
- const lightgrey = colors.grey.light;
- const darkgrey = colors.grey.dark;
- const darkestgrey = colors.grey.darkest;
-
- const { currentSchemaKey, toggleForm } = useFormContext(); // Use toggleForm for toggling modes
- const signupMode = currentSchemaKey === 'signupForm';
- const handleToggle = () => {
- toggleForm(currentSchemaKey === 'loginForm' ? 'signupForm' : 'loginForm');
- };
- const switchBaseStyles = {
- '& .MuiSwitch-switchBase': {
- padding: 1, // Center the switch base padding for proper alignment
- '&.Mui-checked': {
- transform: 'translateX(16px)', // Ensure this aligns with your switch size
- color: theme.palette.common.white, // Thumb color when checked
- '& + .MuiSwitch-track': {
- backgroundColor: theme.palette.primary.main, // Track color when checked
- },
- },
- },
- };
- const thumbStyles = {
- '& .MuiSwitch-thumb': {
- width: 22, // Adjust thumb size for better visual alignment
- height: 22, // Adjust thumb size for better visual alignment
- backgroundColor: mode === 'dark' ? green : lihhtgreen,
- // backgroundColor: theme.palette.common.white, // Default thumb color
-
- '&:before': {
- content: '" "',
- display: 'block',
- backgroundImage: signupMode
- ? convertSvg()
- : convertSvg(),
- width: '100%',
- height: '100%',
- backgroundSize: '50%',
- backgroundPosition: 'center',
- backgroundRepeat: 'no-repeat',
- },
- // '&:after': {
- // right: 12, // Adjust the right icon position
- // backgroundImage: convertSvg(),
- // },
- },
- };
- const trackStyles = {
- '& .MuiSwitch-track': {
- backgroundColor: theme.palette.chartTheme.grey.light, // Default track color
- opacity: 1,
- width: 50, // Adjust thumb size for better visual alignment
- height: 14, // Adjust thumb size for better visual alignment
- // '&:before, &:after': {
- // content: '""',
- // position: 'absolute',
- // top: '50%',
- // transform: 'translateY(-50%)',
- // },
- // '&:before': {
- // left: 12, // Adjust the left icon position
- // backgroundImage: convertSvg(),
- // },
- // '&:after': {
- // right: 12, // Adjust the right icon position
- // backgroundImage: convertSvg(),
- // },
- },
- };
- const switchStyles = {
- ...switchBaseStyles,
- ...thumbStyles,
- ...trackStyles,
- // backgroundImage: convertSvg(),
- // right: 2,
- };
-
- return (
-
-
- }
- label={signupMode ? 'Sign Up' : 'Log In'}
- style={{ margin: 'auto', justifyContent: 'center' }} // Center label and switch
- />
-
- );
-};
-
-export default AuthSwitch;
diff --git a/src/components/buttons/other/CronTrigger.jsx b/src/components/buttons/other/CronTrigger.jsx
deleted file mode 100644
index 9710b37..0000000
--- a/src/components/buttons/other/CronTrigger.jsx
+++ /dev/null
@@ -1,27 +0,0 @@
-// import React from 'react';
-// import { Box, Button } from '@mui/material';
-// import { useCombinedContext } from '../../../context/CombinedProvider';
-// import { useAuthContext } from '../../../context';
-
-// const CronTrigger = () => {
-// const { stopCronJob, handleSendAllCardsInCollections, listOfMonitoredCards } =
-// useCombinedContext();
-// const { userId } = useAuthContext();
-// const handleTriggerCron = () => {
-// console.log('TRIGGERING CRON JOB TO UPDATE: ' + listOfMonitoredCards);
-// handleSendAllCardsInCollections(userId, listOfMonitoredCards);
-// };
-
-// const handleStopCron = () => {
-// stopCronJob();
-// };
-
-// return (
-//
-//
-//
-//
-// );
-// };
-
-// export default CronTrigger;
diff --git a/src/components/buttons/other/CustomButton.jsx b/src/components/buttons/other/CustomButton.jsx
deleted file mode 100644
index 272b23a..0000000
--- a/src/components/buttons/other/CustomButton.jsx
+++ /dev/null
@@ -1,43 +0,0 @@
-// import React from 'react';
-// import { Button } from '@mui/material';
-// import { useMode } from '../../../context'; // Adjust the import path based on your project structure
-// import MDButton from '../../../layout/REUSABLE_COMPONENTS/MDBUTTON';
-
-// const CustomButton = ({
-// text,
-// onClick,
-// variant = 'contained',
-// size = 'large',
-// sx = {},
-// }) => {
-// const { theme } = useMode();
-
-// const defaultStyles = {
-// background: theme.palette.backgroundE.darker,
-// borderColor: theme.palette.backgroundB.darkest,
-// borderWidth: 2,
-// mx: 1,
-// width: '70%',
-// '&:hover': {
-// fontWeight: 'bold',
-// background: theme.palette.backgroundF.dark,
-// borderColor: theme.palette.backgroundB.darkest,
-// border: `1px solid ${theme.palette.backgroundB.darkest}`,
-// },
-// ...sx, // Allow custom styles to override defaults
-// };
-
-// return (
-//
-// {text}
-//
-// );
-// };
-
-// export default CustomButton;
diff --git a/src/components/buttons/other/DeckSwitch.jsx b/src/components/buttons/other/DeckSwitch.jsx
deleted file mode 100644
index 7288664..0000000
--- a/src/components/buttons/other/DeckSwitch.jsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import React from 'react';
-import {
- Switch,
- FormControlLabel,
- Typography,
- FormControl,
-} from '@mui/material';
-import { useFormContext, useMode } from '../../../context'; // Adjust with actual path
-import MDTypography from '../../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-
-const DeckSwitch = ({ editMode, onToggle }) => {
- const { theme } = useMode(); // Ensures theme is applied correctly
-
- return (
-
-
- }
- label={
-
- {editMode ? 'Edit Mode' : 'View Mode'} {/* Label */}
-
- }
- style={{
- margin: theme.spacing(1), // Provide some spacing
- justifyContent: 'space-between', // Align items nicely
- }}
- />
-
- );
-};
-
-export default DeckSwitch;
diff --git a/src/components/buttons/other/OrderSubmitButton.js b/src/components/buttons/other/OrderSubmitButton.js
deleted file mode 100644
index e990dfd..0000000
--- a/src/components/buttons/other/OrderSubmitButton.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// import React from 'react';
-// import { Button } from '@mui/material';
-// import { useMode } from '../../../context';
-
-// const OrderSubmitButton = ({ onClick }) => {
-// const { theme } = useMode();
-// return (
-//
-// );
-// };
-
-// export default OrderSubmitButton;
diff --git a/src/components/buttons/other/ReusableLoadingButton.jsx b/src/components/buttons/other/ReusableLoadingButton.jsx
new file mode 100644
index 0000000..e2eac8e
--- /dev/null
+++ b/src/components/buttons/other/ReusableLoadingButton.jsx
@@ -0,0 +1,66 @@
+import React from 'react';
+import { LoadingButton } from '@mui/lab';
+import AdjustSharpIcon from '@mui/icons-material/AdjustSharp';
+import { useMode } from '../../../context';
+
+const ReusableLoadingButton = ({
+ loading,
+ label,
+ icon,
+ onClick,
+ style,
+ fullWidth,
+ sx,
+ variant,
+}) => {
+ const { theme } = useMode();
+
+ const getButtonStyles = (variant) => {
+ if (variant === 'warning') {
+ return {
+ background: theme.palette.error.main,
+ borderColor: theme.palette.error.darkest,
+ borderWidth: 5,
+
+ '&:hover': {
+ fontWeight: 'bold',
+ background: theme.palette.error.light,
+ borderColor: theme.palette.error.dark,
+ },
+ '&:focus': {
+ outline: `2px solid ${theme.palette.error.dark}`,
+ outlineOffset: 2,
+ },
+ };
+ }
+ return {
+ background: theme.palette.backgroundG.light,
+ borderColor: theme.palette.backgroundG.light,
+ borderWidth: 2,
+ '&:hover': { background: theme.palette.backgroundG.default },
+ '&:focus': { background: theme.palette.backgroundG.default },
+ };
+ };
+
+ return (
+ }
+ fullWidth={fullWidth}
+ onClick={onClick}
+ sx={{
+ ...sx,
+ mt: 2, // Adjust spacing as needed
+ ...getButtonStyles(variant),
+ }}
+ >
+ {label}
+
+ );
+};
+
+export default ReusableLoadingButton;
diff --git a/src/components/buttons/other/SearchButton.js b/src/components/buttons/other/SearchButton.js
deleted file mode 100644
index fcd05ae..0000000
--- a/src/components/buttons/other/SearchButton.js
+++ /dev/null
@@ -1,32 +0,0 @@
-// import React from 'react';
-// import { Button, Grid } from '@mui/material';
-// import { useMode } from '../../../context';
-
-// const SearchButton = ({ searchParams, handleSubmit }) => {
-// // const { handleRequest } = useCardStore();
-// const { theme } = useMode();
-
-// return (
-//
-//
-//
-// );
-// };
-
-// export default SearchButton;
diff --git a/src/components/buttons/other/SignupSwitch.jsx b/src/components/buttons/other/SignupSwitch.jsx
deleted file mode 100644
index e186d06..0000000
--- a/src/components/buttons/other/SignupSwitch.jsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import React from 'react';
-import { Switch, FormControlLabel, FormControl } from '@mui/material';
-import { useFormContext, useMode } from '../../../context'; // Adjust with actual path
-const SignupSwitch = ({ signupMode, toggleAuthMode, formLabel }) => {
- const { theme } = useMode(); // Ensures theme is applied correctly
-
- return (
-
-
- }
- label={formLabel}
- style={{
- margin: theme.spacing(1), // Provide some spacing
- justifyContent: 'space-between', // Align items nicely
- }}
- />
-
- );
-};
-
-export default SignupSwitch;
diff --git a/src/components/buttons/other/ThemeToggleButton.jsx b/src/components/buttons/other/ThemeToggleButton.jsx
deleted file mode 100644
index 1576bdd..0000000
--- a/src/components/buttons/other/ThemeToggleButton.jsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import React, { useContext, useState } from 'react';
-import { IconButton, Menu, MenuItem } from '@mui/material';
-import Brightness4Icon from '@mui/icons-material/Brightness4';
-import Brightness7Icon from '@mui/icons-material/Brightness7';
-import { ColorModeContext } from '../../../context/UTILITIES_CONTEXT/ColorModeContext/ColorModeProvider';
-
-const ThemeToggleButton = () => {
- const [anchorEl, setAnchorEl] = useState(null);
- const { toggleColorMode, setMode } = useContext(ColorModeContext);
-
- const handleClick = (event) => {
- setAnchorEl(event.currentTarget);
- };
-
- const handleClose = () => {
- setAnchorEl(null);
- };
-
- const handleThemeChange = (mode) => {
- toggleColorMode(mode); // Updated this line
- console.log('mode', mode);
- handleClose();
- };
-
- return (
-
-
-
-
-
-
- );
-};
-
-export default ThemeToggleButton;
diff --git a/src/components/cards/CardCarousel.jsx b/src/components/cards/CardCarousel.jsx
deleted file mode 100644
index 2e9c6fa..0000000
--- a/src/components/cards/CardCarousel.jsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import React from 'react';
-import styled from 'styled-components';
-import { Swiper, SwiperSlide } from 'swiper/react';
-import { EffectCoverflow, Pagination } from 'swiper';
-import 'swiper/css';
-import 'swiper/css/effect-coverflow';
-import 'swiper/css/pagination';
-import GenericCard from './GenericCard';
-import {
- StyledCarousel,
- StyledSwiperSlide,
-} from '../../pages/pageStyles/StyledComponents';
-
-const CardCarousel = ({ cards, context }) => {
- const swiperSettings = {
- effect: 'coverflow',
- grabCursor: true,
- centeredSlides: true,
- slidesPerView: 'auto',
- coverflowEffect: {
- rotate: 50,
- stretch: 0,
- depth: 200,
- modifier: 1,
- slideShadows: true,
- },
- loop: true,
- pagination: { clickable: true },
- };
-
- return (
-
-
- {cards.map((card, index) => (
-
-
-
- ))}
-
-
- );
-};
-
-export default CardCarousel;
diff --git a/src/components/cards/CardDetail.jsx b/src/components/cards/CardDetail.jsx
index 465c53c..7a2d605 100644
--- a/src/components/cards/CardDetail.jsx
+++ b/src/components/cards/CardDetail.jsx
@@ -27,18 +27,25 @@ const CardDetail = ({
{icon && {icon}}
- {/* {icon && (
- {icon}
- )} */}
-
{title}:
- {value && {value}}
+ {value && (
+
+ {value}
+
+ )}
{Array.isArray(values) &&
values.length > 0 &&
values.map((rarityValue, index) => (
@@ -56,25 +63,6 @@ const CardDetail = ({
variant="outlined"
/>
))}
- {/*
- {Array.isArray(values) && values.length > 0
- ? values.map((rarityValue, index) => (
- onRarityClick(rarityValue?.toString())}
- sx={{
- borderColor: getChipColor(rarityValue?.toString()),
- borderWidth: '2px',
- fontWeight: 700,
- color: getChipColor(rarityValue?.toString()),
- margin: '5px',
- }}
- variant="outlined"
- />
- ))
- : null}
- */}
);
diff --git a/src/components/cards/CardDetails.jsx b/src/components/cards/CardDetails.jsx
deleted file mode 100644
index 0ef2501..0000000
--- a/src/components/cards/CardDetails.jsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import React from 'react';
-import { Box, Typography } from '@mui/material';
-import useResponsiveStyles from '../../context/hooks/style-hooks/useResponsiveStyles';
-import { useTheme } from 'styled-components';
-import {
- CardDetailContainer,
- CardDetailRow,
- CardIconWrapper,
- CardTitleStyle,
- CardValueStyle,
- useCardDetailStyles,
-} from './styles/cardStyles';
-import { useMode } from '../../context';
-import MDTypography from '../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-
-const CardDetails = ({ details, className }) => {
- // details expected to be an array of objects with { icon, title, value }
- const { theme } = useMode();
- // const theme2 = useTheme();
- // const styles = useCardDetailStyles(theme, theme2);
- // const { getHeaderStyle, getButtonTypographyVariant } =
- // useResponsiveStyles(theme);
-
- return (
-
- {details.map(({ icon, title, value }, index) => (
-
- {icon && {icon}}
-
- {title}:
- {value || ''}
-
-
- ))}
-
- );
-};
-
-export default CardDetails;
diff --git a/src/components/cards/CardDetailsContainer.jsx b/src/components/cards/CardDetailsContainer.jsx
index bc1709b..7ca3a31 100644
--- a/src/components/cards/CardDetailsContainer.jsx
+++ b/src/components/cards/CardDetailsContainer.jsx
@@ -1,5 +1,15 @@
import React from 'react';
-import { Box, Grid } from '@mui/material';
+import {
+ Box,
+ Card,
+ CardContent,
+ CardHeader,
+ Grid,
+ List,
+ ListItem,
+ Stack,
+ Typography,
+} from '@mui/material';
import {
FaDragon,
FaLevelUpAlt,
@@ -27,36 +37,115 @@ const IconWrapper = styled(Box)(({ theme }) => ({
color: theme.palette.text.primary,
}));
-const CardDetailsContainer = ({ card, className }) => {
+const iconDetails = [
+ { icon: FaLevelUpAlt, title: 'Level' },
+ { icon: FaVenusMars, title: 'Type' },
+ { icon: FaDragon, title: 'Race' },
+ { icon: FaRegLightbulb, title: 'Attribute' },
+ { icon: GiAxeSword, title: 'ATK' },
+ { icon: FaShieldAlt, title: 'DEF' },
+];
+
+const textDetails = [
+ { title: 'Description' },
+ { title: 'Price' },
+ { title: 'Rarity', isMultiValue: true, action: 'onRarityClick' },
+ { title: 'Card Sets', isMultiValue: true, action: 'onRarityClick' },
+];
+
+const inventoryDetails = [
+ { title: 'Deck', key: 'deck' },
+ { title: 'Collection', key: 'collection' },
+ { title: 'Cart', key: 'cart' },
+];
+// Consolidating the rendering of both icon and text details into a single component.
+const RenderDetailsSection = ({ details, card, className, handleAction }) => {
+ const { theme } = useMode();
+
+ return details.map((detail, index) => (
+
+
+
+
+ ) : null
+ }
+ title={detail.title}
+ value={
+ detail.isMultiValue
+ ? card?.card_sets?.map((set) => set[detail.title.toLowerCase()])
+ : card?.[detail.title.toLowerCase()]
+ }
+ quantity={card?.quantity}
+ {...(detail.action ? { [detail.action]: handleAction } : {})}
+ />
+
+ ));
+};
+
+const RenderInventoryList = () => (
+
+
+
+ {/* Render the header separately */}
+ {inventoryDetails[0].title}
+ }
+ />
+
+
+ {/* Skip the header in mapping */}
+ {inventoryDetails.slice(1).map((detail, index) => (
+ {detail.title}
+ ))}
+
+
+
+
+
+);
+const CardDetailsContainer = ({
+ card,
+ className,
+ isIconSection,
+ isTextSection,
+ isInventorySection,
+ titles,
+}) => {
const { theme } = useMode();
+ const handleAction = () => console.log('Action clicked');
return (
-
- {[
- { icon: FaLevelUpAlt, title: 'Level', value: card?.level },
- { icon: FaVenusMars, title: 'Type', value: card?.type },
- { icon: FaDragon, title: 'Race', value: card?.race },
- { icon: FaRegLightbulb, title: 'Attribute', value: card?.attribute },
- { icon: GiAxeSword, title: 'ATK', value: card?.atk },
- { icon: FaShieldAlt, title: 'DEF', value: card?.def },
- ].map((detail, index) => (
-
-
-
-
- )
- }
- title={detail.title}
- value={detail.value}
- quantity={card?.quantity}
- />
-
- ))}
+
+ {isIconSection && (
+
+ )}
+ {isTextSection && (
+
+ )}
+ {isInventorySection && }
);
};
diff --git a/src/components/cards/media/CardMediaSection.js b/src/components/cards/CardMediaSection.js
similarity index 87%
rename from src/components/cards/media/CardMediaSection.js
rename to src/components/cards/CardMediaSection.js
index e0a70c3..11f0f97 100644
--- a/src/components/cards/media/CardMediaSection.js
+++ b/src/components/cards/CardMediaSection.js
@@ -1,15 +1,13 @@
import React, { useEffect, forwardRef, useState } from 'react';
-import { Backdrop, CardMedia, Popover, Popper } from '@mui/material';
-import CardToolTip from '../CardToolTip';
+import CardToolTip from './CardToolTip';
import PropTypes from 'prop-types';
-import { useModalContext, useMode, usePopoverContext } from '../../../context';
+import { useMode } from '../../context';
import {
MediaContainer,
Media,
MediaPopover,
- Overlay,
-} from '../../../context/hooks/style-hooks/usePortfolioStyles';
-import { useOverlay } from '../../../context/hooks/useOverlay';
+} from '../../context/hooks/style-hooks/usePortfolioStyles';
+import { useOverlay } from '../../context/hooks/useOverlay';
const CardMediaSection = forwardRef(
(
{
diff --git a/src/components/cards/CardTextSection.jsx b/src/components/cards/CardTextSection.jsx
deleted file mode 100644
index 2000a90..0000000
--- a/src/components/cards/CardTextSection.jsx
+++ /dev/null
@@ -1,119 +0,0 @@
-import React from 'react';
-import Typography from '@mui/material/Typography';
-import Box from '@mui/material/Box';
-import { useMode } from '../../../context';
-import FlexBetween from '../../layout/REUSABLE_COMPONENTS/FlexBetween';
-import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
-
-// Updated SimpleSectionHeader component with additional parameters
-const CardTextSection = ({
- name,
- price,
- cartQuantity,
- collectionQuantity,
- deckQuantity,
- cardSet,
- setCode,
- cardRarity,
-}) => {
- const { theme } = useMode();
- return (
-
- {/* CARD TITLE SECTION: name */}
-
- {name}
-
- {/* CARD TITLE SUBSECTION: set name, rarity, set code */}
-
- {`Set: ${cardSet}`}
-
- {cardRarity}
-
-
- {setCode}
-
-
- {/* CARD TITLE SUBSECTION B: context quantities, price, price change */}
-
-
-
- {`Cart: ${cartQuantity}`}
-
-
- {`Collection: ${collectionQuantity}`}
-
-
- {`Deck: ${deckQuantity}`}
-
-
-
-
- {`Price: ${price}`}
-
- {`Price Change: ${price}`}
-
-
-
-
-
- );
-};
-
-export default CardTextSection;
diff --git a/src/components/cards/CardToolTip.jsx b/src/components/cards/CardToolTip.jsx
index d117750..a9617a8 100644
--- a/src/components/cards/CardToolTip.jsx
+++ b/src/components/cards/CardToolTip.jsx
@@ -1,16 +1,47 @@
import React from 'react';
import PropTypes from 'prop-types';
-import {
- // StyledAttributeSpan,
- StyledDescriptionSpan,
- StyledToolTipBox,
- StyledTooltip,
- StyledTooltipTitle,
-} from './styles/cardStyles';
import { useMode } from '../../context';
-import { Box, Typography } from '@mui/material';
+import { Box, Tooltip, Typography, Zoom } from '@mui/material';
import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
-
+import styled from 'styled-components';
+export const StyledToolTipBox = styled(Box)(({ theme }) => ({
+ width: 'auto',
+ border: `1px solid ${theme.palette.divider}`,
+ borderRadius: theme.shape.borderRadius,
+ padding: theme.spacing(2),
+ backgroundColor: theme.palette.backgroundA.lightest,
+ color: theme.palette.text.primary,
+ boxShadow: theme.shadows[3],
+ alignContent: 'flex-start',
+ alignItems: 'flex-start',
+ height: '100%',
+ maxWidth: 220,
+ position: 'relative',
+ '&::before': {
+ content: '""',
+ display: 'block',
+ paddingTop: '100%',
+ },
+ '& > img': {
+ position: 'absolute',
+ top: 0,
+ left: 0,
+ width: '100%',
+ height: '100%',
+ objectFit: 'cover',
+ },
+}));
+export const StyledTooltipTitle = styled('h4')(({ theme }) => ({
+ fontWeight: 'bold',
+ marginBottom: theme.spacing(1),
+ alignContent: 'flex-start',
+ alignItems: 'flex-start',
+}));
+export const StyledDescriptionSpan = styled('span')(({ theme }) => ({
+ display: 'block',
+ marginTop: theme.spacing(1),
+ flexGrow: 1,
+}));
const formatKey = (key) =>
key.replace(/_/g, ' ').replace(/^\w/, (c) => c.toUpperCase());
const StyledAttributeSpan = ({ theme, children }) => (
@@ -47,13 +78,12 @@ const createTooltip = (card, theme) => {
boxShadow: theme.shadows[3],
borderRadius: theme.shape.borderRadius,
border: `1px solid ${theme.palette.divider}`,
- w: 'auto',
- h: '100%',
+ // w: 'auto',
+ // h: '100%',
bgColor: theme.palette.backgroundC.lightest,
- p: theme.spacing(2),
+ // p: theme.spacing(2),
color: theme.palette.text.primary,
alignContent: 'flex-start',
-
'&::before': {
content: '""',
display: 'block',
@@ -81,11 +111,16 @@ const createTooltip = (card, theme) => {
const CardToolTip = ({ card }) => {
const { theme } = useMode();
return (
-
+
{createTooltip(card, theme)}
-
+
);
};
diff --git a/src/components/cards/CarouselCard.jsx b/src/components/cards/CarouselCard.jsx
deleted file mode 100644
index dda4859..0000000
--- a/src/components/cards/CarouselCard.jsx
+++ /dev/null
@@ -1,160 +0,0 @@
-import React, { useContext, useEffect, useRef, useState } from 'react';
-import SwipeableViews from 'react-swipeable-views';
-import {
- Box,
- Button,
- Container,
- Grid,
- MobileStepper,
- Typography,
-} from '@mui/material';
-import { ModalContext } from '../../context/UTILITIES_CONTEXT/ModalContext/ModalContext';
-import GenericCard from './GenericCard';
-import {
- MainContainer2,
- CardMobile,
- ChartContainerMobile,
- CardDetails,
- CardDetailsContainer,
- ChartContainer,
-} from '../../pages/pageStyles/StyledComponents';
-import { AspectRatio } from '@mui/joy';
-import { debounce } from 'lodash';
-import { useMode } from '../../context';
-import MDTypography from '../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-const CarouselCard = ({ card }) => {
- const { theme } = useMode();
- const { openModalWithCard } = useContext(ModalContext); // Assuming ModalContext is imported
- const cardRef = useRef(null);
- const chartRef = useRef(null);
- const [chartDimensions, setChartDimensions] = useState({
- width: 0,
- height: 0,
- });
- const HEIGHT_TO_WIDTH_RATIO = 1; // Define the ratio here
-
- const handleClick = () => {
- openModalWithCard(card);
- };
-
- useEffect(() => {
- const handleResize = debounce(() => {
- if (chartRef.current) {
- const width = chartRef.current.offsetWidth;
- const height = width * HEIGHT_TO_WIDTH_RATIO;
- setChartDimensions({ width, height });
- }
- }, 100);
-
- window.addEventListener('resize', handleResize);
- handleResize();
-
- return () => {
- window.removeEventListener('resize', handleResize);
- handleResize.cancel();
- };
- }, []);
- return (
-
- {/* */}{' '}
- {/* Ensure the container doesn't overflow */}
-
-
-
- handleClick()}
- context={'Collection'}
- ref={cardRef}
- />
-
-
- {/* Top section for card details */}
-
-
-
-
-
- {card?.name}
-
-
-
-
-
- Price: ${card?.latestPrice?.num || card?.price || 0}
-
-
- Quantity: {card?.quantity}
-
- {/* */}
-
-
-
- {/* Bottom section for chart */}
-
-
-
-
- {/* Chart component goes here */}
-
-
-
-
-
-
-
- {/* */}
-
- );
-};
-
-export default CarouselCard;
diff --git a/src/components/cards/GenericCard.jsx b/src/components/cards/GenericCard.jsx
index 6f9be82..b52ff93 100644
--- a/src/components/cards/GenericCard.jsx
+++ b/src/components/cards/GenericCard.jsx
@@ -6,9 +6,9 @@ import React, {
useState,
} from 'react';
import { CardActions, Typography } from '@mui/material';
-import CardMediaSection from './media/CardMediaSection';
+import CardMediaSection from './CardMediaSection';
import GenericActionButtons from '../buttons/actionButtons/GenericActionButtons';
-import placeholderImage from '../../assets/images/placeholder.jpeg';
+import placeholder from '../../assets/images/placeholder.jpeg';
import { useModalContext } from '../../context/UTILITIES_CONTEXT/ModalContext/ModalContext';
import { PopoverContext } from '../../context/UTILITIES_CONTEXT/PopoverContext/PopoverContext';
import { Box } from '@mui/system';
@@ -31,6 +31,9 @@ import useSelectedContext from '../../context/hooks/useSelectedContext';
import useSelectedCollection from '../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
const GenericCard = React.forwardRef((props, ref) => {
const { card, context, page } = props;
+ const effectiveContext =
+ typeof context === 'object' ? context.pageContext : context;
+
const { theme } = useMode();
const cardRef = useRef(null);
const [cardSize, setCardSize] = useState('md'); // Default to 'sm'
@@ -57,19 +60,6 @@ const GenericCard = React.forwardRef((props, ref) => {
const { selectedDeck, allDecks } = useDeckStore();
const { setContext, setIsContextSelected } = useSelectedContext();
const { isCardInContext } = useAppContext();
-
- // const { isCardInContext } = useAppContext();
- // const isCardInContext = useCallback(
- // (selectedCollection, selectedDeck, cartData, context, card) => {
- // const cardsList = {
- // Collection: selectedCollection?.cards,
- // Deck: selectedDeck?.cards,
- // Cart: cartData?.cart,
- // };
- // return !!cardsList[context]?.find((c) => c?.id === card?.id);
- // },
- // [context, selectedCollection, selectedDeck, cartData]
- // );
const { openModalWithCard, setModalOpen, setClickedCard, isModalOpen } =
useModalContext();
const { setHoveredCard, setIsPopoverOpen, hoveredCard } =
@@ -99,7 +89,7 @@ const GenericCard = React.forwardRef((props, ref) => {
}, [hoveredCard, card, setIsPopoverOpen]);
const isInContext = isCardInContext(card);
const name = card?.name;
- const imgUrl = card?.card_images?.[0]?.image_url || placeholderImage;
+ const imgUrl = card?.card_images?.[0]?.image_url || placeholder;
const price = `Price: ${
card?.latestPrice?.num ||
card?.price ||
@@ -115,18 +105,7 @@ const GenericCard = React.forwardRef((props, ref) => {
allDecks: allDecks,
});
let cardContent = null;
- if (cardSize === 'sm') {
- cardContent = (
-
-
- {name}
-
-
- {price}
-
-
- );
- } else if (cardSize !== 'xs') {
+ if (cardSize !== 'xs') {
cardContent = (
@@ -135,18 +114,22 @@ const GenericCard = React.forwardRef((props, ref) => {
{price}
- {`Cart: ${isInContext ? cartQuantity : 'N/A'}`}
- {`Collection: ${isInContext ? collectionQuantity : 'N/A'}`}
- {`Deck: ${isInContext ? deckQuantity : 'N/A'}`}
+ {cardSize !== 'sm' && (
+ <>
+ {`Cart: ${isInContext ? cartQuantity : 'N/A'}`}
+ {`Collection: ${isInContext ? collectionQuantity : 'N/A'}`}
+ {`Deck: ${isInContext ? deckQuantity : 'N/A'}`}
+ >
+ )}
);
}
@@ -158,7 +141,7 @@ const GenericCard = React.forwardRef((props, ref) => {
isRequired={true}
imgUrl={imgUrl}
card={card}
- context={context}
+ context={effectiveContext}
page={page}
quantity={card?.quantity}
isHovered={hoveredCard === card}
@@ -177,8 +160,8 @@ const GenericCard = React.forwardRef((props, ref) => {
>
handleContextSelect(context)}
+ context={effectiveContext}
+ onClick={() => handleContextSelect(effectiveContext)}
onSuccess={() =>
enqueueSnackbar(
{
diff --git a/src/components/cards/styles/cardStyles.jsx b/src/components/cards/styles/cardStyles.jsx
index 3816ae6..7bf1580 100644
--- a/src/components/cards/styles/cardStyles.jsx
+++ b/src/components/cards/styles/cardStyles.jsx
@@ -33,77 +33,75 @@ export const StyledButton = styled(Button)(({ theme }) => ({
maxHeight: '60px',
width: '100%',
}));
-export const StyledToolTipBox = styled(Box)(({ theme }) => ({
- width: 'auto',
- border: `1px solid ${theme.palette.divider}`,
- borderRadius: theme.shape.borderRadius,
- padding: theme.spacing(2),
- backgroundColor: theme.palette.backgroundA.lightest,
- color: theme.palette.text.primary,
- boxShadow: theme.shadows[3],
- alignContent: 'flex-start',
- alignItems: 'flex-start',
- height: '100%',
- maxWidth: 220,
- position: 'relative',
- '&::before': {
- content: '""',
- display: 'block',
- paddingTop: '100%',
- },
- '& > img': {
- position: 'absolute',
- top: 0,
- left: 0,
- width: '100%',
- height: '100%',
- objectFit: 'cover',
- },
-}));
-export const StyledTooltip = styled(Tooltip)(({ theme }) => ({
- // width: 'auto',
- // border: `1px solid ${theme.palette.divider}`,
- // borderRadius: theme.shape.borderRadius,
- // padding: theme.spacing(2),
- // backgroundColor: theme.palette.backgroundA.lightest,
- // color: theme.palette.text.primary,
- // boxShadow: theme.shadows[3],
- // alignContent: 'flex-start',
- // alignItems: 'flex-start',
- // height: '100%',
- // maxWidth: 220,
- // position: 'relative',
- // '&::before': {
- // content: '""',
- // display: 'block',
- // paddingTop: '100%',
- // },
- // '& > img': {
- // position: 'absolute',
- // top: 0,
- // left: 0,
- // width: '100%',
- // height: '100%',
- // objectFit: 'cover',
- // },
-}));
-export const StyledTooltipTitle = styled('h4')(({ theme }) => ({
- fontWeight: 'bold',
- marginBottom: theme.spacing(1),
- alignContent: 'flex-start',
- alignItems: 'flex-start',
-}));
-
-export const StyledDescriptionSpan = styled('span')(({ theme }) => ({
- display: 'block',
- marginTop: theme.spacing(1),
- flexGrow: 1,
-}));
-
-export const StyledAttributeSpan = styled('span')(({ theme }) => ({
- display: 'block',
- marginBottom: theme.spacing(0.5),
-}));
+// export const StyledToolTipBox = styled(Box)(({ theme }) => ({
+// width: 'auto',
+// border: `1px solid ${theme.palette.divider}`,
+// borderRadius: theme.shape.borderRadius,
+// padding: theme.spacing(2),
+// backgroundColor: theme.palette.backgroundA.lightest,
+// color: theme.palette.text.primary,
+// boxShadow: theme.shadows[3],
+// alignContent: 'flex-start',
+// alignItems: 'flex-start',
+// height: '100%',
+// maxWidth: 220,
+// position: 'relative',
+// '&::before': {
+// content: '""',
+// display: 'block',
+// paddingTop: '100%',
+// },
+// '& > img': {
+// position: 'absolute',
+// top: 0,
+// left: 0,
+// width: '100%',
+// height: '100%',
+// objectFit: 'cover',
+// },
+// }));
+// export const StyledTooltip = styled(Tooltip)(({ theme }) => ({
+// // width: 'auto',
+// // border: `1px solid ${theme.palette.divider}`,
+// // borderRadius: theme.shape.borderRadius,
+// // padding: theme.spacing(2),
+// // backgroundColor: theme.palette.backgroundA.lightest,
+// // color: theme.palette.text.primary,
+// // boxShadow: theme.shadows[3],
+// // alignContent: 'flex-start',
+// // alignItems: 'flex-start',
+// // height: '100%',
+// // maxWidth: 220,
+// // position: 'relative',
+// // '&::before': {
+// // content: '""',
+// // display: 'block',
+// // paddingTop: '100%',
+// // },
+// // '& > img': {
+// // position: 'absolute',
+// // top: 0,
+// // left: 0,
+// // width: '100%',
+// // height: '100%',
+// // objectFit: 'cover',
+// // },
+// }));
+// export const StyledTooltipTitle = styled('h4')(({ theme }) => ({
+// fontWeight: 'bold',
+// marginBottom: theme.spacing(1),
+// alignContent: 'flex-start',
+// alignItems: 'flex-start',
+// }));
+// export const StyledDescriptionSpan = styled('span')(({ theme }) => ({
+// display: 'block',
+// marginTop: theme.spacing(1),
+// flexGrow: 1,
+// }));
+// export const StyledAttributeSpan = styled('span')(({ theme }) => ({
+// display: 'block',
+// marginBottom: theme.spacing(0.5),
+// }));
export const CardDetailContainer = styled(Box)(({ theme }) => ({
padding: theme.spacing(2),
diff --git a/src/components/componentHelpers.jsx b/src/components/componentHelpers.jsx
index c5ce162..cf5f519 100644
--- a/src/components/componentHelpers.jsx
+++ b/src/components/componentHelpers.jsx
@@ -1,4 +1,3 @@
-// Desc: Helper functions for components
export const getQuantity = ({
card,
cartData,
@@ -7,7 +6,6 @@ export const getQuantity = ({
selectedDeck,
allDecks,
}) => {
- // Helper function to find the quantity of a card in a list of collections or decks
const findCardQuantity = (collectionsOrDecks, cardId) =>
collectionsOrDecks?.reduce(
(acc, item) =>
diff --git a/src/components/dialogs/CollectionDialog.jsx b/src/components/dialogs/CollectionDialog.jsx
index 5147405..3df8c3b 100644
--- a/src/components/dialogs/CollectionDialog.jsx
+++ b/src/components/dialogs/CollectionDialog.jsx
@@ -1,132 +1,80 @@
-import React, { useEffect } from 'react';
+import React from 'react';
import PropTypes from 'prop-types';
-import {
- Avatar,
- Box,
- CssBaseline,
- Dialog,
- DialogContent,
- Grid,
- Paper,
-} from '@mui/material';
-import { useCollectionStore, useFormContext, useMode } from '../../context';
+import { CssBaseline, DialogTitle, Divider } from '@mui/material';
+import { useMode } from '../../context';
+import CollectionForm from '../forms/CollectionForm'; // Adjusted import
import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
-import AddCollectionForm from '../forms/AddCollectionForm';
-import UpdateCollectionForm from '../forms/UpdateCollectionForm';
import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
import MDTypography from '../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-import { withDynamicSnackbar } from '../../layout/REUSABLE_COMPONENTS/HOC/DynamicSnackbar';
-const CollectionDialog = ({
- open,
- onClose,
- isNew,
- collectionData,
- collectionMode,
-}) => {
- const { currentForm, setCurrentForm } = useFormContext();
- const { theme } = useMode();
+import {
+ DialogPaper,
+ StyledDialog,
+ StyledDialogContent,
+} from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
+import MDAvatar from '../../layout/REUSABLE_COMPONENTS/MDAVATAR';
- useEffect(() => {
- if (collectionMode === 'edit') {
- setCurrentForm('updateCollectionForm');
- }
- }, [collectionMode, setCurrentForm]);
+const CollectionDialog = ({ open, onClose, isNew, collectionData }) => {
+ const { theme } = useMode();
+ const actionType = isNew ? 'add' : 'update';
return (
-
+
+
+
+
+ {isNew ? 'Add a Collection' : 'Update a Collection'}
+
+
+
+
+
+
+
+
+
+
);
};
CollectionDialog.propTypes = {
- // open: PropTypes.bool.isRequired,
- // onClose: PropTypes.func.isRequired,
+ open: PropTypes.bool.isRequired,
+ onClose: PropTypes.func.isRequired,
isNew: PropTypes.bool,
collectionData: PropTypes.shape({
name: PropTypes.string,
@@ -134,4 +82,4 @@ CollectionDialog.propTypes = {
}),
};
-export default withDynamicSnackbar(CollectionDialog);
+export default CollectionDialog;
diff --git a/src/components/dialogs/DeckDialog.jsx b/src/components/dialogs/DeckDialog.jsx
new file mode 100644
index 0000000..e488cd3
--- /dev/null
+++ b/src/components/dialogs/DeckDialog.jsx
@@ -0,0 +1,85 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { CssBaseline, DialogTitle, Divider } from '@mui/material';
+import { useMode } from '../../context';
+import DeckForm from '../forms/DeckForm'; // Adjusted import
+import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
+import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
+import MDTypography from '../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
+import {
+ DialogPaper,
+ StyledDialog,
+ StyledDialogContent,
+} from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
+import MDAvatar from '../../layout/REUSABLE_COMPONENTS/MDAVATAR';
+
+const DeckDialog = ({ open, onClose, isNew, deckData }) => {
+ const { theme } = useMode();
+ const actionType = isNew ? 'add' : 'update';
+
+ return (
+
+
+
+
+
+
+
+
+
+ {isNew ? 'Add a Deck' : 'Update a Deck'}
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+DeckDialog.propTypes = {
+ open: PropTypes.bool.isRequired,
+ onClose: PropTypes.func.isRequired,
+ isNew: PropTypes.bool,
+ deckData: PropTypes.shape({
+ name: PropTypes.string,
+ description: PropTypes.string,
+ }),
+};
+
+export default DeckDialog;
diff --git a/src/components/dialogs/DeckEditPanel.js b/src/components/dialogs/DeckEditPanel.js
deleted file mode 100644
index 532d924..0000000
--- a/src/components/dialogs/DeckEditPanel.js
+++ /dev/null
@@ -1,374 +0,0 @@
-import React, { useState, useEffect } from 'react';
-import {
- Paper,
- Typography,
- Button,
- TextField,
- Chip,
- Box,
- FormControl,
- InputLabel,
- Select,
- MenuItem,
-} from '@mui/material';
-import { useDeckStore, useFormContext, useMode } from '../../context';
-import useSnackBar from '../../context/hooks/useSnackBar';
-import { withDynamicSnackbar } from '../../layout/REUSABLE_COMPONENTS/HOC/DynamicSnackbar';
-import SaveIcon from '@mui/icons-material/Save';
-import DeleteIcon from '@mui/icons-material/Delete';
-import { FormBox } from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
-import FormField from '../forms/reusable/FormField';
-const DeckEditPanel = ({ selectedDeck, showSnackbar }) => {
- const { theme } = useMode();
- // const { showSnackbar } = useSnackBar(); // Assuming snackbar hook for user notifications
- const {
- formMethods,
- // formStates: { errors, isSubmitting, ...formStates },
- register,
- handleSubmit,
- setValue,
- watch,
- formState: { errors, isSubmitting },
- reset,
- setFormSchema,
- onSubmit,
- // Removal of onSubmit from destructuring as we will define a local handler
- } = useFormContext();
- // Local state for dynamic fields like tags
- const [newTag, setNewTag] = useState('');
- const tags = watch('tags', selectedDeck?.tags || []);
- const color = watch('color');
-
- useEffect(() => {
- setFormSchema('updateDeckForm');
- }, [setFormSchema]);
-
- useEffect(() => {
- if (selectedDeck) {
- reset({
- name: selectedDeck.name,
- description: selectedDeck.description,
- tags: selectedDeck.tags || [],
- color: selectedDeck.color || 'red',
- });
- }
- }, [selectedDeck, reset]);
-
- const handleAddNewTag = (newTag) => {
- if (newTag && !tags.includes(newTag)) {
- setValue('tags', [...tags, newTag.trim()]);
- }
- };
- const handleTagDelete = (tagToDelete) => {
- setValue(
- 'tags',
- tags.filter((tag) => tag !== tagToDelete)
- );
- };
- const handleFormSubmit = async (data) => {
- try {
- // Assuming `onSubmit` is a function passed via context or props that handles the actual submission
- await onSubmit(data); // Adjust based on actual implementation
- showSnackbar({
- message: 'Deck updated successfully',
- variant: 'success',
- });
- } catch (error) {
- showSnackbar({
- message: error.message || 'An error occurred while updating the deck.',
- variant: 'error',
- });
- }
- };
- // const handleDeleteClick = async () => {
- // try {
- // // await deleteDeck(selectedDeck._id);
- // showSnackbar({
- // message: 'Deck deleted successfully',
- // variant: 'warning',
- // });
- // reset(); // Optionally reset form state
- // } catch (error) {
- // showSnackbar({
- // message: error.message || 'Failed to delete deck',
- // variant: 'error',
- // });
- // }
- // };
-
- return (
-
- Deck Editor
-
-
-
-
-
- {tags &&
- tags?.map((tag, index) => (
- handleTagDelete(tag)}
- />
- ))}
- setNewTag(e.target.value)}
- onBlur={handleAddNewTag}
- onKeyDown={(e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
- handleAddNewTag();
- }
- }}
- />
-
-
- Color
-
-
-
- }
- type="submit"
- variant="contained"
- sx={{ flexGrow: 1 }}
- >
- Save Changes
-
- }
- variant="contained"
- color="error"
- onClick={
- selectedDeck
- ? () =>
- onSubmit({
- ...watch(),
- _id: selectedDeck._id,
- delete: true,
- })
- : undefined
- }
- sx={{ flexGrow: 1 }}
- >
- Delete Deck
-
-
-
-
- );
-};
-
-export default withDynamicSnackbar(DeckEditPanel); // Wrap DeckEditPanel with withDynamicSnackbar HOC
-
-// import React, { useState, useEffect } from 'react';
-// import {
-// Paper,
-// Typography,
-// Button,
-// TextField,
-// Chip,
-// Stack,
-// FormControl,
-// InputLabel,
-// Select,
-// MenuItem,
-// Box,
-// Switch,
-// } from '@mui/material';
-// import DeleteIcon from '@mui/icons-material/Delete';
-// import {
-// useDeckStore,
-// useMode,
-// usePageContext,
-// useFormContext,
-// } from '../../context';
-// import {
-// StyledFormControl,
-// SwitchControl,
-// StyledButton,
-// StyledTextField,
-// StyledSelect,
-// } from '../../pages/pageStyles/StyledComponents';
-// import FormField from '../reusable/FormField';
-
-// const DeckEditPanel = ({ selectedDeck, handleToggleEdit, isEditing }) => {
-// const { returnDisplay, loadingStatus, setIsFormDataLoading } =
-// usePageContext();
-// const {
-// setFormType,
-// register,
-// handleSubmit,
-// errors,
-// currentFormType,
-// isSubmitting,
-// // formState: { errors, isSubmitting },
-// onSubmit,
-// } = useFormContext();
-
-// useEffect(() => {
-// // Assuming setFormType is a function that can set the form context
-// setFormType('addDeckForm');
-// }, [isNew, setFormType]);
-// const isAddDeckForm = currentFormType === 'addDeckForm';
-
-// const { theme } = useMode();
-// const tags = selectedDeck?.tags || [];
-
-// return (
-//
-//
-//
-// );
-// };
-// export default DeckEditPanel;
diff --git a/src/components/dialogs/homeDetailsModal/DetailsModal.jsx b/src/components/dialogs/DetailsModal.jsx
similarity index 98%
rename from src/components/dialogs/homeDetailsModal/DetailsModal.jsx
rename to src/components/dialogs/DetailsModal.jsx
index 1d210f1..0227f16 100644
--- a/src/components/dialogs/homeDetailsModal/DetailsModal.jsx
+++ b/src/components/dialogs/DetailsModal.jsx
@@ -13,7 +13,7 @@ import {
} from '@mui/material';
import CloseIcon from '@mui/icons-material/Close';
import { FaGithub, FaExternalLinkAlt } from 'react-icons/fa';
-import { useModalContext } from '../../../context';
+import { useModalContext } from '../../context';
const DetailsModal = () => {
const { featureData, detailsModalShow, closeDetailsModal } =
diff --git a/src/components/dialogs/GenericCardDialog.jsx b/src/components/dialogs/GenericCardDialog.jsx
new file mode 100644
index 0000000..8f11f19
--- /dev/null
+++ b/src/components/dialogs/GenericCardDialog.jsx
@@ -0,0 +1,359 @@
+// import React, { useCallback, useEffect, useState } from 'react';
+// import {
+// Dialog,
+// DialogTitle,
+// DialogContent,
+// Snackbar,
+// Alert,
+// Grid,
+// Container,
+// useMediaQuery,
+// Slide,
+// Fade,
+// IconButton,
+// Stack,
+// Typography,
+// Card,
+// CardHeader,
+// List,
+// CardContent,
+// ListItem,
+// Backdrop,
+// } from '@mui/material';
+// import useSelectedContext from '../../context/hooks/useSelectedContext';
+// import { useModalContext, useMode } from '../../context';
+// import CardMediaSection from '../cards/CardMediaSection';
+// import GenericActionButtons from '../buttons/actionButtons/GenericActionButtons';
+// import CloseIcon from '@mui/icons-material/Close';
+// import CardDetail from '../cards/CardDetail';
+// import { useOverlay } from '../../context/hooks/useOverlay';
+// import CardDetailsContainer from '../cards/CardDetailsContainer';
+// import { enqueueSnackbar } from 'notistack';
+// import {
+// DialogPaper,
+// StyledDialog,
+// } from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
+
+// const GenericCardDialog = (props) => {
+// const { theme } = useMode();
+// const { generateOverlay, handleRarityClick, openOverlay, closeOverlay } =
+// useOverlay(theme);
+// const {
+// open = false,
+// transition = false,
+// close,
+// hideBackdrop = false,
+// title = '',
+// content = '',
+// actions = '',
+// dividers = false,
+// closeIcon = true,
+// // fullScreen = false,
+// actionPosition = 'left',
+// closeIconSx = {
+// position: 'absolute',
+// right: 8,
+// top: 8,
+// color: (theme) => theme.palette.grey[500],
+// },
+// card,
+// context,
+// ...other
+// } = props || {};
+// const fullScreen = useMediaQuery(theme.breakpoints.down('md'));
+// const { closeModal } = useModalContext();
+// const [imageUrl, setImageUrl] = useState(card?.card_images[0]?.image_url);
+// const [hasLoggedCard, setHasLoggedCard] = useState(false);
+// const { setContext, setIsContextSelected } = useSelectedContext();
+// const handleAction = useCallback(
+// (message, severity, error) => {
+// enqueueSnackbar(message, severity);
+// if (error) console.error('Action failed:', error);
+// },
+// [enqueueSnackbar]
+// );
+// useEffect(() => {
+// if (open && card && !hasLoggedCard) {
+// enqueueSnackbar('Card details loaded successfully.', 'success');
+// setHasLoggedCard(true);
+// }
+// return () => {
+// if (!open) setHasLoggedCard(false);
+// };
+// }, [open, card, enqueueSnackbar, hasLoggedCard]);
+// // Context selection handling
+// const handleContextSelect = useCallback(
+// (newContext) => {
+// setContext(newContext);
+// setIsContextSelected(true);
+// },
+// [setContext, setIsContextSelected]
+// );
+// return (
+//
+//
+//
+// {title}
+// {closeIcon && (
+//
+//
+//
+// )}
+//
+//
+//
+//
+//
+//
+// {generateOverlay()}
+//
+
+// {/* these two grid items are for the card details */}
+//
+// }
+// title="Description"
+// value={card?.desc}
+// isTextSection={true}
+// titles={['Description', 'Price', 'Rarity', 'Card Sets']}
+// />
+//
+//
+//
+//
+//
+//
+// Inventory
+//
+//
+//
+// {/* */}
+// {'Cart'}
+// {'Deck'}
+// {'Collection'}
+//
+//
+//
+//
+//
+// {['Deck', 'Collection', 'Cart'].map((mappedContext) => (
+// handleContextSelect(mappedContext)}
+// onSuccess={() =>
+// handleAction(
+// {
+// title: 'Action successful',
+// message: `Card added to ${mappedContext} successfully.`,
+// },
+// 'success'
+// )
+// }
+// onFailure={(error) =>
+// handleAction(
+// {
+// title: 'Action failed',
+// message: `Failed to add card to ${mappedContext}.`,
+// },
+// 'error',
+// error
+// )
+// }
+// />
+// ))}
+//
+//
+//
+//
+//
+//
+//
+// );
+// };
+
+// export default GenericCardDialog;
+import React, { useCallback, useEffect, useState } from 'react';
+import {
+ Dialog,
+ IconButton,
+ Slide,
+ Fade,
+ Typography,
+ Card,
+ CardHeader,
+ List,
+ ListItem,
+ CardContent,
+ useMediaQuery,
+ useTheme,
+ Grid,
+} from '@mui/material';
+import CloseIcon from '@mui/icons-material/Close';
+import CardMediaSection from '../cards/CardMediaSection';
+import GenericActionButtons from '../buttons/actionButtons/GenericActionButtons';
+import CardDetailsContainer from '../cards/CardDetailsContainer';
+import { useSelectedContext, useModalContext, useMode } from '../../context';
+import { useSnackbar } from 'notistack';
+import FlexBetween from '../../layout/REUSABLE_COMPONENTS/FlexBetween';
+
+const GenericCardDialog = ({
+ open = false,
+ transition = false,
+ onClose,
+ title = '',
+ card,
+ context,
+ ...otherProps
+}) => {
+ const { theme } = useMode();
+ const fullScreen = useMediaQuery(theme.breakpoints.down('md'));
+ const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
+
+ const { closeModal } = useModalContext();
+ const { enqueueSnackbar } = useSnackbar(); // Assuming useOverlay has enqueueSnackbar method
+ const [imageUrl, setImageUrl] = useState(card?.card_images[0]?.image_url);
+
+ // Snackbar handlers (simplified for this example)
+ const handleAction = useCallback(
+ (message, variant) => {
+ enqueueSnackbar(message, { variant });
+ },
+ [enqueueSnackbar]
+ );
+
+ useEffect(() => {
+ if (open && card) {
+ handleAction('Card details loaded successfully.', 'success');
+ }
+ }, [open, card, handleAction]);
+
+ const handleContextSelect = useCallback(
+ (newContext) => {
+ // Context selection handling logic here
+ handleAction(`Card added to ${newContext} successfully.`, 'success');
+ },
+ [handleAction]
+ );
+
+ return (
+
+ );
+};
+
+export default GenericCardDialog;
diff --git a/src/components/dialogs/LoginDialog.jsx b/src/components/dialogs/LoginDialog.jsx
index 7649763..d4f90c0 100644
--- a/src/components/dialogs/LoginDialog.jsx
+++ b/src/components/dialogs/LoginDialog.jsx
@@ -9,40 +9,25 @@ import {
DialogContent,
DialogTitle,
Divider,
- FormControl,
FormControlLabel,
- Grid,
- IconButton,
- Link,
- Paper,
- Switch,
Typography,
- useMediaQuery,
} from '@mui/material';
-import Brightness4Icon from '@mui/icons-material/Brightness4';
-import Brightness7Icon from '@mui/icons-material/Brightness7';
import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
-import { withDynamicSnackbar } from '../../layout/REUSABLE_COMPONENTS/HOC/DynamicSnackbar'; // Adjust import paths as necessary
-import LoginForm from '../forms/LoginForm';
-import SignupForm from '../forms/SignupForm';
import { useFormContext, useMode } from '../../context';
import useAuthDialog from '../../context/hooks/useAuthDialog'; // Adjust import paths as necessary
import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
import MDTypography from '../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
import {
- DialogContentsBox,
- DialogPaer,
DialogPaper,
- FormPaper,
StyledDialog,
StyledDialogContent,
} from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
import MDAvatar from '../../layout/REUSABLE_COMPONENTS/MDAVATAR';
-import { AuthModeSwitch } from '../../layout/REUSABLE_STYLED_COMPONENTS/SpecificStyledComponents';
-import AuthSwitch from '../buttons/other/AuthSwitch';
-import SimpleButton from '../../layout/REUSABLE_COMPONENTS/unique/SimpleButton';
-
-function LoginDialog({ showSnackbar }) {
+import RCSwitch from '../forms/reusable/RCSwitch';
+import LoginIcon from '@mui/icons-material/Login';
+import PersonAddIcon from '@mui/icons-material/PersonAdd';
+import AuthForm from '../forms/AuthForm';
+function LoginDialog() {
const { theme, toggleColorMode, mode } = useMode();
const { toggleLoginDialog, isLoggedIn, logout } = useAuthDialog();
// const { currentForm, setFormSchema } = useFormContext();
@@ -64,6 +49,11 @@ function LoginDialog({ showSnackbar }) {
logout();
toggleLoginDialog();
};
+ const handleToggle = () => {
+ setFormSchema(
+ currentSchemaKey === 'loginForm' ? 'signupForm' : 'loginForm'
+ );
+ };
const formTitle = currentSchemaKey === 'loginForm' ? 'Login' : 'Sign Up';
const signupMode = currentSchemaKey === 'signupForm';
@@ -118,40 +108,31 @@ function LoginDialog({ showSnackbar }) {
>
-
+
{formTitle}
- {/* */}
-
- {/* */}
+ {/* */}
+ }
+ iconRight={}
+ />
- {currentSchemaKey === 'loginForm' ? (
-
+
+ {/* {currentSchemaKey === 'loginForm' ? (
+
) : (
-
- )}
- {/* */}
+
+ )} */}
}
label="Remember me"
@@ -177,4 +158,4 @@ function LoginDialog({ showSnackbar }) {
);
}
-export default withDynamicSnackbar(LoginDialog);
+export default LoginDialog;
diff --git a/src/components/dialogs/SelectionErrorDialog.jsx b/src/components/dialogs/SelectionErrorDialog.jsx
index 7b1e736..3388952 100644
--- a/src/components/dialogs/SelectionErrorDialog.jsx
+++ b/src/components/dialogs/SelectionErrorDialog.jsx
@@ -13,51 +13,33 @@ import PersonIcon from '@mui/icons-material/Person';
import AddIcon from '@mui/icons-material/Add';
import Typography from '@mui/material/Typography';
import { blue } from '@mui/material/colors';
-import { withDynamicSnackbar } from '../../layout/REUSABLE_COMPONENTS/HOC/DynamicSnackbar';
import useSelectedCollection from '../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
import { DialogContent, Slide } from '@mui/material';
+import useSnackbarManager from '../../context/hooks/useSnackbarManager';
const Transition = React.forwardRef(function Transition(props, ref) {
return ;
});
function SelectionErrorDialog(props) {
- const { onClose, selectedValue, open, showSnackbar } = props;
- const {
- handleBackToCollections,
- showCollections,
- allCollections,
- handleSelectCollection,
- } = useSelectedCollection();
+ const { onClose, selectedValue, open } = props;
+ const { allCollections } = useSelectedCollection();
+ const { showSuccess, showError, showInfo } = useSnackbarManager(); // Using custom snackbar hook
+
const handleClose = () => {
onClose(selectedValue);
};
- // const handleListItemClick = (value) => {
- // if (typeof value?._id === 'string') {
- // showSnackbar('Not implemented yet', 'successs');
- // } else {
- // showSnackbar(`${value} selected as backup account`, 'success');
- // }
- // onClose(value);
- // };
const handleListItemClick = React.useCallback(
(collection) => {
if (collection._id) {
- showSnackbar('Not implemented yet', 'info'); // Assuming 'successs' was a typo, corrected to 'info' for a non-implemented feature
+ showInfo('Not implemented yet'); // Show an informational snackbar
} else {
- showSnackbar(`${collection} selected as backup account`, 'success');
+ showSuccess(`${collection} selected as backup account`); // Show a success snackbar
}
onClose(collection);
},
- [onClose, showSnackbar]
- );
- const handleAction = React.useCallback(
- (message, severity, error) => {
- showSnackbar(message, severity);
- if (error) console.error('Action failed:', error);
- },
- [showSnackbar]
+ [onClose, showInfo, showSuccess]
);
return (
@@ -87,40 +69,6 @@ function SelectionErrorDialog(props) {
))}
-
- handleListItemClick(collection)}
- // onClick={() => handleContextSelect(mappedContext)}
- onSuccess={() =>
- handleAction(
- {
- title: 'Action successful',
- message: `Card added to ${selectedValue} successfully.`,
- },
- 'success',
- null
- )
- }
- onFailure={(error) =>
- handleAction(
- {
- title: 'Action failed',
- message: `Failed to add card to ${selectedValue}.`,
- },
- 'error',
- error
- )
- }
- >
-
-
-
-
-
-
-
-
@@ -130,7 +78,7 @@ function SelectionErrorDialog(props) {
SelectionErrorDialog.propTypes = {
onClose: PropTypes.func.isRequired,
open: PropTypes.bool.isRequired,
- selectedValue: PropTypes.string.isRequired,
+ selectedValue: PropTypes.string,
};
-export default withDynamicSnackbar(SelectionErrorDialog);
+export default SelectionErrorDialog;
diff --git a/src/components/dialogs/stripeModal/StripeCheckoutModal.js b/src/components/dialogs/StripeCheckoutModal.js
similarity index 96%
rename from src/components/dialogs/stripeModal/StripeCheckoutModal.js
rename to src/components/dialogs/StripeCheckoutModal.js
index ab582fc..a6722ad 100644
--- a/src/components/dialogs/stripeModal/StripeCheckoutModal.js
+++ b/src/components/dialogs/StripeCheckoutModal.js
@@ -1,7 +1,7 @@
import React from 'react';
import { Modal, Fade, Box, Typography, Backdrop } from '@mui/material';
import { Elements } from '@stripe/react-stripe-js';
-import StripeForm from '../../forms/customerCheckoutForm/StripeForm';
+import StripeForm from '../forms/customerCheckoutForm/StripeForm';
import { loadStripe } from '@stripe/stripe-js';
const stripePromise = loadStripe(process.env.REACT_APP_STRIPE_PUBLISHABLE_KEY);
diff --git a/src/components/dialogs/cardDialog/GenericCardDialog.jsx b/src/components/dialogs/cardDialog/GenericCardDialog.jsx
deleted file mode 100644
index a0a0146..0000000
--- a/src/components/dialogs/cardDialog/GenericCardDialog.jsx
+++ /dev/null
@@ -1,230 +0,0 @@
-import React, { useCallback, useEffect, useState } from 'react';
-import {
- Dialog,
- DialogTitle,
- DialogContent,
- Snackbar,
- Alert,
- Grid,
- Container,
- useMediaQuery,
- Slide,
- Fade,
- IconButton,
- Stack,
- Typography,
- Card,
- CardHeader,
- List,
- CardContent,
- ListItem,
- Backdrop,
-} from '@mui/material';
-import useSnackbar from '../../../context/hooks/useSnackBar';
-import useSelectedContext from '../../../context/hooks/useSelectedContext';
-import { useModalContext, useMode } from '../../../context';
-import CardMediaSection from '../../cards/media/CardMediaSection';
-import GenericActionButtons from '../../buttons/actionButtons/GenericActionButtons';
-import CloseIcon from '@mui/icons-material/Close';
-import CardDetail from '../../cards/CardDetail';
-import { useOverlay } from '../../../context/hooks/useOverlay';
-import CardDetailsContainer from '../../cards/CardDetailsContainer';
-import { enqueueSnackbar } from 'notistack';
-import { DialogPaper } from '../../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
-
-const GenericCardDialog = (props) => {
- const { theme } = useMode();
- const { generateOverlay, handleRarityClick, openOverlay, closeOverlay } =
- useOverlay(theme);
- const {
- open = false,
- transition = false,
- close,
- hideBackdrop = false,
- title = '',
- content = '',
- actions = '',
- dividers = false,
- closeIcon = true,
- // fullScreen = false,
- actionPosition = 'left',
- closeIconSx = {
- position: 'absolute',
- right: 8,
- top: 8,
- color: (theme) => theme.palette.grey[500],
- },
- card,
- context,
- ...other
- } = props || {};
- const fullScreen = useMediaQuery(theme.breakpoints.down('md'));
- const { closeModal } = useModalContext();
- const [imageUrl, setImageUrl] = useState(card?.card_images[0]?.image_url);
- // const { handleSnackBar, handleCloseSnackbar } = useSnackbar();
- const [hasLoggedCard, setHasLoggedCard] = useState(false);
- const { setContext, setIsContextSelected } = useSelectedContext();
- const handleAction = useCallback(
- (message, severity, error) => {
- enqueueSnackbar(message, severity);
- if (error) console.error('Action failed:', error);
- },
- [enqueueSnackbar]
- );
- useEffect(() => {
- if (open && card && !hasLoggedCard) {
- enqueueSnackbar('Card details loaded successfully.', 'success');
- setHasLoggedCard(true);
- }
- return () => {
- if (!open) setHasLoggedCard(false);
- };
- }, [open, card, enqueueSnackbar, hasLoggedCard]);
- // Context selection handling
- const handleContextSelect = useCallback(
- (newContext) => {
- setContext(newContext);
- setIsContextSelected(true);
- },
- [setContext, setIsContextSelected]
- );
- return (
-
- );
-};
-
-export default GenericCardDialog;
diff --git a/src/components/forms/AddCollectionForm.jsx b/src/components/forms/AddCollectionForm.jsx
deleted file mode 100644
index b64b9d8..0000000
--- a/src/components/forms/AddCollectionForm.jsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import React from 'react';
-import { Box } from '@mui/material';
-import FormField from './reusable/FormField';
-import { LoadingButton } from '@mui/lab';
-import { useFormContext, useMode } from '../../context';
-import { withDynamicSnackbar } from '../../layout/REUSABLE_COMPONENTS/HOC/DynamicSnackbar';
-import { useForm } from 'react-hook-form';
-import { zodResolver } from '@hookform/resolvers/zod';
-import {
- formSchemas,
- getDefaultValuesFromSchema,
-} from '../../context/UTILITIES_CONTEXT/FormContext/schemas';
-import {
- FormBox,
- FormFieldBox,
-} from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
-
-const AddCollectionForm = ({ showSnackbar }) => {
- const formId = 'addCollectionForm';
- const { onSubmit } = useFormContext();
- const { theme } = useMode();
- const {
- register,
- handleSubmit,
- formState: { errors, isSubmitting },
- } = useForm({
- resolver: zodResolver(formSchemas.addCollectionForm),
- defaultValues: getDefaultValuesFromSchema(formSchemas.addCollectionForm),
- });
-
- const fields = [
- { name: 'name', label: 'Name', type: 'text' },
- { name: 'description', label: 'Description', type: 'text' },
- ];
- const onFormSubmit = async (data) => {
- try {
- // Simulate form submission
- await new Promise((resolve) => setTimeout(resolve, 2000)); // Simulated delay
- onSubmit(data, formId);
- showSnackbar(
- {
- title: 'Success',
- description: "You've successfully added a new collection.",
- },
- 'success'
- ); // Adjust message as needed
- } catch (error) {
- // On error:
- showSnackbar(
- {
- title: 'Error',
- description: 'Failed to add collection. Please try again.',
- },
- 'error'
- ); // Adjust message as needed
- }
- };
- return (
-
-
-
-
-
-
-
-
- Create Collection
-
-
- );
-};
-
-export default withDynamicSnackbar(AddCollectionForm);
diff --git a/src/components/forms/AddDeckForm.jsx b/src/components/forms/AddDeckForm.jsx
deleted file mode 100644
index fea3735..0000000
--- a/src/components/forms/AddDeckForm.jsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import React from 'react';
-import { useFormContext } from '../../context';
-import FormField from '../reusable/FormField';
-import { Button, Paper, Typography, Box } from '@mui/material';
-import SaveIcon from '@mui/icons-material/Save';
-import { withDynamicSnackbar } from '../../layout/REUSABLE_COMPONENTS/HOC/DynamicSnackbar';
-
-const AddDeckForm = ({ showSnackbar }) => {
- const { formStates, onSubmit } = useFormContext();
- const formId = 'addDeckForm'; // Assuming this is the formId for creating decks
-
- const {
- register,
- handleSubmit,
- formState: { errors, isSubmitting },
- } = formStates[formId];
-
- const onFormSubmit = async (data) => {
- try {
- await onSubmit(data, formId);
- showSnackbar(
- {
- title: 'Success',
- description: 'Deck created successfully.',
- },
- 'success'
- );
- } catch (error) {
- showSnackbar(
- {
- title: 'Error',
- description: 'Failed to create deck. Please try again.',
- },
- 'error'
- );
- }
- };
-
- return (
-
- Create Deck
-
-
- );
-};
-export default withDynamicSnackbar(AddDeckForm); // Wrap DeckEditPanel with withDynamicSnackbar HOC
diff --git a/src/components/forms/AuthForm.jsx b/src/components/forms/AuthForm.jsx
new file mode 100644
index 0000000..b089af4
--- /dev/null
+++ b/src/components/forms/AuthForm.jsx
@@ -0,0 +1,67 @@
+import React from 'react';
+import PersonAddIcon from '@mui/icons-material/PersonAdd';
+import PersonIcon from '@mui/icons-material/Person';
+import EmailIcon from '@mui/icons-material/Email';
+import LockIcon from '@mui/icons-material/Lock';
+import RCZodForm from './reusable/RCZodForm';
+import LoginIcon from '@mui/icons-material/Login';
+
+const loginFields = [
+ {
+ name: 'username',
+ label: 'Username',
+ type: 'text',
+ icon: ,
+ field: 'username',
+ },
+ {
+ name: 'password',
+ label: 'Password',
+ type: 'password',
+ icon: ,
+ field: 'password',
+ },
+];
+const signupFields = [
+ {
+ name: 'firstName',
+ label: 'First Name',
+ type: 'text',
+ icon: ,
+ field: 'firstName',
+ },
+ {
+ name: 'lastName',
+ label: 'Last Name',
+ type: 'text',
+ icon: ,
+ field: 'lastName',
+ },
+ {
+ name: 'email',
+ label: 'Email',
+ type: 'email',
+ icon: ,
+ field: 'email',
+ },
+];
+
+const AuthForm = ({ formType }) => {
+ // Combine forms to make signup forms
+ const combinedFields = [...signupFields, ...loginFields];
+ const isSignup = formType === 'signupForm';
+ const fields = isSignup ? combinedFields : loginFields;
+ const buttonLabel = isSignup ? 'Sign Up' : 'Login';
+ const startIcon = isSignup ? : ;
+
+ return (
+
+ );
+};
+
+export default AuthForm;
diff --git a/src/components/forms/CollectionForm.jsx b/src/components/forms/CollectionForm.jsx
new file mode 100644
index 0000000..b139f7d
--- /dev/null
+++ b/src/components/forms/CollectionForm.jsx
@@ -0,0 +1,71 @@
+import React, { useEffect } from 'react';
+import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline';
+import { useFormContext, useMode } from '../../context';
+import useSnackbarManager from '../../context/hooks/useSnackbarManager';
+import RCZodForm from './reusable/RCZodForm';
+
+// Common fields structure used in both add and update forms
+const collectionFields = [
+ {
+ name: 'name',
+ label: 'Name',
+ type: 'text',
+ required: true,
+ },
+ {
+ name: 'description',
+ label: 'Description',
+ type: 'text',
+ required: true,
+ multiline: true,
+ rows: 4,
+ },
+];
+
+const CollectionForm = ({ collectionData, actionType }) => {
+ const { setFormSchema, onSubmit } = useFormContext();
+ const { theme } = useMode();
+ // const { showSuccess, showError } = useSnackbarManager();
+
+ // Determine the schema name and button label based on the action type
+ const schemaName =
+ actionType === 'add' ? 'addCollectionForm' : 'updateCollectionForm';
+ const buttonLabel =
+ actionType === 'add' ? 'Create Collection' : 'Update Collection';
+ const startIcon =
+ actionType === 'add' ? : ;
+
+ // useEffect(() => {
+ // if (collectionData && actionType === 'update') {
+ // setFormSchema(schemaName, collectionData);
+ // }
+ // }, [collectionData, setFormSchema, schemaName, actionType]);
+
+ // const handleFormSubmit = async (data) => {
+ // const method = actionType === 'add' ? 'Add' : 'Update';
+ // try {
+ // await onSubmit(data, schemaName, collectionData?._id);
+ // showSuccess(
+ // `You've successfully ${method.toLowerCase()}ed the collection.`
+ // );
+ // } catch (error) {
+ // showError(
+ // `Failed to ${method.toLowerCase()} collection. Please try again.`
+ // );
+ // }
+ // };
+
+ return (
+
+ );
+};
+
+export default CollectionForm;
diff --git a/src/components/forms/CustomSelector.js b/src/components/forms/CustomSelector.js
deleted file mode 100644
index bc9e771..0000000
--- a/src/components/forms/CustomSelector.js
+++ /dev/null
@@ -1,93 +0,0 @@
-// import React from 'react';
-// import { useTheme } from '@mui/material/styles';
-// import OutlinedInput from '@mui/material/OutlinedInput';
-// import MenuItem from '@mui/material/MenuItem';
-// import FormControl from '@mui/material/FormControl';
-// import Select from '@mui/material/Select';
-// import PropTypes from 'prop-types';
-
-// const ITEM_HEIGHT = 48;
-// const ITEM_PADDING_TOP = 8;
-// const MenuProps = {
-// PaperProps: {
-// style: {
-// maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
-// width: 250,
-// },
-// },
-// };
-
-// function getStyles(name, selected, theme) {
-// return {
-// fontWeight:
-// selected.indexOf(name) === -1
-// ? theme.typography.fontWeightRegular
-// : theme.typography.fontWeightMedium,
-// };
-// }
-
-// const CustomMultipleSelect = ({
-// items,
-// selectedItems,
-// onChange,
-// placeholder,
-// label,
-// }) => {
-// const theme = useTheme();
-
-// const handleChange = (event) => {
-// const {
-// target: { value },
-// } = event;
-// onChange(typeof value === 'string' ? value.split(',') : value);
-// };
-
-// return (
-//
-// }
-// renderValue={(selected) => {
-// if (selected.length === 0) {
-// return {placeholder};
-// }
-
-// return selected.join(', ');
-// }}
-// MenuProps={MenuProps}
-// inputProps={{ 'aria-label': label }}
-// >
-//
-// {items.map((name) => (
-//
-// ))}
-//
-//
-// );
-// };
-
-// CustomMultipleSelect.propTypes = {
-// items: PropTypes.arrayOf(PropTypes.string).isRequired,
-// selectedItems: PropTypes.arrayOf(PropTypes.string).isRequired,
-// onChange: PropTypes.func.isRequired,
-// placeholder: PropTypes.string,
-// label: PropTypes.string,
-// };
-
-// CustomMultipleSelect.defaultProps = {
-// placeholder: 'Select items',
-// label: 'Custom select',
-// };
-
-// export default CustomMultipleSelect;
diff --git a/src/components/forms/DeckForm.jsx b/src/components/forms/DeckForm.jsx
new file mode 100644
index 0000000..7370632
--- /dev/null
+++ b/src/components/forms/DeckForm.jsx
@@ -0,0 +1,144 @@
+import React, { useEffect, useState } from 'react';
+import SaveIcon from '@mui/icons-material/Save';
+import DeleteIcon from '@mui/icons-material/Delete';
+import { useFormContext } from '../../context';
+import RCZodForm from './reusable/RCZodForm';
+
+const DeckForm = ({ actionType, deckData }) => {
+ const { onSubmit, setFormSchema, formMethods } = useFormContext();
+ const isUpdateMode = actionType === 'update';
+ const [tags, setTags] = useState(deckData?.tags || []);
+
+ useEffect(() => {
+ setFormSchema('updateDeckForm');
+ if (deckData) {
+ console.log('deckData:', deckData);
+ formMethods.reset({
+ ...deckData,
+ tags: deckData?.tags?.join(', '),
+ color: deckData?.color || 'red',
+ });
+ }
+ }, [deckData, setFormSchema, formMethods]);
+
+ const handleAddTag = (tag) => {
+ if (tag && !tags.includes(tag)) {
+ setTags([...tags, tag]);
+ formMethods.setValue('tags', [...tags, tag].join(', '));
+ }
+ };
+
+ const handleDeleteTag = (tagToDelete) => {
+ const updatedTags = tags.filter((tag) => tag !== tagToDelete);
+ setTags(updatedTags);
+ formMethods.setValue('tags', updatedTags.join(', '));
+ };
+ const updateDeckFields = [
+ { name: 'name', label: 'Name', type: 'text', icon: null, required: true },
+ {
+ name: 'description',
+ label: 'Description',
+ type: 'text',
+ multiline: true,
+ rows: 4,
+ icon: null,
+ required: false,
+ },
+ {
+ name: 'tags',
+ label: 'Tags',
+ type: 'chips',
+ chipData: tags,
+ icon: null,
+ onAddChip: handleAddTag,
+ onDeleteChip: handleDeleteTag,
+ required: false,
+ },
+ {
+ name: 'color',
+ label: 'Color',
+ type: 'select',
+ icon: null,
+ required: false,
+ options: [
+ { value: 'red', label: 'Red' },
+ { value: 'blue', label: 'Blue' },
+ { value: 'green', label: 'Green' },
+ { value: 'yellow', label: 'Yellow' },
+ { value: 'purple', label: 'Purple' },
+ { value: 'pink', label: 'Pink' },
+ { value: 'orange', label: 'Orange' },
+ { value: 'teal', label: 'Teal' },
+ ],
+ },
+ ];
+
+ const addDeckFields = [
+ { name: 'name', label: 'Name', type: 'text', icon: null, required: true },
+ {
+ name: 'description',
+ label: 'Description',
+ type: 'text',
+ multiline: true,
+ rows: 4,
+ icon: null,
+ required: false,
+ },
+ ];
+
+ const formId = isUpdateMode ? 'updateDeckForm' : 'addDeckForm';
+ const fields = isUpdateMode ? updateDeckFields : addDeckFields;
+
+ React.useEffect(() => {
+ if (!isUpdateMode) {
+ setFormSchema(formId);
+ }
+ }, [setFormSchema, formId, isUpdateMode]);
+
+ const handleSubmit = (data) => {
+ if (isUpdateMode) {
+ console.log('Submitting update deck data:', data);
+ onSubmit(data);
+ } else {
+ console.log('Add Deck Data:', data);
+ onSubmit(data);
+ }
+ };
+
+ const handleDelete = () => {
+ if (isUpdateMode) {
+ console.log('Deleting deck:', deckData._id);
+ onSubmit({ _id: deckData._id, delete: true }, formId);
+ }
+ };
+
+ return (
+ }
+ initialValues={deckData}
+ additionalData={{
+ deckId: deckData ? deckData?._id : null,
+ }}
+ additionalButtons={
+ isUpdateMode
+ ? [
+ {
+ label: 'Delete Deck',
+ onClick: handleDelete,
+ startIcon: ,
+ color: 'error',
+ variant: 'contained',
+ disabled: !deckData,
+ },
+ ]
+ : []
+ }
+ defaultValues={isUpdateMode ? deckData : {}}
+ />
+ );
+};
+
+export default DeckForm;
diff --git a/src/components/forms/LoginForm.jsx b/src/components/forms/LoginForm.jsx
deleted file mode 100644
index 06fcbe1..0000000
--- a/src/components/forms/LoginForm.jsx
+++ /dev/null
@@ -1,152 +0,0 @@
-import React, { useEffect } from 'react';
-import {
- Box,
- Checkbox,
- FormControlLabel,
- Grid,
- InputAdornment,
- Link,
-} from '@mui/material';
-import FormField from './reusable/FormField';
-import { LoadingButton } from '@mui/lab';
-import { useFormContext, useMode } from '../../context';
-import { withDynamicSnackbar } from '../../layout/REUSABLE_COMPONENTS/HOC/DynamicSnackbar';
-import { CopyrightOutlined } from '@mui/icons-material';
-import LockOutlinedIcon from '@material-ui/icons/LockOutlined';
-import AuthSwitch from '../buttons/other/AuthSwitch';
-import LoginIcon from '@mui/icons-material/Login';
-import PersonIcon from '@mui/icons-material/Person';
-import LockIcon from '@mui/icons-material/Lock';
-import {
- FormBox,
- FormFieldBox,
-} from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
-import SimpleButton from '../../layout/REUSABLE_COMPONENTS/unique/SimpleButton';
-const baseButtonStyles = {
- bgcolor: '#6a59ff', // background-color
- borderColor: '#6a59ff',
- borderWidth: 2,
- borderStyle: 'solid',
- display: 'flex',
- flexGrow: 1,
- alignItems: 'center',
- justifyContent: 'center',
- marginLeft: 'auto',
- marginRight: 'auto',
- marginBottom: '16px',
- marginTop: '16px',
- position: 'relative',
- bottom: 0,
- cursor: 'pointer',
- transition: 'background-color 0.3s, border-color 0.3s, color 0.3s',
- ':hover': {
- fontWeight: 'bold',
- bgcolor: '#4a6da7',
- borderColor: '#34597f',
- },
- ':focus': {
- outline: '2px solid #62a4ff',
- outlineOffset: 2,
- },
-};
-const LoginForm = ({ showSnackbar, signupMode, toggleAuthMode, formLabel }) => {
- const { formMethods, onSubmit, setFormSchema } = useFormContext();
- const { theme } = useMode();
- const {
- register,
- handleSubmit,
- formState: { errors, isSubmitting },
- } = formMethods;
-
- useEffect(() => {
- setFormSchema('loginForm');
- }, [setFormSchema]);
- const fields = [
- {
- name: 'username',
- label: 'Username',
- type: 'text',
- icon: ,
- },
- {
- name: 'password',
- label: 'Password',
- type: 'password',
- icon: ,
- },
- ];
-
- const onFormSubmit = (data) => {
- onSubmit(data, 'loginForm')
- .then(() => {
- showSnackbar(
- { title: 'Success', description: "You've successfully logged in." },
- 'success'
- );
- })
- .catch((error) => {
- showSnackbar(
- { title: 'Error', description: 'Login failed. Please try again.' },
- 'error'
- );
- });
- };
- return (
-
- {fields.map((field, index) => (
-
- {field.icon}
- ),
- }}
- />
- {errors[field.name] && (
- {errors[field.name].message}
- )}
-
- ))}
- {/* */}
- }
- fullWidth
- sx={{
- background: theme.palette.backgroundG.light,
- borderColor: theme.palette.backgroundG.light,
- borderWidth: 2,
- '&:hover': { background: theme.palette.backgroundG.default },
- '&:focus': { background: theme.palette.backgroundG.default },
- }}
- >
- Login
-
-
- );
-};
-
-export default withDynamicSnackbar(LoginForm);
diff --git a/src/components/forms/OptionsComponent.jsx b/src/components/forms/OptionsComponent.jsx
new file mode 100644
index 0000000..662faef
--- /dev/null
+++ b/src/components/forms/OptionsComponent.jsx
@@ -0,0 +1,140 @@
+// OptionsComponent.jsx
+import React, { useEffect } from 'react';
+import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
+import { Autocomplete, Grid, TextField } from '@mui/material';
+import {
+ FormBox,
+ FormFieldBox,
+} from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
+import FormField from './reusable/FormField';
+import { useFormContext, useMode } from '../../context';
+import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline';
+
+const OptionsComponent = ({
+ canSearch,
+ search,
+ handleSearchChange,
+ pageSize,
+ setPageSize,
+ pageOptions,
+ // schemaName,
+}) => {
+ const { theme } = useMode();
+ const schemaName = 'collectionSearchForm';
+ const buttonLabel = 'Search';
+ const startIcon = ;
+ const collectionSearchFields = [
+ {
+ name: 'searchTerm',
+ label: 'Search',
+ type: 'text',
+ required: true,
+ value: search,
+ },
+ ];
+ const {
+ formMethods,
+ onSubmit,
+ handleChange,
+ setFormSchema,
+ formState: { errors, isSubmitting },
+ // getValues,
+ handleSearchTermChange,
+ } = useFormContext();
+
+ useEffect(() => {
+ setFormSchema(schemaName);
+ }, [setFormSchema, schemaName]);
+
+ const onFormSubmit = (data) => {
+ onSubmit(data, schemaName);
+ };
+ return (
+
+
+ {canSearch && (
+
+
+
+ )}
+
+ setPageSize(parseInt(newValue, 10))}
+ options={pageOptions?.map((option) => option.toString())}
+ renderInput={(params) => (
+
+ )}
+ />
+
+
+
+ );
+};
+
+export default OptionsComponent;
diff --git a/src/components/forms/ProfileForm.jsx b/src/components/forms/ProfileForm.jsx
deleted file mode 100644
index 60791ca..0000000
--- a/src/components/forms/ProfileForm.jsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import React, { useState, useEffect } from 'react';
-import PropTypes from 'prop-types';
-import { TextField, Button } from '@mui/material';
-import { useFormContext } from '../../context';
-import FormField from './reusable/FormField';
-
-const ProfileForm = ({ userName, name, age, status, onSave }) => {
- const { forms, handleChange, handleSubmit } = useFormContext();
- const profileValues = forms?.updateUserDataForm || {};
- const formType = 'updateUserDataForm';
- const handleFormSubmit = (event) => {
- event.preventDefault(); // Prevent the default form submission behavior
- handleSubmit(formType)(event); // Pass the event to your form handler
- };
-
- return (
-
- );
-};
-
-ProfileForm.propTypes = {
- username: PropTypes.string,
- firstName: PropTypes.string,
- lastName: PropTypes.string,
-
- age: PropTypes.string,
- status: PropTypes.string,
- onSave: PropTypes.func.isRequired,
-};
-
-export default ProfileForm;
diff --git a/src/components/forms/SearchForm.jsx b/src/components/forms/SearchForm.jsx
index 2902961..445eecb 100644
--- a/src/components/forms/SearchForm.jsx
+++ b/src/components/forms/SearchForm.jsx
@@ -1,103 +1,32 @@
-import React, { useCallback, useEffect } from 'react';
-import { Button, Grid } from '@mui/material';
-import { useFormContext, useMode, usePageContext } from '../../context';
-import {
- StyledFormBox,
- StyledFormPaper,
-} from '../../pages/pageStyles/StyledComponents';
-import { FormBox } from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
-import { LoadingButton } from '@mui/lab';
-import FormField from './reusable/FormField';
+import React from 'react';
+import SearchIcon from '@mui/icons-material/Search';
+import RCZodForm from './reusable/RCZodForm';
+import { useFormContext } from '../../context';
-const SearchForm = ({ onFocus, onBlur }) => {
- const { theme } = useMode();
- const formId = 'searchForm'; // Define the form ID for schema selection
- const {
- formMethods,
- formStates: { errors, isSubmitting, ...formStates },
- onSubmit,
- handleFieldChange,
- handleSearchTermChange,
- // handleChange,
- handleBlur,
- handleFocus,
- forms,
- handleChange,
- setFormSchema,
- } = useFormContext();
-
- useEffect(() => {
- setFormSchema(formId);
- }, [setFormSchema]);
-
- // const handleChange = (e) => {
- // const { name, value } = e.target;
- // if (name === 'searchTerm') {
- // handleSearchTermChange(value); // Call the method when searchTerm changes
- // }
- // handleFieldChange(formId, name, value); // Continue to update the form state as before
- // };
-
- // const { searchTerm } = formStates?.searchForm;
- const handleKeyPress = (e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
- formMethods.handleSubmit((data) => {
- onSubmit(data);
- });
- }
- };
+const SearchForm = () => {
+ const { formMethods, formStates } = useFormContext();
+ const { forms } = formStates;
+ const { handleChange, handleFocus, handleBlur } = formMethods;
+ const searchFields = [
+ {
+ name: 'searchTerm',
+ label: 'Search for cards',
+ type: 'text',
+ required: false,
+ value: forms?.searchForm?.searchTerm || '',
+ onChange: handleChange,
+ onFocus: handleFocus,
+ onBlur: handleBlur,
+ },
+ ];
return (
-
-
- onSubmit(data, 'searchForm')
- )}
- >
-
- {errors?.searchTerm && (
-
- {errors?.searchTerm?.message}
-
- )}
-
- {isSubmitting ? 'Loading...' : 'Search'}
-
- {errors?.root && {errors?.root?.message}
}
-
-
+ }
+ />
);
};
diff --git a/src/components/forms/SignupForm.jsx b/src/components/forms/SignupForm.jsx
deleted file mode 100644
index 3e6e74f..0000000
--- a/src/components/forms/SignupForm.jsx
+++ /dev/null
@@ -1,168 +0,0 @@
-import React, { useEffect } from 'react';
-import { Box, Button } from '@mui/material';
-import FormField from './reusable/FormField';
-import { useForm } from 'react-hook-form';
-import { zodResolver } from '@hookform/resolvers/zod';
-import {
- formSchemas,
- getDefaultValuesFromSchema,
-} from '../../context/UTILITIES_CONTEXT/FormContext/schemas'; // Ensure this path is correct
-import { LoadingButton } from '@mui/lab';
-import { useFormContext, useMode, usePageContext } from '../../context';
-import { withDynamicSnackbar } from '../../layout/REUSABLE_COMPONENTS/HOC/DynamicSnackbar';
-import AuthSwitch from '../buttons/other/AuthSwitch';
-import PersonAddIcon from '@mui/icons-material/PersonAdd';
-
-import {
- FormBox,
- FormFieldBox,
-} from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
-const baseButtonStyles = {
- bgcolor: '#6a59ff', // background-color
- borderColor: '#6a59ff',
- borderWidth: 2,
- borderStyle: 'solid',
- display: 'flex',
- flexGrow: 1,
- alignItems: 'center',
- justifyContent: 'center',
- marginLeft: 'auto',
- marginRight: 'auto',
- marginBottom: '16px',
- marginTop: '16px',
- position: 'relative',
- bottom: 0,
- cursor: 'pointer',
- transition: 'background-color 0.3s, border-color 0.3s, color 0.3s',
- ':hover': {
- fontWeight: 'bold',
- bgcolor: '#4a6da7',
- borderColor: '#34597f',
- },
- ':focus': {
- outline: '2px solid #62a4ff',
- outlineOffset: 2,
- },
-};
-const SignupForm = ({
- showSnackbar,
- signupMode,
- toggleAuthMode,
- formLabel,
-}) => {
- const { theme } = useMode();
- const { formMethods, onSubmit, setFormSchema } = useFormContext();
-
- const {
- register,
- handleSubmit,
- formState: { errors, isSubmitting },
- } = formMethods;
-
- useEffect(() => {
- setFormSchema('signupForm');
- }, [setFormSchema]);
- const fields = [
- { name: 'firstName', label: 'First Name', type: 'text' },
- { name: 'lastName', label: 'Last Name', type: 'text' },
- { name: 'email', label: 'Email', type: 'email' },
- { name: 'username', label: 'Username', type: 'text' },
- { name: 'password', label: 'Password', type: 'password' },
- ];
-
- // Updated onFormSubmit to directly use onSubmit from context
- const onFormSubmit = (data) => {
- onSubmit(data, 'signupForm')
- .then(() => {
- showSnackbar(
- { title: 'Success', description: "You've successfully signed up." },
- 'success'
- );
- })
- .catch((error) => {
- showSnackbar(
- { title: 'Error', description: 'Signup failed. Please try again.' },
- 'error'
- );
- });
- };
- // useEffect(() => {
- // setIsFormDataLoading(isSubmitting);
- // console.log('isSubmitting:', isSubmitting);
- // }, [isSubmitting, setIsFormDataLoading]);
- return (
-
- {fields.map((field, index) => (
-
-
-
- ))}
-
- {errors.form && (
- {errors.form.message}
- )}
-
- }
- fullWidth
- sx={{
- background: theme.palette.backgroundG.light,
- borderColor: theme.palette.backgroundG.light,
- borderWidth: 2,
- '&:hover': { background: theme.palette.backgroundG.default },
- '&:focus': { background: theme.palette.backgroundG.default },
- }}
- // type="submit"
- // variant="contained"
- // loading={isSubmitting}
- // onClick={() => handleSubmit(onFormSubmit)()}
- // color="primary"
- // sx={{
- // background: theme.palette.backgroundE.darker,
- // borderColor: theme.palette.backgroundB.darkest,
- // borderWidth: 2,
- // flexGrow: 1,
- // justifySelf: 'bottom',
- // bottom: 0,
- // mx: 'auto',
- // my: 2,
- // '&:hover': {
- // fontWeight: 'bold',
- // background: theme.palette.backgroundF.dark,
- // borderColor: theme.palette.backgroundB.darkest,
- // border: `1px solid ${theme.palette.backgroundB.darkest}`,
- // },
- // }}
- // fullWidth
- >
- Sign Up
-
-
- );
-};
-
-export default withDynamicSnackbar(SignupForm);
diff --git a/src/components/forms/UpdateCollectionForm.jsx b/src/components/forms/UpdateCollectionForm.jsx
deleted file mode 100644
index 80cfbc8..0000000
--- a/src/components/forms/UpdateCollectionForm.jsx
+++ /dev/null
@@ -1,116 +0,0 @@
-import React, { useEffect } from 'react';
-import { Box } from '@mui/material';
-import { LoadingButton } from '@mui/lab';
-import { useFormContext, useMode } from '../../context';
-import { withDynamicSnackbar } from '../../layout/REUSABLE_COMPONENTS/HOC/DynamicSnackbar';
-import { useForm } from 'react-hook-form';
-import { zodResolver } from '@hookform/resolvers/zod';
-import {
- formSchemas,
- getDefaultValuesFromSchema,
-} from '../../context/UTILITIES_CONTEXT/FormContext/schemas';
-import FormField from './reusable/FormField';
-import {
- FormBox,
- FormFieldBox,
-} from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
-
-const UpdateCollectionForm = ({ showSnackbar, collectionData }) => {
- const formId = 'updateCollectionForm';
- const { onSubmit } = useFormContext();
- const { theme } = useMode();
- const {
- register,
- handleSubmit,
- reset,
- formState: { errors, isSubmitting },
- } = useForm({
- resolver: zodResolver(formSchemas.updateCollectionForm),
- defaultValues:
- collectionData ||
- getDefaultValuesFromSchema(formSchemas.updateCollectionForm),
- });
-
- // Automatically reset form fields to the passed collection data
- React.useEffect(() => {
- reset(collectionData);
- }, [collectionData, reset]);
-
- const fields = [
- { name: 'name', label: 'Name', type: 'text' },
- { name: 'description', label: 'Description', type: 'text' },
- ];
-
- const onFormSubmit = async (data) => {
- try {
- // Simulate form submission
- await new Promise((resolve) => setTimeout(resolve, 2000)); // Simulated delay
-
- onSubmit(data, formId, collectionData._id); // Adjust to call the actual update function
-
- // On success:
- showSnackbar(
- {
- title: 'Success',
- description: "You've successfully updated the collection.",
- },
- 'success'
- );
- } catch (error) {
- // On error:
- showSnackbar(
- {
- title: 'Error',
- description: 'Failed to update collection. Please try again.',
- },
- 'error'
- );
- }
- };
-
- return (
-
-
-
-
-
-
-
-
- Update Collection
-
-
- );
-};
-
-export default withDynamicSnackbar(UpdateCollectionForm);
diff --git a/src/components/forms/UpdateDeckForm.jsx b/src/components/forms/UpdateDeckForm.jsx
deleted file mode 100644
index 4c8d719..0000000
--- a/src/components/forms/UpdateDeckForm.jsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import React, { useEffect } from 'react';
-import { useFormContext, useMode } from '../../context';
-import FormField from '../reusable/FormField';
-import { Button, Paper, Typography, Box } from '@mui/material';
-import SaveIcon from '@mui/icons-material/Save';
-import DeleteIcon from '@mui/icons-material/Delete';
-import { withDynamicSnackbar } from '../../layout/REUSABLE_COMPONENTS/HOC/DynamicSnackbar';
-import { FormBox } from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
-
-const UpdateDeckForm = ({ selectedDeck, showSnackbar }) => {
- const { theme } = useMode();
- const { formStates, onSubmit } = useFormContext();
- const formId = 'updateDeckForm'; // Assuming this is the formId for updating decks
-
- const {
- register,
- handleSubmit,
- reset,
- formState: { errors, isSubmitting },
- } = formStates[formId];
-
- useEffect(() => {
- if (selectedDeck) {
- reset(selectedDeck);
- }
- }, [selectedDeck, reset]);
-
- const onFormSubmit = async (data) => {
- try {
- await onSubmit({ ...data, _id: selectedDeck._id }, formId);
- showSnackbar(
- {
- title: 'Success',
- description: 'Deck updated successfully.',
- },
- 'success'
- );
- } catch (error) {
- showSnackbar(
- {
- title: 'Error',
- description: 'Failed to update deck. Please try again.',
- },
- 'error'
- );
- }
- };
-
- return (
-
- Update Deck
-
-
-
-
- }
- type="submit"
- variant="contained"
- disabled={isSubmitting}
- >
- Save Changes
-
- }
- variant="contained"
- color="error"
- onClick={() =>
- onSubmit({ _id: selectedDeck._id, delete: true }, formId)
- }
- disabled={!selectedDeck || isSubmitting}
- >
- Delete Deck
-
-
-
-
- );
-};
-export default withDynamicSnackbar(UpdateDeckForm); // Wrap DeckEditPanel with withDynamicSnackbar HOC
diff --git a/src/components/forms/cleanup/EditUserProfileForm.jsx b/src/components/forms/cleanup/EditUserProfileForm.jsx
deleted file mode 100644
index 29fdfb0..0000000
--- a/src/components/forms/cleanup/EditUserProfileForm.jsx
+++ /dev/null
@@ -1,87 +0,0 @@
-import React from 'react';
-import { Typography } from '@mui/material';
-import { useUserContext } from '../../context/UserContext/UserContext';
-import { usePageContext } from '../../context/PageContext/PageContext';
-import { PageHeader, PageContent } from '../../layout';
-import { FormWrapper, StyledTextField, StyledButton } from './styled';
-import { useFormContext, useMode } from '../../../context';
-
-const EditUserProfileForm = () => {
- const { theme } = useMode();
- const { user, fetchUserData } = useUserContext();
- const userId = user?.id;
- const { isPageLoading, setIsPageLoading, setPageError } = usePageContext();
- const { forms, handleChange, handleSubmit, formErrors } = useFormContext();
- const userDataValues = forms.updateUserDataForm;
- const userDataErrors = formErrors.updateUserDataForm || {};
-
- const handleFormSubmit = (event) => {
- event.preventDefault();
- handleSubmit('updateUserDataForm');
- };
- return (
- <>
-
-
- Edit User Settings
-
-
-
-
-
- >
- );
-};
-
-export default EditUserProfileForm;
diff --git a/src/components/forms/cleanup/EditUserSettingsForm.jsx b/src/components/forms/cleanup/EditUserSettingsForm.jsx
deleted file mode 100644
index 51f7cad..0000000
--- a/src/components/forms/cleanup/EditUserSettingsForm.jsx
+++ /dev/null
@@ -1,124 +0,0 @@
-// Import dependencies
-import React, { useState, useEffect } from 'react';
-import { useCookies } from 'react-cookie';
-import { Box, Button, TextField, Typography } from '@mui/material';
-import { useUserContext } from '../../context/UserContext/UserContext';
-import { usePageContext } from '../../context/PageContext/PageContext';
-import { PageLayout, PageHeader, PageContent } from '../../layout';
-import LoadingIndicator from '../../reusable/indicators/LoadingIndicator';
-import ErrorIndicator from '../../reusable/indicators/ErrorIndicator';
-import ThemeToggleButton from '../../components/reusable/buttons/ThemeToggleButton';
-import { useMode } from '../../../context';
-
-const EditUserSettingsForm = ({ user }) => {
- const [cookies] = useCookies(['user']);
- const { theme } = useMode();
- const { user: currentUser } = cookies;
- const userId = currentUser?.id;
-
- const {
- userData,
- updateUser,
- fetchUserData,
- isLoading,
- setIsLoading,
- pageError,
- setPageError,
- logPageData,
- } = useUserContext();
-
- const { isPageLoading, setIsPageLoading } = usePageContext();
-
- const [formState, setFormState] = useState({
- email: '',
- password: '',
- confirmPassword: '',
- });
-
- const [formError, setFormError] = useState(null);
-
- const { email, password, confirmPassword } = formState;
-
- const handleChange = (e) => {
- const { name, value } = e.target;
- setFormState((prev) => ({ ...prev, [name]: value }));
- };
-
- const handleSubmit = async (e) => {
- e.preventDefault();
- if (password !== confirmPassword) {
- setFormError('Passwords do not match');
- return;
- }
- try {
- setIsLoading(true);
- await updateUser(userId, formState);
- await fetchUserData();
- logPageData('EditUserSettingsForm', userData);
- } catch (e) {
- console.error('Failed to update user settings:', e);
- setPageError(e);
- } finally {
- setIsLoading(false);
- }
- };
-
- if (isPageLoading) return ;
- if (pageError) return ;
- if (isLoading) return ;
-
- return (
- <>
-
-
- Edit User Settings
-
-
-
-
-
- >
- );
-};
-
-export default EditUserSettingsForm;
diff --git a/src/components/forms/formsConfig.jsx b/src/components/forms/formsConfig.jsx
index a2757f4..0038a3d 100644
--- a/src/components/forms/formsConfig.jsx
+++ b/src/components/forms/formsConfig.jsx
@@ -1,11 +1,71 @@
+import LoginIcon from '@mui/icons-material/Login';
+import PersonIcon from '@mui/icons-material/Person';
+import LockIcon from '@mui/icons-material/Lock';
+import EmailRoundedIcon from '@mui/icons-material/EmailRounded';
+import VerifiedUserRoundedIcon from '@mui/icons-material/VerifiedUserRounded';
+import DescriptionRoundedIcon from '@mui/icons-material/DescriptionRounded';
+import AccountCircleRoundedIcon from '@mui/icons-material/AccountCircleRounded';
+import FindInPageRoundedIcon from '@mui/icons-material/FindInPageRounded';
+// TODO: ADD EMAIL ICON
+// TODO: ADD First ICON
+// TODO: ADD Last ICON
+// TODO: ADD General Name ICON
+// TODO: ADD Description ICON
+
const auth = [
- { name: 'firstName', label: 'First Name', type: 'text' },
- { name: 'lastName', label: 'Last Name', type: 'text' },
- { name: 'email', label: 'Email', type: 'email' },
- { name: 'username', label: 'Username', type: 'text' },
- { name: 'password', label: 'Password', type: 'password' },
+ {
+ name: 'firstName',
+ label: 'First Name',
+ type: 'text',
+ icon: ,
+ },
+ {
+ name: 'lastName',
+ label: 'Last Name',
+ type: 'text',
+ icon: ,
+ },
+ { name: 'email', label: 'Email', type: 'email', icon: },
+ {
+ name: 'username',
+ label: 'Username',
+ type: 'text',
+ icon: ,
+ },
+ {
+ name: 'password',
+ label: 'Password',
+ type: 'password',
+ icon: ,
+ },
];
const collection = [
- { name: 'name', label: 'Name', type: 'text' },
- { name: 'description', label: 'Description', type: 'text' },
+ {
+ name: 'name',
+ label: 'Name',
+ type: 'text',
+ icon: ,
+ required: true,
+ multiline: false,
+ },
+ {
+ name: 'description',
+ label: 'Description',
+ type: 'text',
+ icon: ,
+ required: true,
+ multiline: true,
+ rows: 4,
+ },
];
+const deck = [
+ { name: 'name', label: 'Name', type: 'text', icon: <>> },
+ { name: 'description', label: 'Description', type: 'text', icon: <>> },
+];
+const formData = {
+ auth,
+ collection,
+ deck,
+};
+
+export default formData;
diff --git a/src/components/forms/hooks/useSubmitHandler.jsx b/src/components/forms/hooks/useSubmitHandler.jsx
new file mode 100644
index 0000000..5b3287c
--- /dev/null
+++ b/src/components/forms/hooks/useSubmitHandler.jsx
@@ -0,0 +1,39 @@
+import { useCallback } from 'react';
+import useSnackbarManager from '../../../context/hooks/useSnackbarManager';
+
+function useSubmitHandler(
+ onSubmit,
+ successTitle,
+ successDescription,
+ errorDescription
+) {
+ const { showSuccess, showError } = useSnackbarManager();
+
+ return useCallback(
+ (data, formType) => {
+ onSubmit(data, formType)
+ .then(() => {
+ // Using showSuccess for positive feedback
+ showSuccess(
+ `${successTitle}: ${successDescription.replace('{timeRange}', data?.timeRange)}`
+ );
+ })
+ .catch((error) => {
+ // Using showError for negative feedback
+ showError(
+ `${errorDescription.replace('{timeRange}', data?.timeRange)}: ${error}`
+ );
+ });
+ },
+ [
+ onSubmit,
+ showSuccess,
+ showError,
+ successTitle,
+ successDescription,
+ errorDescription,
+ ]
+ );
+}
+
+export default useSubmitHandler;
diff --git a/src/components/forms/index.jsx b/src/components/forms/index.jsx
index f8ca92c..53c6b15 100644
--- a/src/components/forms/index.jsx
+++ b/src/components/forms/index.jsx
@@ -1,2 +1,20 @@
-import CollectionForm from './CollectionForm';
-import ProfileForm from './ProfileForm';
+import SignupForm from './SignupForm';
+import LoginForm from './LoginForm';
+import SearchForm from './SearchForm';
+import UpdateCollectionForm from './UpdateCollectionForm';
+import AddCollectionForm from './AddCollectionForm';
+import AddDeckForm from './AddDeckForm';
+import UpdateDeckForm from './UpdateDeckForm';
+import SearchSettingsForm from './SearchSettingsForm';
+
+const forms = {
+ signup: SignupForm,
+ login: LoginForm,
+ search: SearchForm,
+ updateCollection: UpdateCollectionForm,
+ addCollection: AddCollectionForm,
+ updateDeck: UpdateDeckForm,
+ addDeck: AddDeckForm,
+};
+
+export default forms;
diff --git a/src/components/forms/reusable/FormField.jsx b/src/components/forms/reusable/FormField.jsx
index 776600d..edce8e4 100644
--- a/src/components/forms/reusable/FormField.jsx
+++ b/src/components/forms/reusable/FormField.jsx
@@ -3,8 +3,17 @@ import PropTypes from 'prop-types'; // Import PropTypes
import { useMode } from '../../../context';
import { StyledTextField } from '../../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
-const FormField = ({ name, register, errors, ...props }) => {
+const FormField = ({
+ name,
+ register,
+ initialValue,
+ value,
+ errors,
+ ...props
+}) => {
const { theme } = useMode();
+ const showLabel = !initialValue;
+
return (
{
fullWidth
variant="outlined"
theme={theme}
+ InputLabelProps={{
+ shrink: showLabel ? undefined : true,
+ }}
{...props}
+ sx={{}}
/>
);
};
@@ -24,10 +37,8 @@ FormField.propTypes = {
name: PropTypes.string.isRequired, // Name is a required string
register: PropTypes.func.isRequired, // Register is a required function
errors: PropTypes.object, // Errors is an object, not necessarily required
- theme: PropTypes.object, // Theme is an object, not necessarily required
-
// CONTROLLED FIELDS
- value: PropTypes.string, // Value is a string, not necessarily required
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), // Value can be string or number
};
// Define default props if there are any optional props
diff --git a/src/components/forms/reusable/RCSwitch.jsx b/src/components/forms/reusable/RCSwitch.jsx
new file mode 100644
index 0000000..edaae5e
--- /dev/null
+++ b/src/components/forms/reusable/RCSwitch.jsx
@@ -0,0 +1,98 @@
+import React from 'react';
+import { Switch, FormControlLabel, FormControl } from '@mui/material';
+import { styled } from '@mui/material/styles';
+import { useMode } from '../../../context';
+import { renderToStaticMarkup } from 'react-dom/server';
+import { useCookies } from 'react-cookie';
+
+// Convert SVG icons to data URI
+const convertSvg = (svg) => {
+ const markup = renderToStaticMarkup(svg);
+ const encoded = encodeURIComponent(markup);
+ const dataUri = `url('data:image/svg+xml;utf8,${encoded}')`;
+ return dataUri;
+};
+
+// Generic switch component
+const RCSwitch = ({
+ checked,
+ onChange,
+ labelLeft,
+ labelRight,
+ iconLeft,
+ iconRight,
+ size = { width: 50, height: 14, thumbWidth: 22, thumbHeight: 22 },
+}) => {
+ const { theme } = useMode();
+ const colors = theme.palette.chartTheme;
+ const cookies = useCookies('colorMode');
+ const mode = cookies.colorMode;
+ const green = colors.greenAccent.light;
+ const lihhtgreen = colors.greenAccent.default;
+ const calculateTransform = () => {
+ const trackPadding = 2; // Adjust based on your design
+ const transformDistance = size.width - size.thumbWidth - trackPadding;
+ return transformDistance;
+ };
+ const SwitchBaseStyles = {
+ // pt: 1.5,
+ // pl: 1.5,
+ my: 1.7,
+ // ml: 1.5,
+ '&.Mui-checked': {
+ transform: `translateX(${calculateTransform()}px)`,
+ color: theme.palette.common.white,
+ '& + .MuiSwitch-track': {
+ backgroundColor: theme.palette.primary.main,
+ },
+ },
+ };
+
+ const ThumbStyles = (icon) => ({
+ width: size.thumbWidth,
+ height: size.thumbHeight,
+ // backgroundColor: theme.palette.common.white,
+ backgroundColor: mode === 'dark' ? green : lihhtgreen,
+
+ '&:before': {
+ content: '" "',
+ display: 'block',
+ backgroundImage: convertSvg(icon),
+ width: '100%',
+ height: '100%',
+ backgroundSize: '50%',
+ backgroundPosition: 'center',
+ backgroundRepeat: 'no-repeat',
+ },
+ });
+
+ const TrackStyles = {
+ backgroundColor: theme.palette.grey.light,
+ opacity: 1,
+ // borderRadius: 20,
+ width: size.width,
+ height: size.height,
+ };
+
+ const SwitchStyles = {
+ ...SwitchBaseStyles,
+ '& .MuiSwitch-thumb': checked
+ ? ThumbStyles(iconRight)
+ : ThumbStyles(iconLeft),
+ '& .MuiSwitch-track': TrackStyles,
+ };
+
+ return (
+
+
+ }
+ label={checked ? labelRight : labelLeft}
+ style={{ margin: 'auto', justifyContent: 'center' }}
+ />
+
+ );
+};
+
+export default RCSwitch;
diff --git a/src/components/forms/reusable/RCZodForm.jsx b/src/components/forms/reusable/RCZodForm.jsx
new file mode 100644
index 0000000..fc03843
--- /dev/null
+++ b/src/components/forms/reusable/RCZodForm.jsx
@@ -0,0 +1,197 @@
+import React, { useEffect } from 'react';
+import {
+ Box,
+ InputAdornment,
+ FormControl,
+ InputLabel,
+ Select,
+ MenuItem,
+ Chip,
+} from '@mui/material';
+import FormField from './FormField';
+import ReusableLoadingButton from '../../buttons/other/ReusableLoadingButton';
+import { useFormContext, useMode } from '../../../context';
+import {
+ FormBox,
+ FormFieldBox,
+} from '../../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
+
+const RCZodForm = ({
+ fields,
+ buttonLabel,
+ startIcon,
+ schemaName,
+ additionalButtons,
+ initialValues,
+ additionalData,
+}) => {
+ const { theme } = useMode();
+ const {
+ formMethods,
+ onSubmit,
+ handleChange,
+ setFormSchema,
+ currentForm,
+ currentFormSchema,
+ formState: { errors, isSubmitting },
+ // getValues,
+ // handleSearchTermChange,
+ } = useFormContext();
+
+ // useEffect(() => {
+ // setFormSchema(schemaName);
+ // }, [setFormSchema, schemaName]);
+ // useEffect(() => {
+ // setFormSchema(schemaName);
+ // if (initialValues) {
+ // console.log('initialValues:', initialValues);
+ // formMethods.reset(initialValues);
+ // }
+ // }, [setFormSchema, schemaName, formMethods, initialValues]);
+ // useEffect(() => {
+ // // console.log('initialValues:', initialValues);
+ // console.log('SCHEMA NAME CHANGED TO:', schemaName);
+ // setFormSchema(schemaName);
+ // // When currentForm or schemaName changes, reset form with new initialValues or empty values
+ // formMethods.reset(initialValues || {});
+ // }, [setFormSchema, schemaName, formMethods, initialValues]);
+ const onFormSubmit = (data) => {
+ onSubmit(data, additionalData);
+ };
+
+ const renderField = (field) => {
+ const isSearchForm =
+ schemaName === 'searchForm' && field.name === 'searchTerm';
+
+ const onChange = isSearchForm ? handleChange : undefined;
+
+ if (field.type === 'select') {
+ return (
+
+
+ {field.label}
+
+
+
+ );
+ } else if (field.type === 'chips') {
+ return (
+
+
+ {field?.values?.map((value, index) => (
+ field.onDelete(value)}
+ />
+ ))}
+
+
+ );
+ } else {
+ return (
+
+ formMethods.handleChange(e.target.value)}
+ InputProps={
+ field.icon
+ ? {
+ endAdornment: (
+
+ {field.icon}
+
+ ),
+ }
+ : null
+ }
+ multiline={field.multiline}
+ rows={field.rows}
+ />
+
+ );
+ }
+ };
+
+ return (
+
+ {fields?.map(renderField)}
+
+ {startIcon}
+
+ }
+ fullWidth
+ />
+ {additionalButtons &&
+ additionalButtons?.map((button, index) => (
+
+ ))}
+
+ );
+};
+
+export default RCZodForm;
diff --git a/src/components/forms/reusable/Select.jsx b/src/components/forms/reusable/Select.jsx
index cf0e3c6..8fc0a9d 100644
--- a/src/components/forms/reusable/Select.jsx
+++ b/src/components/forms/reusable/Select.jsx
@@ -71,7 +71,7 @@ const SelectComponent = React.forwardRef(
},
}}
>
- */}
{options.map((option) => (
{option.label}
diff --git a/src/components/forms/search/SearchComponent.jsx b/src/components/forms/search/SearchComponent.jsx
index 0a5e57e..678a44a 100644
--- a/src/components/forms/search/SearchComponent.jsx
+++ b/src/components/forms/search/SearchComponent.jsx
@@ -1,6 +1,7 @@
// DeckSearch.js
import React, { useEffect, useState } from 'react';
import {
+ Card,
Collapse,
Container,
Grid,
@@ -19,6 +20,8 @@ import { useCardStore, useMode } from '../../../context';
import useLocalStorage from '../../../context/hooks/useLocalStorage';
import { useCardStoreHook } from '../../../context/hooks/useCardStore';
import { useConfiguratorContext } from '../../../context';
+import SimpleCard from '../../../layout/REUSABLE_COMPONENTS/unique/SimpleCard';
+import uniqueTheme from '../../../layout/REUSABLE_COMPONENTS/unique/uniqueTheme';
const SearchComponent = (pageContext) => {
const { theme } = useMode();
const itemsPerPage = 12;
@@ -44,27 +47,21 @@ const SearchComponent = (pageContext) => {
return (
-
{
onClick={toggleConfigurator}
size="large"
>
-
+
{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
- p: theme.spacing(2),
}}
>
- {/* eslint-disable-next-line max-len */}
setSearchBarFocused(true)}
onBlur={() => setSearchBarFocused(false)}
/>
-
+
-
+
+
+
);
diff --git a/src/components/forms/search/SearchResults.jsx b/src/components/forms/search/SearchResults.jsx
index c495304..6be7eda 100644
--- a/src/components/forms/search/SearchResults.jsx
+++ b/src/components/forms/search/SearchResults.jsx
@@ -3,7 +3,7 @@ import { Box, Grid } from '@mui/material';
import useGridItems from '../../../context/hooks/useGridItems';
import usePagination from '../../../context/hooks/usePagination';
import PaginationComponent from '../../../layout/collection/collectionGrids/cards-datatable/PaginationComponent';
-import LoadingIndicator from '../../reusable/indicators/LoadingIndicator';
+import LoadingIndicator from '../../../layout/LoadingIndicator';
import MDBox from '../../../layout/REUSABLE_COMPONENTS/MDBOX';
const SearchResults = ({
@@ -20,6 +20,7 @@ const SearchResults = ({
isLoading,
pageContext,
itemsPerPage,
+ type: 'search',
});
if (isLoading) return ;
diff --git a/src/components/forms/selectors/ThemeSelector.jsx b/src/components/forms/selectors/ThemeSelector.jsx
index 25e6fca..ef64bd1 100644
--- a/src/components/forms/selectors/ThemeSelector.jsx
+++ b/src/components/forms/selectors/ThemeSelector.jsx
@@ -3,10 +3,9 @@ import { FormControl, InputLabel } from '@mui/material';
import { Controller } from 'react-hook-form';
import { useSnackbar } from 'notistack';
-import SelectComponent from '../reusable/Select';
import { useFormContext, useMode } from '../../../context';
import { StyledChartBox } from '../../../pages/pageStyles/StyledComponents';
-import MDTypography from '../../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
+import SelectComponent from '../reusable/Select';
const ThemeSelector = ({ setTheme }) => {
const { theme } = useMode();
diff --git a/src/components/forms/selectors/TimeRangeSelector.jsx b/src/components/forms/selectors/TimeRangeSelector.jsx
index ef4f184..a8bdd34 100644
--- a/src/components/forms/selectors/TimeRangeSelector.jsx
+++ b/src/components/forms/selectors/TimeRangeSelector.jsx
@@ -2,15 +2,15 @@ import { useMemo } from 'react';
import { useFormContext, useMode } from '../../../context';
import useSelectedCollection from '../../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
import { StyledChartBox } from '../../../pages/pageStyles/StyledComponents';
-import { FormControl, InputLabel } from '@mui/material';
+import { FormControl, InputLabel, Typography } from '@mui/material';
import { Controller } from 'react-hook-form';
import SelectComponent from '../reusable/Select';
import useTimeRange from './useTimeRange';
+import MDTypography from '../../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-const TimeRangeSelector = ({ showSnackbar }) => {
+const TimeRangeSelector = () => {
const { theme } = useMode();
- const { timeRangeOptions, onFormSubmit, control, errors } =
- useTimeRange(showSnackbar);
+ const { timeRangeOptions, onFormSubmit, control, errors } = useTimeRange();
return (
{
error={!!errors.timeRange}
sx={{ width: '100%' }}
>
- Time Range
+
+ {/* */}
+ Time Range
+ {/* */}
+
{
);
};
export default TimeRangeSelector;
-
-// // const TimeRangeSelector = ({ showSnackbar }) => {
-// // const { theme } = useMode();
-// // const { formMethods, onSubmit } = useFormContext();
-// // const { selectedCollection } = useSelectedCollection();
-// // const averagedChartData = selectedCollection?.averagedChartData;
-
-// // const timeRangeOptions = useMemo(() => {
-// // const options = [];
-// // averagedChartData?.forEach((value, key) => {
-// // options.push({
-// // value: key,
-// // label: key.toUpperCase(),
-// // });
-// // });
-// // return options;
-// // }, [averagedChartData]);
-
-// // const {
-// // control,
-// // handleSubmit,
-// // formState: { errors },
-// // } = formMethods;
-
-// // const onFormSubmit = (data) => {
-// // onSubmit(data, 'timeRangeSelector')
-// // .then(() => {
-// // showSnackbar(
-// // {
-// // title: 'Success',
-// // description: `Now viewing chart data for ${data?.timeRange}`,
-// // },
-// // 'success'
-// // );
-// // })
-// // .catch((error) => {
-// // showSnackbar(
-// // {
-// // title: 'Error',
-// // description: `Failed to view chart data for ${data?.timeRange}: ${error}`,
-// // },
-// // 'error'
-// // );
-// // });
-// // };
-
-// // return (
-// //
-// //
-// // Time Range
-// // (
-// //
-// // )}
-// // />
-// //
-// //
-// // );
-// // };
-
-// // export default TimeRangeSelector;
-// // import React, { useMemo } from 'react';
-// // import { useFormContext, Controller } from 'react-hook-form';
-// // import { FormControl, InputLabel } from '@mui/material';
-// // import { useMode } from '../../../../context';
-// // import useSelectedCollection from '../../../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
-// // import SelectComponent from '../../../REUSABLE_COMPONENTS/SelectComponent';
-// // import StyledChartBox from '../../../REUSABLE_COMPONENTS/StyledChartBox';
-
-// const TimeRangeSelector = ({ showSnackbar }) => {
-// const { theme } = useMode();
-// const { formMethods, onSubmit } = useFormContext();
-// const { selectedCollection } = useSelectedCollection();
-// const averagedChartData = selectedCollection?.averagedChartData;
-
-// // Convert the Map to an array of options for the select component
-// const timeRangeOptions = useMemo(() => {
-// return Array.from(averagedChartData?.entries() || []).map(
-// ([key, value]) => ({
-// value: key,
-// label: value.name.toUpperCase(),
-// })
-// );
-// }, [averagedChartData]);
-
-// const {
-// control,
-// handleSubmit,
-// formState: { errors },
-// } = formMethods;
-
-// const onFormSubmit = (data) => {
-// onSubmit(data, 'timeRangeSelector')
-// .then(() => {
-// showSnackbar(
-// {
-// title: 'Success',
-// description: `Now viewing chart data for ${data?.timeRange}`,
-// },
-// 'success'
-// );
-// })
-// .catch((error) => {
-// showSnackbar(
-// {
-// title: 'Error',
-// description: `Failed to view chart data for ${data?.timeRange}: ${error}`,
-// },
-// 'error'
-// );
-// });
-// };
-
-// return (
-//
-//
-// Time Range
-// (
-//
-// )}
-// />
-//
-//
-// );
-// };
-
-// export default TimeRangeSelector;
diff --git a/src/components/forms/selectors/useTimeRange.jsx b/src/components/forms/selectors/useTimeRange.jsx
index 497d24a..79af5bb 100644
--- a/src/components/forms/selectors/useTimeRange.jsx
+++ b/src/components/forms/selectors/useTimeRange.jsx
@@ -1,46 +1,70 @@
import { useMemo, useCallback } from 'react';
import { useFormContext } from '../../../context';
import useSelectedCollection from '../../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
+import useSubmitHandler from '../hooks/useSubmitHandler';
function useTimeRange(showSnackbar) {
const { formMethods, onSubmit } = useFormContext();
const { selectedCollection } = useSelectedCollection();
const averagedChartData = selectedCollection?.averagedChartData;
-
+ const selectedTimeRange = formMethods.watch('timeRange', '24hr');
const timeRangeOptions = useMemo(() => {
- return Object.keys(averagedChartData || {}).map((key) => ({
- value: key,
- label: key.toUpperCase(),
- }));
+ return Object.entries(averagedChartData || {}).map(([key, value]) => {
+ // console.log(`Key: ${key}, Value: `, value);
+ return {
+ value: value?.id,
+ label: value?.name?.toUpperCase(),
+ };
+ });
}, [averagedChartData]);
- // Watching the "timeRange" field to get its current value
- const selectedTimeRange = formMethods.watch('timeRange', '24hr');
+ const handleTimeRangeSubmit = async (data) => {
+ // Here you can integrate the logic to handle the submission data,
+ // for instance, to update the chart based on the selected time range.
+ console.log('Time Range Selected:', data.timeRange);
+ };
+ const successTitle = 'Success';
+ const successDescription = 'Now viewing chart data for {timeRange}';
+ const errorDescription = 'Failed to view chart data for {timeRange}';
- const onFormSubmit = useCallback(
- (data) => {
- onSubmit(data, 'timeRangeSelector')
- .then(() => {
- showSnackbar(
- {
- title: 'Success',
- description: `Now viewing chart data for ${data?.timeRange}`,
- },
- 'success'
- );
- })
- .catch((error) => {
- showSnackbar(
- {
- title: 'Error',
- description: `Failed to view chart data for ${data?.timeRange}: ${error}`,
- },
- 'error'
- );
- });
- },
- [onSubmit, showSnackbar]
+ // Using the custom submit handler hook.
+ const onFormSubmit = useSubmitHandler(
+ handleTimeRangeSubmit,
+ successTitle,
+ successDescription,
+ errorDescription
);
+ // const onFormSubmit = useSubmitHandler(
+ // onSubmit,
+ // showSnackbar,
+ // 'Success',
+ // 'Now viewing chart data for {timeRange}',
+ // 'Failed to view chart data for {timeRange}'
+ // );
+ // const onFormSubmit = useCallback(
+ // (data) => {
+ // onSubmit(data, 'timeRangeSelector')
+ // .then(() => {
+ // showSnackbar(
+ // {
+ // title: 'Success',
+ // description: `Now viewing chart data for ${data?.timeRange}`,
+ // },
+ // 'success'
+ // );
+ // })
+ // .catch((error) => {
+ // showSnackbar(
+ // {
+ // title: 'Error',
+ // description: `Failed to view chart data for ${data?.timeRange}: ${error}`,
+ // },
+ // 'error'
+ // );
+ // });
+ // },
+ // [onSubmit, showSnackbar]
+ // );
return {
timeRangeOptions,
diff --git a/src/components/grids/deckBuilderGrids/CardsGrid.js b/src/components/grids/deckBuilderGrids/CardsGrid.js
deleted file mode 100644
index a6e58ad..0000000
--- a/src/components/grids/deckBuilderGrids/CardsGrid.js
+++ /dev/null
@@ -1,159 +0,0 @@
-// import React, { useMemo, useState } from 'react';
-// import { Grid, Grow, Typography } from '@mui/material';
-// import { useDeckStore } from '../../../context/MAIN_CONTEXT/DeckContext/DeckContext';
-// import SkeletonDeckItem from '../gridItems/SkeletonDeckItem';
-// import GridLayout from '../searchResultsGrids/GridLayout';
-// import StoreItem from '../gridItems/StoreItem';
-// import MDBox from '../../../layout/REUSABLE_COMPONENTS/MDBOX';
-
-// const CardsGrid = ({ isLoading }) => {
-// const { selectedCards } = useDeckStore();
-// const [error, setError] = useState('');
-
-// const flattenSelectedCards = useMemo(() => {
-// if (!Array.isArray(selectedCards)) return [];
-
-// const cardCountMap = new Map();
-
-// return selectedCards.reduce((acc, card) => {
-// if (!card) return acc;
-// const currentCount = cardCountMap.get(card.id) || 0;
-// if (currentCount < 3) {
-// cardCountMap.set(card.id, currentCount + 1);
-// return [...acc, { ...card, uniqueKey: `${card.id}-${currentCount}` }];
-// }
-// return acc;
-// }, []);
-// }, [selectedCards]);
-
-// if (error) {
-// return {error};
-// }
-
-// const skeletonCount = 12;
-
-// return (
-//
-// {(isLoading
-// ? Array.from({ length: skeletonCount })
-// : flattenSelectedCards
-// ).map((item, index) => (
-//
-//
-//
-// {isLoading ? (
-//
-// ) : (
-//
-// )}
-//
-//
-//
-// ))}
-//
-// );
-// };
-
-// export default React.memo(CardsGrid);
-import React, { useMemo } from 'react';
-import { Grid, Grow, Typography } from '@mui/material';
-import { useDeckStore } from '../../../context/MAIN_CONTEXT/DeckContext/DeckContext';
-import SkeletonDeckItem from '../gridItems/SkeletonDeckItem';
-import StoreItem from '../gridItems/StoreItem';
-import MDBox from '../../../layout/REUSABLE_COMPONENTS/MDBOX';
-import GridLayout from '../../../layout/Containers/GridLayout';
-
-const CardsGrid = ({ isLoading }) => {
- const { selectedCards } = useDeckStore();
-
- // Efficiently flattening and processing selectedCards with useMemo
- const flattenSelectedCards = useMemo(() => {
- if (!Array.isArray(selectedCards)) return [];
-
- const cardCountMap = new Map();
-
- return selectedCards.reduce((acc, card) => {
- if (!card) return acc;
- const currentCount = (cardCountMap.get(card.id) || 0) + 1;
- if (currentCount <= 3) {
- acc.push({ ...card, uniqueKey: `${card.id}-${currentCount - 1}` });
- cardCountMap.set(card.id, currentCount);
- }
- return acc;
- }, []);
- }, [selectedCards]);
-
- const gridItems = useMemo(() => {
- return isLoading ? Array.from({ length: 12 }) : flattenSelectedCards;
- }, [isLoading, flattenSelectedCards]);
-
- // Define grid item breakpoints once to reuse in the mapping
- const gridItemProps = { xs: 6, sm: 4, md: 4, lg: 4 };
-
- return (
-
- {gridItems.map((item, index) => (
-
-
-
- {isLoading ? (
-
- ) : (
-
- )}
-
-
-
- ))}
-
- );
-};
-
-export default React.memo(CardsGrid);
diff --git a/src/components/grids/deckBuilderGrids/SelectDeckList.jsx b/src/components/grids/deckBuilderGrids/SelectDeckList.jsx
deleted file mode 100644
index 8da1a5d..0000000
--- a/src/components/grids/deckBuilderGrids/SelectDeckList.jsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import React from 'react';
-import { Grid, Chip, Typography } from '@mui/material';
-import DeckBuilderIcon from '../../reusable/icons/DeckBuilderIcon';
-import { useDeckStore } from '../../../context/MAIN_CONTEXT/DeckContext/DeckContext';
-import { useMode } from '../../../context';
-
-const SelectDeckList = ({ handleSelectDeck }) => {
- const { allDecks } = useDeckStore();
- const { theme } = useMode();
-
- return (
-
- {allDecks?.map((deck) => (
-
-
- {deck?.name || 'Unnamed'}
-
- }
- onClick={() => handleSelectDeck(deck?._id)}
- icon={}
- variant="outlined"
- color="primary"
- clickable
- sx={{
- justifyContent: 'flex-start',
- padding: 1,
- borderRadius: theme.shape.borderRadius,
- width: '100%', // Make chip full width of the container
- }}
- />
-
- ))}
-
- );
-};
-
-export default SelectDeckList;
diff --git a/src/components/grids/gridItems/ReusableSkeletonItem.jsx b/src/components/grids/gridItems/ReusableSkeletonItem.jsx
deleted file mode 100644
index 074a7b9..0000000
--- a/src/components/grids/gridItems/ReusableSkeletonItem.jsx
+++ /dev/null
@@ -1,30 +0,0 @@
-// ReusableSkeletonItem.jsx
-import React from 'react';
-import { Grid } from '@mui/material';
-import SkeletonStoreItem from './SkeletonStoreItem';
-import SkeletonDeckItem from './SkeletonDeckItem';
-
-const ReusableSkeletonItem = ({ itemType, count, gridItemProps, context }) =>
- context === 'Cart' ? (
- <>
- {Array(count)
- .fill(0)
- .map((_, index) => (
-
-
-
- ))}
- >
- ) : (
- <>
- {Array(count)
- .fill(0)
- .map((_, index) => (
-
-
-
- ))}
- >
- );
-
-export default ReusableSkeletonItem;
diff --git a/src/components/grids/gridItems/SkeletonDeckItem.jsx b/src/components/grids/gridItems/SkeletonDeckItem.jsx
deleted file mode 100644
index 686cd89..0000000
--- a/src/components/grids/gridItems/SkeletonDeckItem.jsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import React from 'react';
-import { Box, CardContent, Skeleton } from '@mui/material';
-import {
- AspectRatioBoxSkeleton,
- StyledSkeletonCard,
-} from '../../../pages/pageStyles/StyledComponents';
-import { useMode } from '../../../context';
-
-const SkeletonDeckItem = ({ context }) => {
- const { theme } = useMode();
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-};
-
-export default SkeletonDeckItem;
diff --git a/src/components/grids/gridItems/SkeletonStoreItem.jsx b/src/components/grids/gridItems/SkeletonStoreItem.jsx
deleted file mode 100644
index 6348f9d..0000000
--- a/src/components/grids/gridItems/SkeletonStoreItem.jsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import React from 'react';
-import { Box, CardContent, Skeleton } from '@mui/material';
-import { useMode } from '../../../context';
-import {
- AspectRatioBoxSkeleton,
- StyledSkeletonCard,
-} from '../../../pages/pageStyles/StyledComponents';
-const SkeletonStoreItem = () => {
- const { theme } = useMode();
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-};
-
-export default SkeletonStoreItem;
diff --git a/src/components/grids/gridItems/StoreItem.jsx b/src/components/grids/gridItems/StoreItem.jsx
deleted file mode 100644
index 8aa6b56..0000000
--- a/src/components/grids/gridItems/StoreItem.jsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import React, { memo } from 'react';
-import { Box, Container } from '@mui/material';
-import GenericCard from '../../cards/GenericCard';
-
-// eslint-disable-next-line react/display-name
-const StoreItem = memo(({ card, context, page, index }) => {
- return (
-
-
-
-
-
- );
-});
-
-export default StoreItem;
diff --git a/src/components/reusable/CustomPagination.jsx b/src/components/reusable/CustomPagination.jsx
deleted file mode 100644
index 35ef3ec..0000000
--- a/src/components/reusable/CustomPagination.jsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import React from 'react';
-import { Box, Pagination } from '@mui/material';
-import { useMode } from '../../context';
-
-const CustomPagination = ({
- totalCount,
- itemsPerPage,
- currentPage,
- handlePagination,
-}) => {
- const { theme } = useMode();
- const pageCount = Math.ceil(totalCount / itemsPerPage);
-
- return (
-
-
-
- );
-};
-
-export default CustomPagination;
diff --git a/src/components/reusable/icons/DeckBuilderIcon.jsx b/src/components/reusable/icons/DeckBuilderIcon.jsx
deleted file mode 100644
index 6bb8302..0000000
--- a/src/components/reusable/icons/DeckBuilderIcon.jsx
+++ /dev/null
@@ -1,161 +0,0 @@
-/* eslint-disable max-len */
-// /* eslint-disable max-len */
-// import * as React from 'react';
-// import { SvgIcon } from '@mui/material';
-
-// export default function DeckBuilderIcon(props) {
-// // Extract customPaths and otherProps from props
-// const { customPaths, ...otherProps } = props;
-
-// // Default paths if custom paths are not provided
-// const defaultPaths = [
-// 'M1050 1666 c-129 -45 -387 -136 -572 -201 -186 -65 -347 -127 -358 -137 -24 -22 -26 -70 -5 -92 48 -48 491 -413 513 -423 65 -29 98 -20 679 183 309 108 576 205 592 215 25 15 31 25 31 53 0 38 -4 42 -348 330 -160 134 -198 156 -259 156 -21 -1 -143 -38 -273 -84z',
-// 'M60 1188 c0 -7 6 -23 13 -35 14 -25 477 -417 522 -441 19 -11 55 -16
-// 100 -17 66 0 104 12 633 198 310 108 577 204 593 213 29 14 49 48 49 81 0 13
-// -4 12 -24 -6 -28 -27 0 -16 -656 -247 -583 -205 -602 -210 -686 -168 -22 10
-// -149 111 -282 224 -134 113 -248 207 -253 208 -5 2 -9 -2 -9 -10z',
-// 'M70 1079 c0 -36 7 -43 253 -249 138 -117 266 -219 284 -226 18 -8 59
-// -14 92 -14 53 0 133 25 630 199 313 110 579 204 590 210 28 16 51 51 51 80 l0
-// 24 -23 -21 c-36 -34 -1183 -432 -1243 -432 -89 0 -111 14 -370 232 -137 116
-// -252 215 -256 222 -4 6 -8 -5 -8 -25z',
-// 'M70 972 c0 -35 4 -38 324 -305 181 -152 203 -167 253 -177 30 -7 71
-// -9 92 -5 44 8 1109 379 1167 406 41 19 64 52 64 91 l0 21 -23 -21 c-14 -13
-// -243 -100 -602 -227 -742 -262 -679 -258 -902 -69 -68 57 -179 152 -248 210
-// -122 103 -125 105 -125 76z',
-// 'M70 873 c0 -18 7 -38 15 -47 38 -37 490 -413 514 -426 17 -10 52 -14
-// 101 -14 71 1 104 11 634 198 307 108 572 204 588 212 30 15 48 49 48 87 -1 19
-// -2 20 -13 7 -7 -8 -19 -21 -28 -27 -20 -16 -1140 -408 -1192 -417 -21 -4 -63
-// -2 -93 4 -51 11 -72 26 -282 202 -125 105 -242 204 -259 221 l-33 31 0 -31z',
-// 'M70 778 c0 -30 10 -39 324 -301 181 -152 203 -167 253 -177 30 -7 71
-// -9 92 -5 44 8 1109 379 1167 406 22 11 46 31 52 45 19 39 14 49 -11 26 -36
-// -34 -1183 -432 -1243 -432 -89 0 -111 14 -370 232 -137 116 -252 215 -256 222
-// -5 6 -8 -1 -8 -16z'
-// ];
-
-// // Use customPaths if provided, otherwise use defaultPaths
-// const paths = customPaths || defaultPaths;
-// return (
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-// );
-// }
-import * as React from 'react';
-import { SvgIcon } from '@mui/material';
-
-export default function DeckBuilderIcon(props) {
- // Extract customPaths and otherProps from props
- const { customPaths, ...otherProps } = props;
- // const { customPaths, ...otherProps } = props;
-
- // Default paths if custom paths are not provided
- const defaultPaths = [
- 'M1050 1666 c-129 -45 -387 -136 -572 -201 -186 -65 -347 -127 -358 -137 -24 -22 -26 -70 -5 -92 48 -48 491 -413 513 -423 65 -29 98 -20 679 183 309 108 576 205 592 215 25 15 31 25 31 53 0 38 -4 42 -348 330 -160 134 -198 156 -259 156 -21 -1 -143 -38 -273 -84z',
- 'M60 1188 c0 -7 6 -23 13 -35 14 -25 477 -417 522 -441 19 -11 55 -16 100 -17 66 0 104 12 633 198 310 108 577 204 593 213 29 14 49 48 49 81 0 13 -4 12 -24 -6 -28 -27 0 -16 -656 -247 -583 -205 -602 -210 -686 -168 -22 10 -149 111 -282 224 -134 113 -248 207 -253 208 -5 2 -9 -2 -9 -10z',
- 'M70 1079 c0 -36 7 -43 253 -249 138 -117 266 -219 284 -226 18 -8 59 -14 92 -14 53 0 133 25 630 199 313 110 579 204 590 210 28 16 51 51 51 80 l0 24 -23 -21 c-36 -34 -1183 -432 -1243 -432 -89 0 -111 14 -370 232 -137 116 -252 215 -256 222 -4 6 -8 -5 -8 -25z',
- 'M70 972 c0 -35 4 -38 324 -305 181 -152 203 -167 253 -177 30 -7 71 -9 92 -5 44 8 1109 379 1167 406 41 19 64 52 64 91 l0 21 -23 -21 c-14 -13 -243 -100 -602 -227 -742 -262 -679 -258 -902 -69 -68 57 -179 152 -248 210 -122 103 -125 105 -125 76z',
- 'M70 873 c0 -18 7 -38 15 -47 38 -37 490 -413 514 -426 17 -10 52 -14 101 -14 71 1 104 11 634 198 307 108 572 204 588 212 30 15 48 49 48 87 -1 19 -2 20 -13 7 -7 -8 -19 -21 -28 -27 -20 -16 -1140 -408 -1192 -417 -21 -4 -63 -2 -93 4 -51 11 -72 26 -282 202 -125 105 -242 204 -259 221 l-33 31 0 -31z',
- 'M70 778 c0 -30 10 -39 324 -301 181 -152 203 -167 253 -177 30 -7 71 -9 92 -5 44 8 1109 379 1167 406 22 11 46 31 52 45 19 39 14 49 -11 26 -36 -34 -1183 -432 -1243 -432 -89 0 -111 14 -370 232 -137 116 -252 215 -256 222 -5 6 -8 -1 -8 -16z',
- ];
-
- // const defaultPaths = [
- // 'M1050 1666 c-129 -45 -387 -136 -572 -201 -186 -65 -347 -127 -358
- // -137 -24 -22 -26 -70 -5 -92 48 -48 491 -413 513 -423 65 -29 98 -20 679 183
- // 309 108 576 205 592 215 25 15 31 25 31 53 0 38 -4 42 -348 330 -160 134 -198
- // 156 -259 156 -21 -1 -143 -38 -273 -84z',
- // 'M60 1188 c0 -7 6 -23 13 -35 14 -25 477 -417 522 -441 19 -11 55 -16
- // 100 -17 66 0 104 12 633 198 310 108 577 204 593 213 29 14 49 48 49 81 0 13
- // -4 12 -24 -6 -28 -27 0 -16 -656 -247 -583 -205 -602 -210 -686 -168 -22 10
- // -149 111 -282 224 -134 113 -248 207 -253 208 -5 2 -9 -2 -9 -10z',
- // 'M70 1079 c0 -36 7 -43 253 -249 138 -117 266 -219 284 -226 18 -8 59
- // -14 92 -14 53 0 133 25 630 199 313 110 579 204 590 210 28 16 51 51 51 80 l0
- // 24 -23 -21 c-36 -34 -1183 -432 -1243 -432 -89 0 -111 14 -370 232 -137 116
- // -252 215 -256 222 -4 6 -8 -5 -8 -25z',
- // 'M70 972 c0 -35 4 -38 324 -305 181 -152 203 -167 253 -177 30 -7 71
- // -9 92 -5 44 8 1109 379 1167 406 41 19 64 52 64 91 l0 21 -23 -21 c-14 -13
- // -243 -100 -602 -227 -742 -262 -679 -258 -902 -69 -68 57 -179 152 -248 210
- // -122 103 -125 105 -125 76z',
- // 'M70 873 c0 -18 7 -38 15 -47 38 -37 490 -413 514 -426 17 -10 52 -14
- // 101 -14 71 1 104 11 634 198 307 108 572 204 588 212 30 15 48 49 48 87 -1 19
- // -2 20 -13 7 -7 -8 -19 -21 -28 -27 -20 -16 -1140 -408 -1192 -417 -21 -4 -63
- // -2 -93 4 -51 11 -72 26 -282 202 -125 105 -242 204 -259 221 l-33 31 0 -31z',
- // 'M70 778 c0 -30 10 -39 324 -301 181 -152 203 -167 253 -177 30 -7 71
- // -9 92 -5 44 8 1109 379 1167 406 22 11 46 31 52 45 19 39 14 49 -11 26 -36
- // -34 -1183 -432 -1243 -432 -89 0 -111 14 -370 232 -137 116 -252 215 -256 222
- // -5 6 -8 -1 -8 -16z'
- // ];
-
- // Use customPaths if provided, otherwise use defaultPaths
- const paths = customPaths || defaultPaths;
- return (
-
-
- {paths?.map((d, i) => (
-
- ))}
-
-
- );
-}
diff --git a/src/config.js b/src/config.js
deleted file mode 100644
index ac980fb..0000000
--- a/src/config.js
+++ /dev/null
@@ -1,8 +0,0 @@
-const config = {
- basename: '',
- defaultPath: '/home',
- fontFamily: "'Roboto', sans-serif",
- borderRadius: 12,
-};
-
-export default config;
diff --git a/src/config.json b/src/config.json
new file mode 100644
index 0000000..0d90ac9
--- /dev/null
+++ b/src/config.json
@@ -0,0 +1,24 @@
+{
+ "compilerOptions": {
+ "baseUrl": ".",
+ "target": "es5",
+ "module": "commonjs",
+ "sourceMap": true,
+ "outDir": "dist",
+ "paths": {
+ "@material-ui/core": ["../node_modules/@material-ui/core"],
+ "@material-ui/icons": ["../node_modules/@material-ui/icons"],
+ "@material-ui/lab": ["../node_modules/@material-ui/lab"],
+ "@material-ui/pickers": ["../node_modules/@material-ui/pickers"],
+ "@material-ui/styles": ["../node_modules/@material-ui/styles"],
+ "@material-ui/system": ["../node_modules/@material-ui/system"],
+ "@material-ui/utils": ["../node_modules/@material-ui/utils"],
+ "@tabler/icons-react": ["../node_modules/@tabler/icons-react"],
+ "@tabler/icons": ["../node_modules/@tabler/icons"],
+ "@tabler/core": ["../node_modules/@tabler/core"],
+ "@tabler/core-react": ["../node_modules/@tabler/core-react"],
+ "@tabler/core-icons": ["../node_modules/@tabler/core-icons"],
+ "@tabler/core-react-icons": ["../node_modules/@tabler/core-react-icons"]
+ }
+ }
+}
diff --git a/src/context/Helpers.jsx b/src/context/Helpers.jsx
index 0de877f..1655ba5 100644
--- a/src/context/Helpers.jsx
+++ b/src/context/Helpers.jsx
@@ -17,13 +17,6 @@ export const BASE_API_URL = `${process.env.REACT_APP_SERVER}/api/users`;
*/
export const createApiUrl = (path) => `${BASE_API_URL}/${path}`;
-const lastRequestTime = {
- POST: 0,
- PUT: 0,
- DELETE: 0,
- GET: 0,
- PATCH: 0,
-};
/**
* Filters a collection of data points based on a time threshold.
*
@@ -85,20 +78,17 @@ export const roundToNearestTenth = (value) => {
return Math.round(value * 10) / 10;
};
-// Function to calculate total price of a collection
export const calculateTotalPrice = (collection) => {
// Assuming collection is an object where each key-value pair is cardId-price
return Object.values(collection).reduce((total, price) => total + price, 0);
};
-// Function to get the quantity of cards in a collection by its ID
export const getCardQuantity = (collectionId, allCollections) => {
// Assuming allCollections is an array of collection objects
const collection = allCollections.find((coll) => coll._id === collectionId);
return collection ? collection.cards.length : 0;
};
-// Custom Hook to get the userId from cookies
export const useUserId = () => {
const [cookies] = useCookies(['authUser']);
const [userId, setUserId] = useState(null);
@@ -165,3 +155,23 @@ export const createNewPriceEntry = (price) => {
timestamp: new Date(),
};
};
+export const calculateCollectionValue = (collection) => {
+ if (!collection) return 0;
+
+ const cards = collection?.cards;
+
+ if (!Array.isArray(cards)) {
+ console.warn('Invalid collection format', collection, cards);
+ return 0;
+ }
+
+ return cards.reduce((totalValue, card) => {
+ const cardPrice = card?.price || 0;
+ const cardQuantity = card?.quantity || 0;
+ return totalValue + cardPrice * cardQuantity;
+ }, 0);
+};
+
+export const shouldFetchCollections = (prevUserId, currentUserId) => {
+ return prevUserId !== currentUserId && currentUserId != null;
+};
diff --git a/src/context/MAIN_CONTEXT/AuthContext/authContext.js b/src/context/MAIN_CONTEXT/AuthContext/authContext.js
index 46cf135..625cf63 100644
--- a/src/context/MAIN_CONTEXT/AuthContext/authContext.js
+++ b/src/context/MAIN_CONTEXT/AuthContext/authContext.js
@@ -8,16 +8,13 @@ import React, {
useMemo,
useState,
} from 'react';
-import axios from 'axios';
import { useCookies } from 'react-cookie';
-import { usePageContext } from '../../UTILITIES_CONTEXT/PageContext/PageContext';
-import { processResponseData } from './helpers';
import useLogger from '../../hooks/useLogger';
import { defaultContextValue } from '../../constants';
import { Redirect, useNavigate } from 'react-router-dom';
-import { useLoading } from '../../hooks/useLoading';
import useFetchWrapper from '../../hooks/useFetchWrapper';
import jwt_decode from 'jwt-decode';
+import { CircularProgress, Snackbar } from '@mui/material';
export const AuthContext = createContext(defaultContextValue.AUTH_CONTEXT);
@@ -32,6 +29,7 @@ export default function AuthProvider({ children }) {
'authUser',
'userId',
]);
+ const [openSnackbar, setOpenSnackbar] = useState(false);
const [user, setUser] = useState({
isLoggedIn: false,
accessToken: '',
@@ -63,7 +61,7 @@ export default function AuthProvider({ children }) {
const [responseMessage, setResponseMessage] = useState('');
const { fetchWrapper } = useFetchWrapper();
- const { logEvent } = useLogger('AuthContext');
+ // const { logEvent } = useLogger('AuthContext');
// Helper function to set cookies
const setAuthCookies = (data) => {
const { accessToken, refreshToken, user } = data;
@@ -105,10 +103,18 @@ export default function AuthProvider({ children }) {
);
}
};
+ // const logout = useCallback(() => {
+ // clearAuthCookies();
+ // }, [removeCookie, navigate]);
const logout = useCallback(() => {
- clearAuthCookies();
- }, [removeCookie, navigate]);
-
+ ['accessToken', 'refreshToken', 'user'].forEach((cookieName) =>
+ removeCookie(cookieName, { path: '/' })
+ );
+ setOpenSnackbar(true); // Open the snackbar with loading icon
+ setTimeout(() => {
+ navigate('/login'); // Redirect to login after the timeout
+ }, 3000); // Set timeout duration (e.g., 3000 ms = 3 seconds)
+ }, [navigate, removeCookie]);
const login = useCallback(
async (username, password) => {
await executeAuthAction(
@@ -140,7 +146,12 @@ export default function AuthProvider({ children }) {
const checkTokenValidity = useCallback(() => {
const accessToken = cookies.accessToken;
if (!accessToken) {
- logout();
+ console.info('No access token found, user not logged in.');
+ setOpenSnackbar(true); // Notify the user they are being redirected to login
+ setTimeout(() => {
+ setOpenSnackbar(false); // Close the notification
+ navigate('/login'); // Redirect to login after showing the notification
+ }, 3000); // Adjust the timeout duration as needed
return;
}
@@ -148,7 +159,6 @@ export default function AuthProvider({ children }) {
const { exp } = jwt_decode(accessToken);
const isTokenExpired = Date.now() >= exp * 1000;
if (isTokenExpired) {
- console.log('Token is invalid, logging out...');
logout();
}
} catch (error) {
@@ -161,6 +171,13 @@ export default function AuthProvider({ children }) {
useEffect(() => {
checkTokenValidity();
}, [checkTokenValidity]);
+ const renderSnackbar = (
+ }
+ />
+ );
const contextValue = useMemo(
() => ({
@@ -178,7 +195,9 @@ export default function AuthProvider({ children }) {
);
return (
- {children}
+
+ {children} {renderSnackbar}
+
);
}
diff --git a/src/context/MAIN_CONTEXT/CardContext/CardContext.jsx b/src/context/MAIN_CONTEXT/CardContext/CardContext.jsx
index f28052f..5dd2983 100644
--- a/src/context/MAIN_CONTEXT/CardContext/CardContext.jsx
+++ b/src/context/MAIN_CONTEXT/CardContext/CardContext.jsx
@@ -10,13 +10,11 @@ export const CardProvider = ({ children }) => {
searchData,
searchSettings,
setSearchSettings,
- // previousSearchData,
isDataValid,
setSearchData,
cardsVersion,
openConfigurator,
setOpenConfigurator,
- // setPreviousSearchData,
setIsDataValid,
clearSearchData,
handleRequest,
@@ -29,13 +27,11 @@ export const CardProvider = ({ children }) => {
searchData,
searchSettings,
setSearchSettings,
- // previousSearchData,
isDataValid,
setSearchData,
cardsVersion,
openConfigurator,
setOpenConfigurator,
- // setPreviousSearchData,
setIsDataValid,
clearSearchData,
handleRequest,
diff --git a/src/context/MAIN_CONTEXT/CartContext/CartContext.js b/src/context/MAIN_CONTEXT/CartContext/CartContext.js
index c7b954b..2327534 100644
--- a/src/context/MAIN_CONTEXT/CartContext/CartContext.js
+++ b/src/context/MAIN_CONTEXT/CartContext/CartContext.js
@@ -205,7 +205,6 @@ export const CartProvider = ({ children }) => {
console.error(error.message || 'Failed to create user cart');
}
}, [userId, fetchWrapper, setCartDataAndCookie]);
-
const fetchUserCart = useCallback(async () => {
const loadingID = 'fetchUserCart';
if (!userId || isLoading(loadingID)) return;
@@ -242,9 +241,6 @@ export const CartProvider = ({ children }) => {
setError,
logger,
]);
- // useEffect(() => {
- // if (!hasFetchedCart) fetchUserCart();
- // }, [fetchUserCart, userId, hasFetchedCart, setCartDataAndCookie]);
const updateCart = useCallback(
async (cartId, updatedCart, method, type) => {
if (!userId || !cartId) return;
@@ -281,80 +277,6 @@ export const CartProvider = ({ children }) => {
},
[userId, fetchWrapper, setCartDataAndCookie]
);
- // useEffect(() => {
- // if (userId) {
- // fetchUserCart(); // Fetch cart data when userId is available
- // }
- // }, [userId, fetchUserCart]);
- // useEffect to fetch and set cart data
- // useEffect(() => {
- // if (userId && isLoggedIn) {
- // fetchUserCart().catch((error) =>
- // console.error('Failed to fetch or create cart:', error)
- // );
- // }
- // }, [userId, fetchUserCart]);
- // useEffect(() => {
- // const newTotalQuantity = cartData?.cart?.reduce(
- // (total, item) => total + item?.quantity,
- // 0
- // );
- // setTotalQuantity(newTotalQuantity);
- // setTotalPrice(totalCost);
- // }, [cartData?.cart, totalCost]);
- // const updateCart = useCallback(
- // async (cartId, updatedCart, method, type) => {
- // if (!userId || !cartId) return;
-
- // const formattedCartData = {
- // userId: userId,
- // cart: updatedCart.map((item) => ({
- // id: item.id, // assuming id is the unique identifier for each cart item
- // quantity: item.quantity, // ensure this is the current quantity to be updated in the cart
- // price: item.price, // ensure this is the current price of the item
- // // Include other necessary fields as per your cart item structure
- // })),
- // method: method, // 'POST' for adding items, 'DELETE' for removing items, 'PUT' for updating items
- // type: type,
- // // Calculating total quantity and total price outside of the cart array
- // quantity: updatedCart.reduce((total, item) => total + item.quantity, 0),
- // totalPrice: updatedCart.reduce(
- // (total, item) => total + item.quantity * item.price,
- // 0
- // ),
- // };
-
- // try {
- // const response = await fetch(
- // `${process.env.REACT_APP_SERVER}/api/users/${userId}/cart/${cartId}/update`,
- // {
- // method: 'PUT',
- // headers: {
- // 'Content-Type': 'application/json',
- // },
- // body: JSON.stringify(formattedCartData),
- // }
- // );
-
- // const { message, data } = await response.json();
- // console.log('PUT: /cart -----> response message', message);
- // if (response.ok) {
- // console.log('PUT: /cart -----> response data', data);
- // setCartDataAndCookie(data); // Update your cart state and cookie here
- // } else {
- // console.error(
- // 'Failed to update cart: ',
- // data?.error || 'Error occurred'
- // );
- // // Handle errors appropriately (e.g., show an error message to the user)
- // }
- // } catch (error) {
- // console.error('Error updating cart: ', error);
- // // Handle errors appropriately (e.g., show an error message to the user)
- // }
- // },
- // [userId, setCartDataAndCookie] // dependencies array
- // );
const addCardsToCart = async (cards, cart) => {
console.log('ADD CARDS TO CART: ', cards, cart);
const newCards = [];
diff --git a/src/context/MAIN_CONTEXT/ChartContext/ChartContext.jsx b/src/context/MAIN_CONTEXT/ChartContext/ChartContext.jsx
index 63beabd..1902a38 100644
--- a/src/context/MAIN_CONTEXT/ChartContext/ChartContext.jsx
+++ b/src/context/MAIN_CONTEXT/ChartContext/ChartContext.jsx
@@ -11,26 +11,16 @@ export const ChartProvider = ({ children }) => {
const contextValue = useMemo(
() => ({
- // timeRange: selectedCollection.averagedChartData[],
- // timeRanges: TIME_RANGES,
- // tickValues: tickValues,
- // xFormat: xFormat,
-
nivoChartData: selectedCollection?.nivoChartData,
newNivoChartData: selectedCollection?.newNivoChartData,
muiChartData: selectedCollection?.muiChartData,
nivoTestData: selectedCollection?.nivoTestData,
- // setTimeRange,
}),
[
- // timeRange,
- // tickValues,
- // xFormat,
selectedCollection?.nivoChartData,
selectedCollection?.newNivoChartData,
selectedCollection?.muiChartData,
selectedCollection?.nivoTestData,
- // setTimeRange,
]
);
return (
diff --git a/src/context/MAIN_CONTEXT/CollectionContext/CollectionContext.jsx b/src/context/MAIN_CONTEXT/CollectionContext/CollectionContext.jsx
index 98c3780..18d5e5b 100644
--- a/src/context/MAIN_CONTEXT/CollectionContext/CollectionContext.jsx
+++ b/src/context/MAIN_CONTEXT/CollectionContext/CollectionContext.jsx
@@ -7,7 +7,7 @@ import {
useMemo,
useState,
} from 'react';
-import { calculateCollectionValue } from './collectionUtility';
+import { calculateCollectionValue } from '../../../assets/currentlyUnused/collectionUtility';
import { useAuthContext } from '../AuthContext/authContext';
import useCollectionManager from './useCollectionManager';
import { defaultContextValue } from '../../constants';
diff --git a/src/context/MAIN_CONTEXT/CollectionContext/collectionUtility.jsx b/src/context/MAIN_CONTEXT/CollectionContext/collectionUtility.jsx
deleted file mode 100644
index 3b087e8..0000000
--- a/src/context/MAIN_CONTEXT/CollectionContext/collectionUtility.jsx
+++ /dev/null
@@ -1,21 +0,0 @@
-/* eslint-disable @typescript-eslint/no-empty-function */
-export const calculateCollectionValue = (collection) => {
- if (!collection) return 0;
-
- const cards = collection?.cards;
-
- if (!Array.isArray(cards)) {
- console.warn('Invalid collection format', collection, cards);
- return 0;
- }
-
- return cards.reduce((totalValue, card) => {
- const cardPrice = card?.price || 0;
- const cardQuantity = card?.quantity || 0;
- return totalValue + cardPrice * cardQuantity;
- }, 0);
-};
-
-export const shouldFetchCollections = (prevUserId, currentUserId) => {
- return prevUserId !== currentUserId && currentUserId != null;
-};
diff --git a/src/context/MAIN_CONTEXT/CollectionContext/useCollectionManager.jsx b/src/context/MAIN_CONTEXT/CollectionContext/useCollectionManager.jsx
index 6dad84f..685665c 100644
--- a/src/context/MAIN_CONTEXT/CollectionContext/useCollectionManager.jsx
+++ b/src/context/MAIN_CONTEXT/CollectionContext/useCollectionManager.jsx
@@ -17,7 +17,6 @@ const useCollectionManager = () => {
showCollections,
selectedCollectionId,
customError: selectedCollectionError,
-
updateCollectionsData,
handleSelectCollection,
resetCollection,
@@ -110,14 +109,14 @@ const useCollectionManager = () => {
performAction(createApiUrl('create'), 'POST', data, 'createNewCollection');
const deleteCollection = (collectionId) =>
performAction(
- createApiUrl(`delete/${collectionId}`),
+ createApiUrl(`${collectionId}/delete`),
'DELETE',
{},
'deleteCollection'
);
const updateCollection = (collectionId, updatedData) =>
performAction(
- createApiUrl(`update/${collectionId}`),
+ createApiUrl(`${collectionId}/update`),
'PUT',
updatedData,
'updateCollection'
@@ -213,570 +212,3 @@ const useCollectionManager = () => {
};
export default useCollectionManager;
-// const validateParams = useCallback(
-// (data, expectedTypes, actionName) => {
-// let isValid = true;
-// const errors = [];
-
-// expectedTypes.forEach((type, index) => {
-// const actualType = Array.isArray(data[index])
-// ? 'array'
-// : typeof data[index];
-// if (actualType !== type) {
-// isValid = false;
-// errors.push(`Param ${index + 1}: Expected ${type}, got ${actualType}`);
-// }
-// });
-
-// if (!isValid) {
-// logger.logError(`[${actionName}] Validation errors: `, errors.join('; '));
-// }
-// return isValid;
-// },
-// [logger]
-// );
-// const createNewCollection = useCallback(
-// (data) => {
-// performAction(
-// createApiUrl('create'),
-// 'POST',
-// data,
-// 'createNewCollection',
-// {
-// paramTypes: ['object'],
-// beforeAction: () => console.log('Creating new collection...'),
-// afterAction: () => console.log('New collection created.'),
-// }
-// );
-// },
-// [performAction, createApiUrl]
-// );
-// const deleteCollection = useCallback(
-// (collectionId) => {
-// performAction(
-// createApiUrl('delete'),
-// 'DELETE',
-// {
-// collectionId,
-// },
-// 'deleteCollection',
-// ['string']
-// );
-// },
-// [performAction]
-// );
-// const updateCollection = useCallback(
-// (collectionId, updatedData) => {
-// performAction(
-// createApiUrl('update'),
-// 'PUT',
-// updatedData,
-// 'updateCollection',
-// ['string', 'object']
-// );
-// },
-// [performAction]
-// );
-// const updateCollection = useCallback(
-// (collectionId, updatedData) => {
-// performAction(
-// `/update/${collectionId}`,
-// 'PUT',
-// updatedData,
-// 'updateCollection',
-// ['string', 'object']
-// );
-// },
-// [performAction]
-// );
-// const updateCardInCollection = useCallback(
-// (collectionId, cardId, updatedData) => {
-// if (
-// !validateParams(
-// [collectionId, cardId, updatedData],
-// ['string', 'string', 'object']
-// )
-// ) {
-// logger.logError('Invalid parameter types for updateCardInCollection.');
-// return;
-// }
-// performAction(
-// `/updateCard/${collectionId}/${cardId}`,
-// 'PUT',
-// updatedData,
-// 'updateCardInCollection'
-// );
-// },
-// [performAction, logger]
-// );
-// /**
-// * Updates the chart data for a specific collection.
-// * @param {string} userId - The ID of the user who owns the collection.
-// * @param {string} collectionId - The ID of the collection for which chart data is being updated.
-// * @param {Object} chartData - The updated chart data for the collection. The structure of this data depends on how chart data is managed in your application.
-// * @returns {Promise
+ {shouldShowIcons && sorted && (
- arrow_drop_up
-
-
- arrow_drop_down
+
+ arrow_drop_up
+
+
+ arrow_drop_down
+
-
- )}
+ )}
+
-
- );
-}
+ );
+ };
-// Setting default values for the props of DataTableHeadCell
-DataTableHeadCell.defaultProps = {
- width: 'auto',
- sorted: 'none',
- align: 'left',
+ return useMemo(
+ () => (
+ <>
+ {headerGroups.map((headerGroup, key) => (
+
+ {headerGroup.headers.map(renderCellContent)}
+
+ ))}
+ >
+ ),
+ [
+ headerGroups,
+ isSorted,
+ setSortedValue,
+ theme.palette.divider,
+ theme.typography.fontWeightMedium,
+ ]
+ );
};
-// Typechecking props for the DataTableHeadCell
DataTableHeadCell.propTypes = {
- width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
- children: PropTypes.node.isRequired,
- sorted: PropTypes.oneOf([false, 'none', 'asce', 'desc']),
- align: PropTypes.oneOf(['left', 'right', 'center']),
+ headerGroups: PropTypes.array.isRequired,
+ isSorted: PropTypes.bool.isRequired,
+ setSortedValue: PropTypes.func.isRequired,
};
export default DataTableHeadCell;
diff --git a/src/layout/collection/collectionGrids/cards-datatable/DataTableHeadComponent.jsx b/src/layout/collection/collectionGrids/cards-datatable/DataTableHeadComponent.jsx
deleted file mode 100644
index e382b4d..0000000
--- a/src/layout/collection/collectionGrids/cards-datatable/DataTableHeadComponent.jsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { TableRow } from '@mui/material';
-import MDBox from '../../../REUSABLE_COMPONENTS/MDBOX';
-import DataTableHeadCell from './DataTableHeadCell';
-
-export const DataTableHeadComponent = (props) => {
- const {
- onSelectAllClick,
- order,
- orderBy,
- numSelected,
- rowCount,
- onRequestSort,
- headerGroups,
- isSorted,
- setSortedValue,
- } = props;
- const createSortHandler = (property) => (event) => {
- onRequestSort(event, property);
- };
-
- return (
-
- {headerGroups?.map((headerGroup, key) => (
-
- {/*
- 0 && numSelected < rowCount}
- checked={rowCount > 0 && numSelected === rowCount}
- onChange={onSelectAllClick}
- />
- */}
- {headerGroup.headers.map((column, idx) => (
-
- {column.render('Header')}
-
- ))}
-
- ))}
-
- );
-};
diff --git a/src/layout/collection/collectionGrids/cards-datatable/OptionsComponent.jsx b/src/layout/collection/collectionGrids/cards-datatable/OptionsComponent.jsx
deleted file mode 100644
index c5fdad8..0000000
--- a/src/layout/collection/collectionGrids/cards-datatable/OptionsComponent.jsx
+++ /dev/null
@@ -1,53 +0,0 @@
-// OptionsComponent.jsx
-import React from 'react';
-import MDBox from '../../../REUSABLE_COMPONENTS/MDBOX';
-import { Autocomplete, Grid, TextField } from '@mui/material';
-
-const OptionsComponent = ({
- canSearch,
- search,
- handleSearchChange,
- pageSize,
- setPageSize,
- pageOptions,
-}) => (
-
-
- {canSearch && (
-
-
-
- )}
-
- setPageSize(parseInt(newValue, 10))}
- options={pageOptions?.map((option) => option?.toString())}
- renderInput={(params) => (
-
- )}
- />
-
-
-
-);
-
-export default OptionsComponent;
diff --git a/src/layout/collection/collectionGrids/cards-datatable/index.jsx b/src/layout/collection/collectionGrids/cards-datatable/index.jsx
index 64c80d3..8c371b9 100644
--- a/src/layout/collection/collectionGrids/cards-datatable/index.jsx
+++ b/src/layout/collection/collectionGrids/cards-datatable/index.jsx
@@ -13,25 +13,14 @@ import {
import Table from '@mui/material/Table';
import TableContainer from '@mui/material/TableContainer';
import TableRow from '@mui/material/TableRow';
-import Icon from '@mui/material/Icon';
import DataTableBodyCell from './DataTableBodyCell';
-import useScreenWidth from '../../../../context/hooks/useScreenWidth';
-import {
- Box,
- Button,
- Checkbox,
- Grid,
- Paper,
- TableBody,
- TextField,
-} from '@mui/material';
+import { Box, Button, Checkbox, Grid, Paper, TableBody } from '@mui/material';
import PaginationComponent from './PaginationComponent';
-import OptionsComponent from './OptionsComponent';
-import { DataTableHeadComponent } from './DataTableHeadComponent';
-import BoxHeader from '../../../REUSABLE_COMPONENTS/BoxHeader';
+import OptionsComponent from '../../../../components/forms/OptionsComponent';
import GenericActionButtons from '../../../../components/buttons/actionButtons/GenericActionButtons';
-import { enqueueSnackbar } from 'notistack';
import { useMode } from '../../../../context';
+import DataTableHeadCell from './DataTableHeadCell';
+import FlexBetween from '../../../REUSABLE_COMPONENTS/FlexBetween';
const setSortedValue = (column, isSorted) => {
let sortedValue;
@@ -55,25 +44,15 @@ function DataTable({
noEndBorder,
tableSize,
}) {
- // ** New Custom Breakpoints for Tracking Visible Table Data **
- // 800px - hide total price
- // 650px = hide quantity
- // 500px - hdie check box
const { theme } = useMode();
const [showTotalPrice, setShowTotalPrice] = useState(window.innerWidth > 800);
- const [showQuantity, setShowQuantity] = useState(window.innerWidth > 650);
const [showSelection, setShowSelection] = useState(window.innerWidth > 500);
- const [showPrice, setShowPrice] = useState(window.innerWidth > 445);
useEffect(() => {
const handleResize = () => {
setShowTotalPrice(window.innerWidth > 800);
- setShowQuantity(window.innerWidth > 650);
setShowSelection(window.innerWidth > 500);
- setShowPrice(window.innerWidth > 445);
};
-
window.addEventListener('resize', handleResize);
-
return () => {
window.removeEventListener('resize', handleResize);
};
@@ -82,47 +61,38 @@ function DataTable({
const data = useMemo(() => table.data, [table.data]);
const columns = useMemo(() => {
let baseColumns = [
- // Only include the selection column if showSelection is true
showSelection && {
id: 'selection',
+ showIcons: false,
Header: ({ getToggleAllRowsSelectedProps }) => (
),
Cell: ({ row }) => ,
+ // Apply a fixed width to the checkbox column
+ // width: 30, // Adjust the width as needed
+ // minWidth: 30, // Ensure it doesn't get smaller than the set width
+ // maxWidth: 30, // Ensure it doesn't get larger than the set width
},
{ Header: 'Name', accessor: 'name' },
- // { Header: 'Price', accessor: 'price' },
+ { Header: 'Price', accessor: 'price' },
+
+ { Header: 'Quantity', accessor: 'quantity', showIcons: false },
{
id: 'action',
Header: 'Action',
accessor: 'action',
+ showIcons: false,
+
Cell: ({ value }) => (
console.log('clicked')}
- onSuccess={() =>
- enqueueSnackbar(
- {
- title: 'Action successful',
- message: `Card added to ${value} successfully.`,
- },
- 'success',
- null
- )
- }
- onFailure={(error) =>
- enqueueSnackbar(
- {
- title: 'Action failed',
- message: `Failed to add card to ${value}.`,
- },
- 'error',
- error
- )
- }
+ onSuccess={() => console.log('success')}
+ onFailure={(error) => console.log(error)}
page={'Collection'}
cardSize={'small'}
+ variant="data-table"
/>
),
},
@@ -133,21 +103,9 @@ function DataTable({
accessor: 'tPrice',
});
}
- if (tableSize !== 'large' && showQuantity) {
- baseColumns.push({
- Header: 'Quantity',
- accessor: 'quantity',
- });
- }
- if (tableSize !== 'large' && showPrice) {
- baseColumns.push({
- Header: 'Price',
- accessor: 'price',
- });
- }
// Filter out any falsey values to remove the conditionally included columns when not shown
return baseColumns.filter(Boolean);
- }, [showTotalPrice, showQuantity, showSelection, tableSize, showPrice]);
+ }, [showTotalPrice, showSelection, tableSize]);
const defaultPageSize = useMemo(
() => entriesPerPage.defaultValue,
@@ -228,6 +186,9 @@ function DataTable({
'& .MuiDataGrid-columnSeparator': {
visibility: 'hidden',
},
+ '& .MuiTableRow-root': {
+ flexGrow: 1,
+ },
}}
>
@@ -241,56 +202,73 @@ function DataTable({
pageOptions={pageSizeOptions}
/>
{/* Table */}
-
- {}}
- headerGroups={headerGroups}
- isSorted={isSorted}
- setSortedValue={setSortedValue}
- />
- {/* Table Body */}
-
- {page.map((row, key) => {
- prepareRow(row);
- return (
-
- {row.cells.map((cell, idx) => (
-
- {cell.render('Cell')}
-
- ))}
-
- );
- })}
-
-
+
+
+
+ {}}
+ headerGroups={headerGroups}
+ isSorted={isSorted}
+ setSortedValue={setSortedValue}
+ />
+
+ {/* Table Body */}
+
+ {page.map((row, key) => {
+ prepareRow(row);
+ return (
+
+ {' '}
+
+ {row.cells.map((cell, idx) => (
+
+ {cell.render('Cell')}
+
+ ))}
+
+
+ );
+ })}
+
+
+
{/* Pagination */}
-
+
+
+
);
diff --git a/src/layout/collection/collectionGrids/cards-datatable/useSkeletonLoader.jsx b/src/layout/collection/collectionGrids/cards-datatable/useSkeletonLoader.jsx
index c296376..3eedab4 100644
--- a/src/layout/collection/collectionGrids/cards-datatable/useSkeletonLoader.jsx
+++ b/src/layout/collection/collectionGrids/cards-datatable/useSkeletonLoader.jsx
@@ -1,5 +1,6 @@
import React from 'react';
-import { Skeleton, Box, Stack, Grid } from '@mui/material';
+import { Box, Stack, Grid } from '@mui/material';
+import { Skeleton } from '@mui/joy';
// Enhanced skeleton configurations for a wider variety of types
const skeletonVariants = {
@@ -116,45 +117,6 @@ const useSkeletonLoader = () => {
},
...props
}) => {
- // if (type === 'grid') {
- // const { variant, width, height } = skeletonVariants.grid;
- // const typesKeyMap = contentProps.types.reduce(
- // (acc, type) => ({ ...acc, [contentProps.numOfItems]: type }),
- // {}
- // );
- // console.log(typesKeyMap);
- // const selectedVariant = typesKeyMap[count] || variant;
-
- // // Render skeletons within Grid container for 'grid' type
- // return (
- //
- // {Array.from({ length: count }, (_, index) => (
- //
- // {/* Customize Grid item props as needed */}
- //
- //
- // ))}
- //
- // );
- // }
- // const skeletonVariants = {
- // grid: { variant: 'rect', width: 210, height: 118 },
- // text: { variant: 'text', width: '100%', height: 20, marginBottom: 1 },
- // // Add other types as needed...
- // };
-
const generateVariantSequence = () => {
return contentProps?.typeData?.flatMap((item) =>
Array.from({ length: item.num }, () => item.type)
@@ -182,6 +144,25 @@ const useSkeletonLoader = () => {
);
}
+ if (type === 'pieChart') {
+ return (
+
+ {' '}
+ {/* */}
+
+ );
+ }
const { variant, width, height, marginBottom } =
skeletonVariants[type] || skeletonVariants.text;
diff --git a/src/layout/collection/collectionGrids/collections-list/CollectionListItem.jsx b/src/layout/collection/collectionGrids/collections-list/CollectionListItem.jsx
index ad57aa1..9510cd2 100644
--- a/src/layout/collection/collectionGrids/collections-list/CollectionListItem.jsx
+++ b/src/layout/collection/collectionGrids/collections-list/CollectionListItem.jsx
@@ -1,175 +1,187 @@
-/* eslint-disable react/display-name */
-import React, { memo, useCallback, useRef, useState } from 'react';
-import { Card, CardActionArea, Grid, Tooltip } from '@mui/material';
-import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward';
-import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
-import PropTypes from 'prop-types';
+import React, { memo, useCallback } from 'react';
import {
- useAuthContext,
- useMode,
- useVisibilityContext,
-} from '../../../../context';
-import LongMenu from '../../../../layout/navigation/LongMenu';
-import useCollectionVisibility from '../../../../context/hooks/useCollectionVisibility';
+ Box,
+ Card,
+ CardActionArea,
+ CardContent,
+ Grid,
+ Tooltip,
+} from '@mui/material';
+import PropTypes from 'prop-types';
import MDBox from '../../../../layout/REUSABLE_COMPONENTS/MDBOX';
-import MDTypography from '../../../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-import {
- StyledCollectionListCard,
- StyledCollectionListCardContent,
-} from '../../../../pages/pageStyles/StyledComponents';
import useCollectionManager from '../../../../context/MAIN_CONTEXT/CollectionContext/useCollectionManager';
-import CollectionDialog from '../../../../components/dialogs/CollectionDialog';
import useSelectedCollection from '../../../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
import useDialogState from '../../../../context/hooks/useDialogState';
-import SimpleCard from '../../../REUSABLE_COMPONENTS/unique/SimpleCard';
-import uniqueTheme from '../../../REUSABLE_COMPONENTS/unique/uniqueTheme';
+import { useMode } from '../../../../context';
+import CollectionDialog from '../../../../components/dialogs/CollectionDialog';
+import LongMenu from '../../../../layout/navigation/LongMenu';
+import MDTypography from '../../../REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
+import RCChange from '../../../REUSABLE_COMPONENTS/RC/RCChange';
+import RCInfoItem from '../../../REUSABLE_COMPONENTS/RCInfoItem';
+import { useVisibility } from '../../../../context/hooks/useVisibility';
+import { roundToNearestTenth } from '../../../../context/Helpers';
-const CollectionInfoItem = ({ label, value, sx }) => (
-
-
-
- {label}: {value}
-
-
- {/*
- {label}: {value}
- */}
-
-);
+// const CollectionInfoItem = ({ label, value, theme }) => (
+//
+//
+//
+// {`${label}:`}
+//
+//
+// {value}
+//
+//
+//
+// );
+
+// CollectionInfoItem.propTypes = {
+// label: PropTypes.string.isRequired,
+// value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
+// theme: PropTypes.object.isRequired,
+// };
const CollectionListItem = memo(({ collection }) => {
const { theme } = useMode();
- const roundToNearestTenth = (number) => Math.ceil(number / 10) * 10;
- const ref = useRef(null);
const { deleteCollection } = useCollectionManager();
- const {
- handleBackToCollections,
- showCollections,
- selectedCollection,
- handleSelectCollection,
- toggleShowCollections,
- } = useSelectedCollection();
- const {
- isCollectionVisible,
- toggleCollectionVisibility,
- // dialogStates,
- // toggleDialog,
- } = useVisibilityContext();
-
+ const { handleSelectCollection } = useSelectedCollection();
const { dialogState, openDialog, closeDialog } = useDialogState({
isEditCollectionDialogOpen: false,
});
+
const handleOpenDialog = useCallback((collection) => {
- openDialog('editCollectionDialog', collection);
- console.log(collection);
- }, []);
- const handleCloseDialog = useCallback(() => {
- closeDialog('editCollectionDialog');
+ openDialog('isEditCollectionDialogOpen', collection);
}, []);
const handleDelete = async () => {
await deleteCollection(collection?._id);
- // setShowOptions(false); // Close the options menu after deletion
};
+
const renderToolTip = () => (
-
- handleOpenDialog(collection)}
- onDelete={handleDelete} // Pass the async delete function
- onSelect={() => handleSelectCollection(collection)}
- onHide={() => toggleShowCollections(false)}
- onStats={() => console.log('Stats:', collection)}
- onView={() => console.log('View:', collection)}
- // onClose={() => setShowOptions(false)}
- collectionId={collection?._id}
- ref={ref}
- />
-
+ handleOpenDialog(collection)}
+ onDelete={handleDelete}
+ onSelect={() => handleSelectCollection(collection)}
+ // onHide={() => toggleShowCollections(false)}
+ collectionId={collection?._id}
+ collection={collection}
+ />
);
- const renderPercentageChange = useCallback(() => {
- const percentageChange =
- collection?.collectionStatistics?.percentageChange || 0;
- return (
- 0 ? 'success' : 'error'}
- sx={{ display: 'flex', alignItems: 'center' }}
- >
- {percentageChange > 0 ? : }
- {percentageChange}%
-
- );
- }, [collection]);
+
+ const percentageChange =
+ collection?.collectionStatistics?.percentageChange || 0;
+
const handleSelection = useCallback(() => {
handleSelectCollection(collection);
- toggleCollectionVisibility();
+ // toggleShowCollections();
}, [collection]);
return (
-
-
-
-
-
-
-
-
- {renderPercentageChange()}
-
-
+
+
+
+
+
+
+
+ 0}
+ change={percentageChange}
+ rangeLevel="24hr" // Default value; replace with actual data if available
/>
-
+
- {renderToolTip()}
+
+
+ {renderToolTip()}
+
+
+ {/* */}
{dialogState.isEditCollectionDialogOpen && (
handleCloseDialog()}
+ onClose={() => closeDialog('isEditCollectionDialogOpen')}
+ // onClose={() => closeDialog('isAddDeckDialogOpen')}
+ collectionData={collection}
isNew={false}
- collectionMode="edit"
- collectionData={{
- name: collection?.name,
- description: collection?.description,
- }}
/>
)}
-
+
);
});
+CollectionListItem.displayName = 'CollectionListItem';
+
CollectionListItem.propTypes = {
collection: PropTypes.object.isRequired,
- isSelected: PropTypes.bool,
-};
-
-CollectionListItem.defaultProps = {
- isSelected: false,
};
export default CollectionListItem;
diff --git a/src/layout/collection/collectionGrids/collections-list/SelectCollectionHeader.jsx b/src/layout/collection/collectionGrids/collections-list/SelectCollectionHeader.jsx
index 3ddb427..9002817 100644
--- a/src/layout/collection/collectionGrids/collections-list/SelectCollectionHeader.jsx
+++ b/src/layout/collection/collectionGrids/collections-list/SelectCollectionHeader.jsx
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
-import { Grid, Button, Box } from '@mui/material';
+import { Grid, Button, Box, useMediaQuery } from '@mui/material';
import {
useAuthContext,
useFormContext,
@@ -7,42 +7,13 @@ import {
useUserContext,
} from '../../../../context';
import { Card, Typography } from '@mui/joy';
-import MDButton from '../../../REUSABLE_COMPONENTS/MDBUTTON';
-import CustomButton from '../../../../components/buttons/other/CustomButton';
import useSkeletonLoader from '../cards-datatable/useSkeletonLoader';
-import IconStatWrapper from '../../../REUSABLE_COMPONENTS/unique/IconStatWrapper';
import uniqueTheme from '../../../REUSABLE_COMPONENTS/unique/uniqueTheme';
import SimpleButton from '../../../REUSABLE_COMPONENTS/unique/SimpleButton';
import styled from 'styled-components';
import SimpleCard from '../../../REUSABLE_COMPONENTS/unique/SimpleCard';
-import FlexBetween from '../../../REUSABLE_COMPONENTS/FlexBetween';
import SimpleSectionHeader from '../../../REUSABLE_COMPONENTS/unique/SimpleSectionHeader';
-import MDBox from '../../../REUSABLE_COMPONENTS/MDBOX';
-const StyledButtonWrapper = styled.div`
- margin-bottom: 1rem;
-`;
-const SelectCollectionHeaderSkeleton = () => {
- const { SkeletonLoader } = useSkeletonLoader();
-
- return (
-
-
-
-
-
-
-
-
-
-
-
- );
-};
+import { PageHeaderSkeleton } from '../../../REUSABLE_COMPONENTS/SkeletonVariants';
const FlexContainer = styled(Box)`
display: flex;
@@ -52,12 +23,12 @@ const FlexContainer = styled(Box)`
padding: ${({ theme }) => theme.spacing(1, 2)};
`;
-const HeaderContainer = styled.div`
+const HeaderContainer = styled(Box)`
flex: 1;
- max-width: 25%;
+ max-width: 50%;
`;
-const ButtonContainer = styled.div`
+const ButtonContainer = styled(Box)`
flex: 1;
display: flex;
justify-content: flex-end;
@@ -68,9 +39,8 @@ const SelectCollectionHeader = ({ openNewDialog }) => {
const { theme } = useMode();
const { setCurrentForm } = useFormContext();
const { user } = useUserContext();
-
if (!user) {
- return ;
+ return ;
}
return (
diff --git a/src/layout/collection/collectionGrids/collections-list/SelectCollectionList.jsx b/src/layout/collection/collectionGrids/collections-list/SelectCollectionList.jsx
index d4dc736..6e4300f 100644
--- a/src/layout/collection/collectionGrids/collections-list/SelectCollectionList.jsx
+++ b/src/layout/collection/collectionGrids/collections-list/SelectCollectionList.jsx
@@ -1,77 +1,4 @@
-// import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
-// import {
-// Box,
-// Card,
-// CardActionArea,
-// Collapse,
-// Grid,
-// List,
-// Skeleton,
-// } from '@mui/material';
-// import PropTypes from 'prop-types';
-// import { TransitionGroup } from 'react-transition-group';
-// import CollectionListItem from './CollectionListItem';
-// import useSelectedCollection from '../../../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
-// import SimpleCard from '../../../REUSABLE_COMPONENTS/unique/SimpleCard';
-// import uniqueTheme from '../../../REUSABLE_COMPONENTS/unique/uniqueTheme';
-// import FlexBetween from '../../../REUSABLE_COMPONENTS/FlexBetween';
-// //
-// //
-// const CollectionListItemSkeleton = ({ count }) => {
-// return (
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-// );
-// };
-
-// CollectionListItemSkeleton.propTypes = {
-// count: PropTypes.number,
-// };
-
-// CollectionListItemSkeleton.displayName = 'CollectionListItemSkeleton';
-
-// const SelectCollectionList = ({ openDialog }) => {
-// const { allCollections } = useSelectedCollection();
-// const minListSize = 5;
-// const collectionCount = allCollections?.length || 0;
-// const skeletonsNeeded = Math.max(0, minListSize - collectionCount);
-
-// return (
-//
-//
-//
-// {allCollections?.map((collection, index) => (
-//
-//
-// {skeletonsNeeded > 0 && (
-//
-// )}
-//
-// ))}
-//
-//
-//
-// );
-// };
-
-// SelectCollectionList.propTypes = {
-// openDialog: PropTypes.func.isRequired,
-// };
-
-// export default SelectCollectionList;
-import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
+import React, { memo, useEffect, useRef, useState } from 'react';
import {
Box,
Card,
@@ -88,64 +15,78 @@ import useSelectedCollection from '../../../../context/MAIN_CONTEXT/CollectionCo
import styled from 'styled-components';
import SimpleCard from '../../../REUSABLE_COMPONENTS/unique/SimpleCard';
import uniqueTheme from '../../../REUSABLE_COMPONENTS/unique/uniqueTheme';
-const FlexContainer = styled(Box)`
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 100%;
- padding: ${({ theme }) => theme.spacing(1, 2)};
-`;
-const CollectionListItemSkeleton = ({ count }) => {
- return [...Array(count).keys()].map((index) => (
-
-
-
-
-
-
-
-
-
-
-
-
-
- ));
-};
+import { CollectionListItemSkeleton } from '../../../REUSABLE_COMPONENTS/SkeletonVariants';
-CollectionListItemSkeleton.propTypes = {
- count: PropTypes.number.isRequired,
-};
+const SelectCollectionList = ({
+ openDialog,
+ handleSelectAndShowCollection,
+}) => {
+ const {
+ allCollections,
+ allIds,
+ handleSelectCollection,
+ toggleShowCollections,
+ } = useSelectedCollection();
+ const [collectionList, setCollectionList] = useState([]);
+ const numCollections = allIds?.length || 0;
+ const nonSkeletonCount = useRef(0);
+
+ useEffect(() => {
+ const minItems = 5;
+ const numRequired =
+ minItems - numCollections > 0 ? minItems - numCollections : 0;
+ nonSkeletonCount.current = numCollections;
+
+ const allSkeletonCollections = [...Array(numRequired).keys()].map(
+ (index) => (
+
+ )
+ );
+ const combinedCollections = allCollections
+ .map((collection, index) => (
+
+ {
+ handleSelectAndShowCollection(collection);
+ }}
+ >
+
+
+
+ ))
+ .concat(allSkeletonCollections);
+
+ setCollectionList(combinedCollections);
+ }, [allIds?.length]); // Dependency on allIds.length instead of allIds and allCollections
-const SelectCollectionList = ({ openDialog }) => {
- const { allCollections } = useSelectedCollection();
- // const [skeletonCount, setSkeletonCount] = useState(0);
- const listRef = useRef();
- const minItems = 5;
- const numRequired = minItems - (allCollections?.length || 0);
- const allSkeletonCollections = [...Array(numRequired).keys()].map((index) => (
-
- ));
- const combinedCollections = [...allCollections, ...allSkeletonCollections];
return (
- {combinedCollections?.map((collection, index) => (
-
-
-
- ))}
- {/* */}
+ {collectionList?.map((item, index) =>
+ React.isValidElement(item) ? (
+ item
+ ) : (
+
+ )
+ )}
diff --git a/src/layout/collection/collectionGrids/collections-list/StatBoard.jsx b/src/layout/collection/collectionGrids/collections-list/StatBoard.jsx
index c30585a..2b2a27f 100644
--- a/src/layout/collection/collectionGrids/collections-list/StatBoard.jsx
+++ b/src/layout/collection/collectionGrids/collections-list/StatBoard.jsx
@@ -1,40 +1,87 @@
-import { Grid } from '@mui/material';
+/* eslint-disable react/jsx-key */
+import { Box, Grid, Typography, Skeleton } from '@mui/material';
// import PieChart from './statItems/PieChart';
-// import TotalPriceStatBox from './statItems/TotalPriceStatBox';
+import TotalPriceStatBox from './statItems/TotalPriceStatBox';
// import ValuDistributionCircle from './statItems/ValuDistributionCircle';
// import PricedCardList from './statItems/PricedCardList';
import SimpleCard from '../../../REUSABLE_COMPONENTS/unique/SimpleCard';
import uniqueTheme from '../../../REUSABLE_COMPONENTS/unique/uniqueTheme';
-import { ChartArea } from '../../../../pages/pageStyles/StyledComponents';
-import NivoContainer from '../cards-chart/NivoContainer';
-import { useMode } from '../../../../context';
+import { useAppContext, useMode } from '../../../../context';
import ValuDistributionCircle from './statItems/ValuDistributionCircle';
import PricedCardList from './statItems/PricedCardList';
-import ZenEnso from '../../../../assets/animations/ZenEnso';
+import PerformanceStatBox from './statItems/PerformanceStatBox';
import MDBox from '../../../REUSABLE_COMPONENTS/MDBOX';
-// import ValueDistPieChart from './statItems/ValueDistPieChart';
+import styled from 'styled-components';
+import TotalCardsCollectedStatBox from './statItems/TotalCardsCollectedStatBox';
+import FlexBetween from '../../../REUSABLE_COMPONENTS/FlexBetween';
-// const StatBoard = () => {
-// return (
-//
-//
-// {item}
-//
-//
-// {item}
-//
-//
-// {item}
-//
-//
-// );
-// };
+const SkeletonPieChart = ({ theme }) => (
+
+
+ Collection Value Distribution
+
+
+
+);
-const StatBoard = () => {
+const StatBoxes = () => {
+ const { theme } = useMode();
+ return (
+
+
+
+
+ );
+};
+const DistCircle = () => {
const { theme } = useMode();
+ const colors = theme.palette.chartTheme;
+ const { allCollections } = useAppContext();
+ if (!allCollections || allCollections.length === 0) {
+ return (
+
+
+
+ );
+ }
+ return (
+
+
+
+ );
+};
+
+const PriceList = () => {
+ const { theme } = useMode();
+ const colors = theme.palette.chartTheme;
+
+ return (
+
+
+
+ );
+};
+const StatBoard = () => {
return (
{
>
- {/*
-
-
- {' '}
- */}
- {/* */}
- {/* */}
- {/*
-
- */}
- {/* */}
- {/*
- {/*
-
- */}
- {/*
-
- */}
-
-
-
+ {[, , ].map(
+ (component, index) => (
+
+
+ {component}
+
+
+ )
+ )}
);
diff --git a/src/layout/collection/collectionGrids/collections-list/statItems/PerformanceStatBox.jsx b/src/layout/collection/collectionGrids/collections-list/statItems/PerformanceStatBox.jsx
new file mode 100644
index 0000000..0cae726
--- /dev/null
+++ b/src/layout/collection/collectionGrids/collections-list/statItems/PerformanceStatBox.jsx
@@ -0,0 +1,52 @@
+import { Box, Typography } from '@mui/material';
+import StatBox from '../../../../REUSABLE_COMPONENTS/StatBox';
+// import useCollectionStats from '../../../../../context/MAIN_CONTEXT/CollectionContext/useCollectionStats';
+import { useAppContext, useMode } from '../../../../../context';
+import MonetizationOnIcon from '@mui/icons-material/MonetizationOn';
+import ProgressCircle from '../../../../REUSABLE_COMPONENTS/ProgressCircle';
+import MDBox from '../../../../REUSABLE_COMPONENTS/MDBOX';
+import StackedLineChartRoundedIcon from '@mui/icons-material/StackedLineChartRounded';
+const PerformanceStatBox = () => {
+ const { theme } = useMode();
+ const colors = theme.palette.chartTheme;
+ const primary = colors.primary.dark;
+ const greenAccent = colors.greenAccent.light;
+ // const primary = colors.primary.default;
+ // const blue = colors.blueAccent.default;
+ const green = colors.greenAccent.default;
+ const greenliht = colors.greenAccent.light;
+
+ const grey = colors.grey.default;
+ const { collectionMetaData } = useAppContext();
+
+ return (
+
+
+ }
+ />
+
+ );
+};
+
+export default PerformanceStatBox;
diff --git a/src/layout/collection/collectionGrids/collections-list/statItems/PieChart.jsx b/src/layout/collection/collectionGrids/collections-list/statItems/PieChart.jsx
deleted file mode 100644
index 0c36f5c..0000000
--- a/src/layout/collection/collectionGrids/collections-list/statItems/PieChart.jsx
+++ /dev/null
@@ -1,232 +0,0 @@
-import { mockPieData as data } from '../../../data/mockData';
-import { useMode } from '../../../../../context';
-import { ResponsivePie } from '@nivo/pie';
-
-const PieChart = () => {
- // const { theme } = useMode();
- // const colors = theme.palette.chartTheme;
- // const lightGrey = colors.grey.lightest;
- return (
-
- );
-};
-
-export default PieChart;
diff --git a/src/layout/collection/collectionGrids/collections-list/statItems/PricedCardList.jsx b/src/layout/collection/collectionGrids/collections-list/statItems/PricedCardList.jsx
index a255e6c..faaecad 100644
--- a/src/layout/collection/collectionGrids/collections-list/statItems/PricedCardList.jsx
+++ b/src/layout/collection/collectionGrids/collections-list/statItems/PricedCardList.jsx
@@ -1,108 +1,82 @@
import MDBox from '../../../../REUSABLE_COMPONENTS/MDBOX';
import BoxHeader from '../../../../REUSABLE_COMPONENTS/BoxHeader';
-import useSelectedCollection from '../../../../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
-import useCollectionStats from '../../../../../context/MAIN_CONTEXT/CollectionContext/useCollectionStats';
-import { Box } from '@mui/material';
-import { useMode } from '../../../../../context';
+import { Box, Card, CardContent } from '@mui/material';
+import { useAppContext, useMode } from '../../../../../context';
import { DataGrid } from '@mui/x-data-grid';
import prepareTableData from '../../../data/topCards';
+import styled from 'styled-components';
+import { useMemo } from 'react';
const PricedCardList = () => {
- const { collectionStats, metaStats } = useCollectionStats();
- const { selectedCollection } = useSelectedCollection();
- const { data, columns } = prepareTableData(selectedCollection);
const { theme } = useMode();
const colors = theme.palette.chartTheme;
- const grey = theme.palette.chartTheme.grey.darkest;
- const lightGrey = theme.palette.chartTheme.grey.lightest;
-
- const greenAccent = colors.greenAccent.default;
-
- // const renderCurrency = (params) => `$${params.value}`;
-
- // const productColumns = [
- // {
- // field: '_id',
- // headerName: 'ID',
- // flex: 1,
- // },
- // {
- // field: 'expense',
- // headerName: 'Expense',
- // flex: 0.5,
- // renderCell: renderCurrency,
- // },
- // {
- // field: 'price',
- // headerName: 'Price',
- // flex: 0.5,
- // renderCell: renderCurrency,
- // },
- // ];
-
- // const countItems = (params) => params.value.length;
-
- // const transactionColumns = [
- // {
- // field: '_id',
- // headerName: 'ID',
- // flex: 1,
- // },
- // {
- // field: 'buyer',
- // headerName: 'Buyer',
- // flex: 0.67,
- // },
- // {
- // field: 'amount',
- // headerName: 'Amount',
- // flex: 0.35,
- // renderCell: renderCurrency,
- // },
- // {
- // field: 'productIds',
- // headerName: 'Count',
- // flex: 0.1,
- // renderCell: countItems,
- // },
- // ];
-
- // Assuming productData is available in your context or props
- // const productData = []; // Placeholder for actual data
+ const grey = colors.grey.darkest;
+ const lightGrey = colors.grey.lightest;
+ const primary = colors.primary.dark;
+ const greenAccent = colors.greenAccent.light;
+ const { cardsWithQuantities } = useAppContext();
+ const topFiveCards = useMemo(() => {
+ return cardsWithQuantities?.sort((a, b) => b.price - a.price).slice(0, 5);
+ }, [cardsWithQuantities]);
+ const { data, columns } = useMemo(
+ () => prepareTableData(topFiveCards),
+ [topFiveCards]
+ );
return (
-
-
+
-
+
+
+ acc + card.price, 0)}`}
+ colorVariant={greenAccent}
+ useSX={true}
+ titleVariant="h5"
+ paddingVariant={theme.spacing(2)}
+ sx={{
+ color: greenAccent,
+ }}
+ />
+
+
+
+
+
);
diff --git a/src/layout/collection/collectionGrids/collections-list/statItems/TotalCardsCollectedStatBox.jsx b/src/layout/collection/collectionGrids/collections-list/statItems/TotalCardsCollectedStatBox.jsx
new file mode 100644
index 0000000..bdc48bd
--- /dev/null
+++ b/src/layout/collection/collectionGrids/collections-list/statItems/TotalCardsCollectedStatBox.jsx
@@ -0,0 +1,42 @@
+import { Box } from '@mui/material';
+import StatBox from '../../../../REUSABLE_COMPONENTS/StatBox';
+// import useCollectionStats from '../../../../../context/MAIN_CONTEXT/CollectionContext/useCollectionStats';
+import { useAppContext, useMode } from '../../../../../context';
+import styled from 'styled-components';
+import FormatListNumberedRoundedIcon from '@mui/icons-material/FormatListNumberedRounded';
+const TotalCardsCollectedStatBox = () => {
+ const { theme } = useMode();
+ const colors = theme.palette.chartTheme;
+ const primary = colors.primary.dark;
+ const greenAccent = colors.greenAccent.light;
+ const grey = colors.grey.dark;
+ const { collectionMetaData } = useAppContext();
+ return (
+
+
+ }
+ />
+
+ );
+};
+
+export default TotalCardsCollectedStatBox;
diff --git a/src/layout/collection/collectionGrids/collections-list/statItems/TotalPriceStatBox.jsx b/src/layout/collection/collectionGrids/collections-list/statItems/TotalPriceStatBox.jsx
index 84508fb..d2ea418 100644
--- a/src/layout/collection/collectionGrids/collections-list/statItems/TotalPriceStatBox.jsx
+++ b/src/layout/collection/collectionGrids/collections-list/statItems/TotalPriceStatBox.jsx
@@ -1,15 +1,20 @@
-import MonetizationOnIcon from '@mui/icons-material/MonetizationOn';
-import useCollectionStats from '../../../../../context/MAIN_CONTEXT/CollectionContext/useCollectionStats';
-import { useMode } from '../../../../../context';
import { Box } from '@mui/material';
import StatBox from '../../../../REUSABLE_COMPONENTS/StatBox';
+// import useCollectionStats from '../../../../../context/MAIN_CONTEXT/CollectionContext/useCollectionStats';
+import { useAppContext, useMode } from '../../../../../context';
+import MonetizationOnIcon from '@mui/icons-material/MonetizationOn';
+import styled from 'styled-components';
const TotalPriceStatBox = () => {
- const { collectionStats, metaStats } = useCollectionStats();
const { theme } = useMode();
const colors = theme.palette.chartTheme;
const primary = colors.primary.dark;
const greenAccent = colors.greenAccent.light;
+ const grey = colors.grey.dark;
+
+ const { collectionMetaData } = useAppContext();
+ const roundToNearestTenth = (num) => Math.round(num * 10) / 10;
+
return (
{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
+ borderRadius: theme.spacing(4),
height: '100%',
- boxSizing: 'border-box',
+ minHeight: '135px',
+ // p: '5px',
}}
>
- }
+ wrapIcon={false}
+ icon={}
/>
);
diff --git a/src/layout/collection/collectionGrids/collections-list/statItems/ValuDistributionCircle.jsx b/src/layout/collection/collectionGrids/collections-list/statItems/ValuDistributionCircle.jsx
index cc1472b..b74ae5a 100644
--- a/src/layout/collection/collectionGrids/collections-list/statItems/ValuDistributionCircle.jsx
+++ b/src/layout/collection/collectionGrids/collections-list/statItems/ValuDistributionCircle.jsx
@@ -1,31 +1,73 @@
+/* eslint-disable max-len */
+import React from 'react';
import { Box, Typography } from '@mui/material';
+import MDBox from '../../../../REUSABLE_COMPONENTS/MDBOX';
import { useMode } from '../../../../../context';
import ProgressCircle from '../../../../REUSABLE_COMPONENTS/ProgressCircle';
-const ValuDistributionCircle = () => {
+const ValuDistributionCircle = ({ collections }) => {
const { theme } = useMode();
- const colors = theme.palette.chartTheme;
- const primary = colors.primary.dark;
- const greenAccent = colors.greenAccent.default;
+ const collectionMetaData = collections?.reduce(
+ (meta, collection) => {
+ meta.totalValue += collection?.totalPrice;
+ meta.tooltips.push(
+ `${collection?.name}: $${collection?.totalPrice.toFixed(2)}`
+ );
+ return meta;
+ },
+ { totalValue: 0, tooltips: [] }
+ );
+
+ let cumulativePercent = 0;
+ const gradientStops = collections
+ .map((collection) => {
+ const valuePercent =
+ (collection?.totalPrice / collectionMetaData?.totalValue) * 100;
+ const stop = `${theme.palette.chartTheme.blueAccent.default} ${cumulativePercent}%, ${theme.palette.chartTheme.blueAccent.default} ${cumulativePercent + valuePercent}%`;
+ cumulativePercent += valuePercent;
+ return stop;
+ })
+ .join(', ');
+
+ const tooltipContent = collectionMetaData.tooltips.join('\n');
return (
-
-
- Campaign
-
-
-
-
- $48,352 revenue generated
+
+
+
+ Collection Value Distribution
+
+
+
+ Total Value: ${collectionMetaData.totalValue.toFixed(2)}
+
+
+ Includes extra misc expenditures and costs
- Includes extra misc expenditures and costs
-
+
);
};
diff --git a/src/layout/collection/collectionGrids/collections-list/statItems/ValueDistPieChart.jsx b/src/layout/collection/collectionGrids/collections-list/statItems/ValueDistPieChart.jsx
deleted file mode 100644
index a2b3d6c..0000000
--- a/src/layout/collection/collectionGrids/collections-list/statItems/ValueDistPieChart.jsx
+++ /dev/null
@@ -1,27 +0,0 @@
-// import { Box } from '@mui/material';
-// import Header from './Header';
-// import NivoContainer from '../../cards-chart/NivoContainer';
-// import { useMode } from '../../../../../context';
-// import { ChartArea } from '../../../../../pages/pageStyles/StyledComponents';
-// import ChartErrorBoundary from '../../cards-chart/ChartErrorBoundary';
-// import PieChart from './PieChart';
-
-// const ValueDistPieChart = () => {
-// const { theme } = useMode();
-// return (
-//
-//
-// {/* */}
-//
-// {/* */}
-//
-//
-//
-// {/* */}
-//
-// {/* */}
-//
-// );
-// };
-
-// export default ValueDistPieChart;
diff --git a/src/layout/collection/collectionGrids/cards-chart/GenerateNivoTestData.jsx b/src/layout/collection/data/GenerateNivoTestData.jsx
similarity index 100%
rename from src/layout/collection/collectionGrids/cards-chart/GenerateNivoTestData.jsx
rename to src/layout/collection/data/GenerateNivoTestData.jsx
diff --git a/src/layout/collection/data/collectionPortfolioData.jsx b/src/layout/collection/data/collectionPortfolioData.jsx
index e77ddca..ae256ca 100644
--- a/src/layout/collection/data/collectionPortfolioData.jsx
+++ b/src/layout/collection/data/collectionPortfolioData.jsx
@@ -84,6 +84,7 @@ export default function prepareTableData(selectedCards) {
Cell: ({ value }) => (
console.log('clicked')}
onSuccess={() =>
diff --git a/src/layout/collection/data/topCards.jsx b/src/layout/collection/data/topCards.jsx
index f9828d9..f388e56 100644
--- a/src/layout/collection/data/topCards.jsx
+++ b/src/layout/collection/data/topCards.jsx
@@ -1,95 +1,78 @@
-import Icon from '@mui/material/Icon';
-// Images
-import MDTypography from '../../REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
import React from 'react';
-import GenericActionButtons from '../../../components/buttons/actionButtons/GenericActionButtons';
-import { useSnackbar } from 'notistack';
+import MDTypography from '../../REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
+
const Name = ({ name }) => (
{name}
);
+
const Price = ({ price }) => (
{price}
);
-const TPrice = ({ tPrice }) => (
-
- {tPrice}
-
-);
+
const Quantity = ({ quantity }) => (
{quantity}
);
-export default function prepareTableData(selectedCards) {
- const roundToNearestTenth = (value) => Math.round(value * 10) / 10;
- const columns = React.useMemo(
- () => [
- {
- Header: 'Name',
- accessor: 'name',
- id: 'name',
- Cell: ({ value }) => ,
- },
- {
- Header: 'Price',
- accessor: 'price',
- id: 'price',
- Cell: ({ value }) => ,
- },
- {
- Header: 'Quantity',
- accessor: 'quantity',
- id: 'quantity',
- Cell: ({ value }) => ,
- },
- ],
- []
- );
- const data = React.useMemo(() => {
- if (!selectedCards || selectedCards.length === 0) {
- return [];
- }
- // Sort by totalPrice in descending order and take the top 5
- const topFiveCards = selectedCards
- ?.sort((a, b) => b.price - a.price)
- .slice(0, 5)
- .map((card) => ({
- ...card,
- tPrice: roundToNearestTenth(card.totalPrice),
- action: card,
- }));
+export default function prepareTableData(topCards) {
+ if (!topCards || topCards.length === 0) {
+ return { columns: [], data: [] };
+ }
+ console.log('topFiveCards:', topCards);
+
+ const columns = [
+ {
+ field: 'name',
+ headerName: 'Name',
+ renderCell: (params) => ,
+ width: 250,
+ flex: 1,
+ },
+ {
+ field: 'price',
+ headerName: 'Price',
+ renderCell: (params) => ,
+ maxWidth: 50,
+ flex: 1,
+ },
+ {
+ field: 'quantity',
+ headerName: 'Quantity',
+ renderCell: (params) => ,
+ maxWidth: 50,
+ flex: 1,
+ },
+ ];
- return topFiveCards;
- }, [selectedCards]);
+ const data = topCards?.map((card, index) => ({
+ id: card.id,
+ name: card.name,
+ price: card.price,
+ quantity: card.quantity,
+ }));
return { columns, data };
}
diff --git a/src/layout/collection/index.jsx b/src/layout/collection/index.jsx
index 8c12811..8d489a1 100644
--- a/src/layout/collection/index.jsx
+++ b/src/layout/collection/index.jsx
@@ -1,527 +1,261 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
-import propTypes from 'prop-types';
-import useCollectionVisibility from '../../context/hooks/useCollectionVisibility';
-import {
- useCollectionStore,
- useMode,
- useVisibilityContext,
-} from '../../context';
-import DashboardLayout from '../Containers/DashBoardLayout';
+import { useMode } from '../../context';
+import DashboardLayout from '../REUSABLE_COMPONENTS/DashBoardLayout';
import MDBox from '../REUSABLE_COMPONENTS/MDBOX';
-import PageLayout from '../Containers/PageLayout';
import { PortfolioBoxA } from '../../pages/pageStyles/StyledComponents';
-import { Grid, Card, Typography } from '@mui/material';
-import { useFormContext } from '../../context';
+import { Box, Card, Grid } from '@mui/material';
import CollectionDialog from '../../components/dialogs/CollectionDialog';
import collectionPortfolioData from './data/collectionPortfolioData';
import ChartGridLayout from './collectionGrids/ChartGridLayout';
-import StatisticsCardGrid from './collectionGrids/StatisticsCardsGrid';
import CollectionPortfolioHeader from './sub-components/CollectionPortfolioHeader';
-import CollectionListStats from './collectionGrids/CollectionListStats';
import SelectCollectionList from './collectionGrids/collections-list/SelectCollectionList';
import useSelectedCollection from '../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
-import useSnackBar from '../../context/hooks/useSnackBar';
-import { withDynamicSnackbar } from '../REUSABLE_COMPONENTS/HOC/DynamicSnackbar';
-import SelectionErrorDialog from '../../components/dialogs/SelectionErrorDialog';
-import useCollectionManager from '../../context/MAIN_CONTEXT/CollectionContext/useCollectionManager';
-import useSkeletonLoader from './collectionGrids/cards-datatable/useSkeletonLoader';
-import { DEFAULT_COLLECTION } from '../../context/constants';
import useDialogState from '../../context/hooks/useDialogState';
import SelectCollectionHeader from './collectionGrids/collections-list/SelectCollectionHeader';
import DashboardBox from '../REUSABLE_COMPONENTS/DashboardBox';
import StatBoard from './collectionGrids/collections-list/StatBoard';
+import { Tab, Tabs } from '@mui/material';
+import RCHeader from '../REUSABLE_COMPONENTS/RCHeader';
-// function SelectCollectionView({ onNewDialog, onCloseDialog, dialogState }) {
-// const { theme } = useMode();
-// const { allCollections, selectedCollection } = useSelectedCollection();
-// const { currentForm } = useFormContext();
-// return (
-//
-//
-//
-//
-//
-
-//
-//
-//
-//
-//
-// {dialogState.isDialogOpen && (
-//
-// )}
-// {dialogState.isSelectionErrorDialogOpen && (
-//
-// )}
-//
-//
-// );
-// }
+const CollectionsView = ({ openDialog, handleTabAndSelect }) => {
+ const { theme } = useMode();
+ return (
+
+
+
+ openDialog('isAddCollectionDialogOpen')}
+ />
+
+
+
+
+
+ openDialog('isEditCollectionDialogOpen')}
+ />
+
+
+
+ );
+};
+const PortfolioView = ({
+ selectedCollection,
+ columns,
+ data,
+ handleBackToCollections,
+ allCollections,
+}) => (
+
+
+
+
+
+
+
+
+
+
+);
const CollectionPortfolio = () => {
const { theme } = useMode();
- const { fetchCollections, hasFetchedCollections } = useCollectionManager();
const {
handleBackToCollections,
- // showCollections,
- selectedCollection,
selectedCollectionId,
+ selectedCollection,
allCollections,
- customError,
- toggleShowCollections,
+ handleSelectCollection,
} = useSelectedCollection();
- // Initially fetch collections if needed
- useEffect(() => {
- fetchCollections();
- }, []);
- const { currentForm } = useFormContext();
- const {
- isCollectionVisible,
- toggleCollectionVisibility,
- // dialogStates,
- // toggleDialog,
- } = useVisibilityContext();
-
- const { dialogState, openDialog, closeDialog } = useDialogState({
- isAddCollectionDialogOpen: false,
- isSelectionErrorDialogOpen: false,
- isConfirmationDialogOpen: false, // New dialog state
- });
- const [viewState, setViewState] = useState({
- showListOfAllCollections: isCollectionVisible,
- showSelectedCollection: !isCollectionVisible,
- currentCollection: selectedCollectionId,
- });
- const handleAddCollectionDialogToggle = useCallback(() => {
- openDialog('isAddCollectionDialogOpen');
- }, [openDialog]);
-
- const handleCloseAddCollectionDialog = useCallback(() => {
- closeDialog('isAddCollectionDialogOpen');
- }, [closeDialog]);
-
- const handleSelectionErrorDialogToggle = useCallback(() => {
- openDialog('isSelectionErrorDialogOpen');
- }, [openDialog]);
-
- const handleCloseSelectionErrorDialog = useCallback(() => {
- closeDialog('isSelectionErrorDialogOpen');
- }, [closeDialog]);
- // const handleDialogToggle = () =>
- // setDialogState((prevState) => ({
- // ...prevState,
- // isDialogOpen: !prevState.isDialogOpen,
- // }));
- // const handleCloseDialog = () =>
- // setDialogState((prevState) => ({
- // ...prevState,
- // isDialogOpen: false,
- // }));
- // const handleErrorDialog = () =>
- // setDialogState((prevState) => ({
- // ...prevState,
- // isSelectionErrorDialogOpen: true,
- // }));
- // const handleCloseErrorDialog = () =>
- // setDialogState((prevState) => ({
- // ...prevState,
- // isSelectionErrorDialogOpen: false,
- // }));
- useEffect(() => {
- if (customError === 'Selection Error') {
- handleSelectionErrorDialogToggle();
- } else {
- handleCloseSelectionErrorDialog();
+ const { dialogState, openDialog, closeDialog } = useDialogState();
+ const { columns, data } = collectionPortfolioData(selectedCollection?.cards);
+ const [activeTab, setActiveTab] = useState(0);
+ const tabs = [];
+ if (selectedCollectionId) {
+ tabs.push();
+ }
+ const handleTabChange = (event, newValue) => {
+ if (newValue === 0 || (newValue === 1 && selectedCollectionId)) {
+ setActiveTab(newValue);
}
- }, [customError]);
- // const handleSelectedCollectionView = useCallback(() => {
- // console.log('SWITCHING TO SELECTED COLLECTION VIEW', selectedCollectionId);
- // setViewState((prevState) => ({
- // ...prevState,
- // showListOfAllCollections: !prevState.showListOfAllCollections,
- // showSelectedCollection: !prevState.showSelectedCollection,
- // currentCollection: selectedCollectionId,
- // }));
- // }, [selectedCollectionId]);
- const handleDialogToggle = useCallback(
- (dialogName) => {
- dialogState[dialogName]
- ? closeDialog(dialogName)
- : openDialog(dialogName);
+ };
+ const handleSelectAndShowCollection = useCallback(
+ (collection) => {
+ handleSelectCollection(collection._id); // Assume this function sets the selectedCollectionId
+ setActiveTab(1); // Switch to Portfolio View tab
},
- [dialogState, openDialog, closeDialog]
+ [handleSelectCollection]
);
- // const handleViewChange = useCallback(() => {
- // toggleShowCollections();
- // }, [toggleShowCollections]);
- useEffect(() => {
- console.log('VIEW STATE CHANGED', viewState);
- console.log('ALL COLLECTION', allCollections);
- console.log('SELECTED COLLECTION', selectedCollection);
- console.log('SELECTED COLLECTION ID', selectedCollectionId);
- console.log('IS COLLECTION VISIBLE', isCollectionVisible);
- }, [
- viewState,
- allCollections,
- isCollectionVisible,
- selectedCollection,
- selectedCollectionId,
- ]);
- const { columns, data } = collectionPortfolioData(selectedCollection?.cards);
-
- // if (!hasFetchedCollections) {
- // return (
- //
- //
- //
- // {/* Directly use the SkeletonLoader with 'grid' type and customize gridProps as needed */}
- //
- //
- //
- //
- // );
- // }
return (
-
-
- {!isCollectionVisible ? (
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ {tabs}
+
+
+
+ {activeTab === 0 && (
+
+ )}
- {dialogState.isAddCollectionDialogOpen && (
-
- )}
- {dialogState.isSelectionErrorDialogOpen && (
-
- )}
-
-
- ) : (
- // Selected collection view
-
-
-
-
-
-
- {/* */}
-
-
-
-
-
-
- )}
-
+ {activeTab === 1 && selectedCollectionId && (
+ {
+ // handleBackToCollections();
+ setActiveTab(0); // Switch back to collections tab when going back
+ }}
+ allCollections={allCollections}
+ />
+ )}
+ {dialogState.isAddCollectionDialogOpen && (
+ closeDialog('isAddCollectionDialogOpen')}
+ collectionData={null}
+ isNew={true}
+ />
+ )}
);
};
-export default withDynamicSnackbar(CollectionPortfolio);
-// {
-// viewState.showListOfAllCollections && (
-//
-//
-//
-//
-//
+export default CollectionPortfolio;
+// const CollectionPortfolio = () => {
+// const { theme } = useMode();
+// const { Transitions } = theme;
+// const {
+// handleBackToCollections,
+// selectedCollectionId,
+// selectedCollection,
+// allCollections,
+// showCollections,
+// } = useSelectedCollection();
+// const { dialogState, openDialog, closeDialog } = useDialogState({
+// isAddCollectionDialogOpen: false,
+// isSelectionErrorDialogOpen: false,
+// });
-//
-//
-//
-//
-//
-// {dialogState.isDialogOpen && (
-//
-// )}
-// {dialogState.isSelectionErrorDialogOpen && (
-//
-// )}
-//
-//
-// );
-// }
-// {
-// viewState.showSelectedCollection && (
-//
-//
-//
-// {
-// handleBackToCollections();
-// handleSelectedCollectionView();
-// }}
-// />
-//
-//
-//
-//
-//
-//
-//
-//
-// );
-// }
-// const [isDialogOpen, setDialogOpen] = useState(false);
-// const [isSelectionErrorDialogOpen, setSelectionErrorDialogOpen] =
-// useState(false);
-// const { currentForm } = useFormContext();
-// currentForm === 'addCollectionForm'
-// const openNewDialog = useCallback((addOrEdit) => {
-// setDialogOpen(true); // Correctly opens the dialog
-// }, []);
-// const handleDialogToggle = () => setDialogOpen(!isDialogOpen);
-// const handleCloseDialog = () => setDialogOpen(false);
-// const handleErrorDialog = () => setSelectionErrorDialogOpen(true);
-// const handleCloseErrorDialog = () => setSelectionErrorDialogOpen(false);
+// const { columns, data } = collectionPortfolioData(selectedCollection?.cards);
-// if (!hasFetchedCollections) {
// return (
-//
-//
-// Loading...
-//
-//
-// );
-// }
-
-// return (
-//
-//
-// {showCollections ? (
-//
-//
-// {/* HEADER */}
-//
-//
-//
-// {/* STATISTICS FEATURE GRID */}
-//
-// {/* */}
-//
-// {/* CHARTS */}
-//
-//
-//
-//
-//
-// ) : (
-//
-//
-// {/* HEADER */}
-//
-//
+// {!selectedCollectionId ? (
+//
+//
+//
+//
-//
-//
-//
-// {/* COLLECTION LIST STATS DISPLAY */}
-//
-// openDialog('isAddCollectionDialogOpen')}
+// />
+//
+//
-//
-//
-//
-// {/* COLLECTION LIST */}
-//
-//
+//
+//
// openDialog('isEditCollectionDialogOpen')}
// />
-//
-//
+//
-// {isDialogOpen && (
-//
-// )}
-// {isSelectionErrorDialogOpen && (
-//
-// )}
-//
-//
+// {dialogState.isAddCollectionDialogOpen && (
+// closeDialog('isAddCollectionDialogOpen')}
+// collectionData={null}
+// isNew={true}
+// />
+// )}
+//
+//
+//
+// ) : (
+//
+//
+//
+//
+//
+//
+//
+// {/* */}
+//
+//
+//
+//
+//
+//
+//
// )}
-//
-//
-// );
+//
+// );
+// };
-// export default withDynamicSnackbar(CollectionPortfolio);
+// export default CollectionPortfolio;
diff --git a/src/layout/collection/sub-components/CollectionGoalsTimeLine.jsx b/src/layout/collection/sub-components/CollectionGoalsTimeLine.jsx
deleted file mode 100644
index 5e9893b..0000000
--- a/src/layout/collection/sub-components/CollectionGoalsTimeLine.jsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import React from 'react';
-import Card from '@mui/material/Card';
-import Icon from '@mui/material/Icon';
-import MDBox from 'components/MDBox';
-import MDTypography from 'components/MDTypography';
-import TimelineItem from 'examples/Timeline/TimelineItem';
-
-function CollectionGoalsTimeLine({ color, icon, title, dateTime, completed }) {
- return (
-
- );
-}
-
-function GoalsOverview() {
- const goals = [
- { title: '$2,000 Goal', dateTime: '1 Jan', completed: true },
- { title: '$4,000 Goal', dateTime: '15 Feb', completed: true },
- { title: '$6,000 Goal', dateTime: '10 Mar', completed: true },
- { title: '$8,000 Goal', dateTime: '5 Apr', completed: false },
- { title: '$9,000 Goal', dateTime: '30 Apr', completed: false },
- ];
-
- return (
-
-
-
- Collection Goals Overview
-
-
-
- {goals.map((goal, index) => (
-
- ))}
-
-
- );
-}
-
-export default GoalsOverview;
diff --git a/src/layout/collection/sub-components/CollectionPortfolioHeader.jsx b/src/layout/collection/sub-components/CollectionPortfolioHeader.jsx
index b6705e1..45b1920 100644
--- a/src/layout/collection/sub-components/CollectionPortfolioHeader.jsx
+++ b/src/layout/collection/sub-components/CollectionPortfolioHeader.jsx
@@ -6,39 +6,14 @@ import AttachMoneyIcon from '@mui/icons-material/AttachMoney';
import FormatListNumberedIcon from '@mui/icons-material/FormatListNumbered';
import TrendingUpIcon from '@mui/icons-material/TrendingUp';
import MDBox from '../../REUSABLE_COMPONENTS/MDBOX';
-import MDTypography from '../../REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-import MDAvatar from '../../REUSABLE_COMPONENTS/MDAVATAR';
import { useMode } from '../../../context';
-import useSelectedCollection from '../../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
-import { TransitionGroup } from 'react-transition-group';
-import useSkeletonLoader from '../collectionGrids/cards-datatable/useSkeletonLoader';
import { DEFAULT_COLLECTION } from '../../../context/constants';
import uniqueTheme from '../../REUSABLE_COMPONENTS/unique/uniqueTheme';
-import SimpleCard from '../../REUSABLE_COMPONENTS/unique/SimpleCard';
import IconStatWrapper from '../../REUSABLE_COMPONENTS/unique/IconStatWrapper';
import DashboardBox from '../../REUSABLE_COMPONENTS/DashboardBox';
-const SelectCollectionHeaderSkeleton = () => {
- const { SkeletonLoader } = useSkeletonLoader();
+import { PageHeaderSkeleton } from '../../REUSABLE_COMPONENTS/SkeletonVariants';
+import RCWrappedIcon from '../../REUSABLE_COMPONENTS/RCWRAPPEDICON/RCWrappedIcon';
- return (
-
-
-
-
-
-
-
-
-
-
-
- );
-};
const HeaderItem = ({ icon, label, value, delay }) => {
return (
@@ -72,12 +47,13 @@ const CollectionPortfolioHeader = ({ onBack, collection, allCollections }) => {
useEffect(() => {
console.log('collection', collection);
}, [collection]);
+
if (
!collection ||
- collection === DEFAULT_COLLECTION ||
- allCollections.length === 0
+ collection === DEFAULT_COLLECTION
+ // allCollections.length === 0
) {
- return onBack();
+ return ;
}
const headerItems = [
{
@@ -126,30 +102,19 @@ const CollectionPortfolioHeader = ({ onBack, collection, allCollections }) => {
width: '100%',
}}
>
- {/* */}
-
+
- {/* */}
- {headerItems.map((item, index) => (
+ {headerItems?.map((item, index) => (
{
))}
{/* */}
- {/* */}
);
};
diff --git a/src/layout/collection/sub-components/ComplexStatisticsCard.jsx b/src/layout/collection/sub-components/ComplexStatisticsCard.jsx
deleted file mode 100644
index b8062a3..0000000
--- a/src/layout/collection/sub-components/ComplexStatisticsCard.jsx
+++ /dev/null
@@ -1,174 +0,0 @@
-import PropTypes from 'prop-types';
-import Card from '@mui/material/Card';
-import Divider from '@mui/material/Divider';
-import Icon from '@mui/material/Icon';
-import MDBox from '../../REUSABLE_COMPONENTS/MDBOX/index';
-import MDTypography from '../../REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-import { useMode } from '../../../context';
-
-function ComplexStatisticsCard({ color, title, count, percentage, icon, sx }) {
- const { theme } = useMode();
- const textColor = color === 'light' ? 'dark' : 'white';
-
- const gradientColor = theme.palette[color]?.main || theme.palette.info.main;
-
- const cardStyle = {
- display: 'flex',
- flexDirection: 'column',
- height: '100%',
- borderRadius: theme.shape.borderRadius,
- ...sx,
- };
-
- const iconBoxStyle = {
- variant: 'gradient',
- bgColor: color,
- color: textColor,
- coloredShadow: color,
- borderRadius: 'xl',
- display: 'flex',
- justifyContent: 'center',
- alignItems: 'center',
- width: '4rem',
- height: '4rem',
- transform: 'translateY(-50%)',
- background: `linear-gradient(145deg, ${gradientColor}, ${theme.palette[color]?.dark || theme.palette.info.dark})`,
- };
-
- const statisticsBoxStyle = {
- textAlign: 'right',
- lineHeight: 1.25,
- mt: -3,
- display: 'flex',
- flexDirection: 'column',
- justifyContent: 'center',
- alignItems: 'flex-end',
- width: '100%',
- height: '6rem',
- };
-
- const percentageStyle = {
- component: 'p',
- variant: 'button',
- color: 'text',
- display: 'flex',
- justifyContent: 'space-between',
- mt: 1,
- };
- return (
-
-
-
-
- {icon}
-
-
-
-
- {title}
-
- {count}
-
-
-
-
-
-
- {percentage.amount}
-
- {percentage.label}
-
-
-
- );
-}
-
-// Setting default values for the props of ComplexStatisticsCard
-ComplexStatisticsCard.defaultProps = {
- color: 'info',
- percentage: {
- color: 'success',
- text: '',
- label: '',
- },
-};
-
-// Typechecking props for the ComplexStatisticsCard
-ComplexStatisticsCard.propTypes = {
- color: PropTypes.oneOf([
- 'primary',
- 'secondary',
- 'info',
- 'success',
- 'warning',
- 'error',
- 'light',
- 'dark',
- ]),
- title: PropTypes.string.isRequired,
- count: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
- percentage: PropTypes.shape({
- color: PropTypes.oneOf([
- 'primary',
- 'secondary',
- 'info',
- 'success',
- 'warning',
- 'error',
- 'dark',
- 'white',
- ]),
- amount: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
- label: PropTypes.string,
- }),
- icon: PropTypes.node.isRequired,
-};
-
-export default ComplexStatisticsCard;
diff --git a/src/layout/collection/sub-components/Notifications.jsx b/src/layout/collection/sub-components/Notifications.jsx
deleted file mode 100644
index b987287..0000000
--- a/src/layout/collection/sub-components/Notifications.jsx
+++ /dev/null
@@ -1,244 +0,0 @@
-/**
-=========================================================
-* Material Dashboard 2 React - v2.2.0
-=========================================================
-
-* Product Page: https://www.creative-tim.com/product/material-dashboard-react
-* Copyright 2023 Creative Tim (https://www.creative-tim.com)
-
-Coded by www.creative-tim.com
-
- =========================================================
-
-* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-*/
-import PriceChangeIcon from '@mui/icons-material/PriceChange';
-
-import { useState } from 'react';
-
-// @mui material components
-import Grid from '@mui/material/Grid';
-import Card from '@mui/material/Card';
-
-// Material Dashboard 2 React components
-import MDBox from 'components/MDBox';
-import MDTypography from 'components/MDTypography';
-import MDAlert from 'components/MDAlert';
-import MDButton from 'components/MDButton';
-import MDSnackbar from 'components/MDSnackbar';
-
-// Material Dashboard 2 React example components
-import DashboardLayout from 'examples/LayoutContainers/DashboardLayout';
-import DashboardNavbar from 'examples/Navbars/DashboardNavbar';
-import Footer from 'examples/Footer';
-
-function Notifications() {
- const [successSB, setSuccessSB] = useState(false);
- const [infoSB, setInfoSB] = useState(false);
- const [warningSB, setWarningSB] = useState(false);
- const [errorSB, setErrorSB] = useState(false);
-
- const openSuccessSB = () => setSuccessSB(true);
- const closeSuccessSB = () => setSuccessSB(false);
- const openInfoSB = () => setInfoSB(true);
- const closeInfoSB = () => setInfoSB(false);
- const openWarningSB = () => setWarningSB(true);
- const closeWarningSB = () => setWarningSB(false);
- const openErrorSB = () => setErrorSB(true);
- const closeErrorSB = () => setErrorSB(false);
-
- const alertContent = (name) => (
-
- A simple {name} alert with
-
- an example link
-
- . Give it a click if you like.
-
- );
-
- const renderSuccessSB = (
-
- );
-
- const renderInfoSB = (
-
- );
-
- const renderWarningSB = (
-
- );
-
- const renderErrorSB = (
-
- );
-
- return (
-
-
-
-
-
-
-
- Alerts
-
-
-
- {alertContent('primary')}
-
-
- {alertContent('secondary')}
-
-
- {alertContent('success')}
-
-
- {alertContent('error')}
-
-
- {alertContent('warning')}
-
-
- {alertContent('info')}
-
-
- {alertContent('light')}
-
-
- {alertContent('dark')}
-
-
- {alertContent('blueGreen')}
-
-
-
-
-
-
-
-
- Notifications
-
- Notifications on this page use Toasts from Bootstrap. Read
- more details here.
-
-
-
-
-
-
- success notification
-
- {renderSuccessSB}
-
-
-
- info notification
-
- {renderInfoSB}
-
-
-
- warning notification
-
- {renderWarningSB}
-
-
-
- error notification
-
- {renderErrorSB}
-
- {/* CUSTOMIZED API NOTIFICATIONS */}
-
-
- Price Change Notification
-
- {renderSuccessSB}
-
-
-
-
-
-
-
-
-
- );
-}
-
-export default Notifications;
diff --git a/src/layout/collection/sub-components/PieChartStats.jsx b/src/layout/collection/sub-components/PieChartStats.jsx
deleted file mode 100644
index 02eba99..0000000
--- a/src/layout/collection/sub-components/PieChartStats.jsx
+++ /dev/null
@@ -1,211 +0,0 @@
-import React from 'react';
-import { PieChart } from '@mui/x-charts';
-import { Box, Skeleton } from '@mui/material';
-import StatisticsDisplaySection from './StatisticsDisplaySection';
-import styled from 'styled-components';
-import shortid from 'shortid'; // shortid is a simple library to generate unique ids
-
-const ChartWrapper = styled(Box)`
- display: flex;
- justify-content: center;
- align-items: center;
- width: 100%;
- height: 100%;
-`;
-
-const PieChartStats = ({ chartData, iconName, title }) => {
- console.log('chartData', chartData);
-
- // Function to add unique IDs to each chart data entry
- const processDataWithIds = (data) => {
- return data.map((item) => ({
- ...item,
- id: shortid.generate(), // Assigning a unique id
- }));
- };
-
- const renderPieChart = () => {
- const processedChartData = chartData ? processDataWithIds(chartData) : [];
-
- return chartData ? (
-
- ) : (
-
- );
- };
-
- return (
-
- );
-};
-
-export default PieChartStats;
-
-// import React, { useMemo } from 'react';
-// import {
-// Box,
-// Card,
-// Grid,
-// Icon,
-// Paper,
-// Skeleton,
-// Typography,
-// } from '@mui/material';
-// // import { styled } from '@mui/system';
-// import { useMode } from '../../../../context';
-// import { PieChart } from '@mui/x-charts';
-// // import { StatisticHeader } from '../../../../context/hooks/style-hooks/usePortfolioStyles';
-// import MDBox from '../../../../layout/collection/MDBOX';
-// import MDTypography from '../../../../layout/collection/MDTypography';
-// import PropTypes from 'prop-types';
-// import styled from 'styled-components';
-// const StatisticPaper = styled(Paper)(({ theme }) => ({
-// padding: theme.spacing(2),
-// flexGrow: 1,
-// color: theme.palette.text.secondary,
-// background: theme.palette.backgroundA.lightest,
-// boxShadow: theme.shadows[2],
-// borderRadius: theme.shape.borderRadius,
-// transition: 'box-shadow 0.3s',
-// '&:hover': {
-// boxShadow: theme.shadows[4],
-// },
-// }));
-
-// const StatisticHeader = styled(Typography)(({ theme }) => ({
-// fontWeight: 'bold',
-// color: theme.palette.backgroundA.dark,
-// marginBottom: theme.spacing(1),
-// }));
-
-// const PieChartStats = ({ chartData, date, description, title, icon }) => {
-// const { theme } = useMode();
-// const isChartDataValid =
-// chartData && chartData.some((entry) => entry.value != null);
-
-// const renderChartContent = useMemo(
-// () => (
-//
-//
-//
-// Top Collections
-//
-//
-// {description && (
-//
-// {description}
-//
-// )}
-// {!isChartDataValid ? (
-//
-// ) : (
-//
-// )}
-// {date && (
-//
-// {date}
-//
-// )}
-//
-//
-//
-// ),
-// [chartData, theme, icon.component, title, description]
-// );
-
-// return (
-//
-// {' '}
-// {/* */}
-// {/* */}
-// {icon.component && (
-// // Icon JSX
-//
-// {icon.component}
-//
-// )}
-// {renderChartContent}
-//
-// );
-// };
-// // Setting default values for the props of PieChart
-// PieChart.defaultProps = {
-// icon: { color: 'info', component: '' },
-// title: '',
-// description: '',
-// height: '19.125rem',
-// };
-
-// // Typechecking props for the PieChart
-// PieChart.propTypes = {
-// icon: PropTypes.shape({
-// color: PropTypes.oneOf([
-// 'primary',
-// 'secondary',
-// 'info',
-// 'success',
-// 'warning',
-// 'error',
-// 'light',
-// 'dark',
-// ]),
-// component: PropTypes.node,
-// }),
-// title: PropTypes.string,
-// description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
-// height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
-// // chartData: PropTypes.array.isRequired,
-// };
-
-// export default PieChartStats;
diff --git a/src/layout/collection/sub-components/StatisticsDisplaySection.jsx b/src/layout/collection/sub-components/StatisticsDisplaySection.jsx
deleted file mode 100644
index 43bb2e9..0000000
--- a/src/layout/collection/sub-components/StatisticsDisplaySection.jsx
+++ /dev/null
@@ -1,118 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import { styled } from '@mui/system';
-import { Card, CardContent, Typography, Box } from '@mui/material';
-import { useMode } from '../../../context';
-import PieChartIcon from '@mui/icons-material/PieChart';
-import AttachMoneyIcon from '@mui/icons-material/AttachMoney';
-import EmojiEventsIcon from '@mui/icons-material/EmojiEvents';
-import MDBox from '../../REUSABLE_COMPONENTS/MDBOX';
-
-const StatisticCard = styled(Card)(({ theme }) => ({
- height: '100%',
- width: '100%',
- display: 'flex',
- flexGrow: 1,
- flexDirection: 'column',
- justifyContent: 'center',
- padding: theme.spacing(2),
- color: theme.palette.text.secondary,
- background: theme.palette.backgroundA.lightest,
- boxShadow: theme.shadows[2],
- borderRadius: theme.shape.borderRadius,
- transition: 'box-shadow 0.3s',
- '&:hover': {
- boxShadow: theme.shadows[4],
- },
- '@media (max-width: 600px)': {
- padding: theme.spacing(1), // Reduced padding on mobile
- },
-}));
-
-const StatisticHeader = styled(Typography)(({ theme }) => ({
- fontWeight: 'bold',
- // color: theme.palette.backgroundA.lightest,
- marginBottom: theme.spacing(1),
-}));
-
-const HeaderContainer = styled(Box)(({ theme }) => ({
- display: 'flex',
- alignItems: 'center',
- marginBottom: theme.spacing(2),
-}));
-
-const DataContainer = styled(Box)(({ theme }) => ({
- width: '100%',
- overflow: 'auto',
- maxHeight: 'calc(100% - 40px)', // Adjust the height based on header size
-}));
-
-const HeaderBox = styled(Box)(({ theme }) => ({
- display: 'flex',
- alignItems: 'flex-start',
- flexGrow: 1,
- paddingBottom: theme.spacing(2),
- borderBottom: `1px solid ${theme.palette.backgroundA.lighter}`,
- marginBottom: theme.spacing(2),
-}));
-
-const ContentBox = styled(Box)(({ theme }) => ({
- display: 'flex', // Using Flexbox
- justifyContent: 'center', // Horizontally center the content
- alignItems: 'center', // Vertically center the content
- overflow: 'auto', // Handle overflow
- padding: theme.spacing(2),
- height: '100%', // Ensure it takes the full height of its parent
-}));
-
-const iconComponents = {
- PieChart: PieChartIcon,
- AttachMoney: AttachMoneyIcon,
- EmojiEvents: EmojiEventsIcon,
-};
-
-const StatisticsDisplaySection = ({ iconName, title, renderContent }) => {
- const { theme } = useMode();
- const IconComponent = iconComponents[iconName];
- // console.log('chartData', chartData);
- return (
-
-
-
- {IconComponent && (
-
-
-
- )}
-
- {title}
-
-
-
- {renderContent()}
-
-
-
- );
-};
-
-StatisticsDisplaySection.propTypes = {
- icon: PropTypes.string,
- title: PropTypes.string.isRequired,
- renderContent: PropTypes.func.isRequired,
-};
-
-export default StatisticsDisplaySection;
diff --git a/src/layout/collection/sub-components/TopCardsDisplay.jsx b/src/layout/collection/sub-components/TopCardsDisplay.jsx
deleted file mode 100644
index a7b706a..0000000
--- a/src/layout/collection/sub-components/TopCardsDisplay.jsx
+++ /dev/null
@@ -1,188 +0,0 @@
-import React, { useEffect, useRef, useState } from 'react';
-import SwipeableViews from 'react-swipeable-views';
-import {
- Box,
- Button,
- Container,
- Grid,
- MobileStepper,
- useMediaQuery,
- useTheme,
-} from '@mui/material';
-import { KeyboardArrowLeft, KeyboardArrowRight } from '@mui/icons-material';
-import { useCollectionStore } from '../../../context/MAIN_CONTEXT/CollectionContext/CollectionContext';
-import { styled } from 'styled-components';
-
-import { MainContainer } from '../../../pages/pageStyles/StyledComponents';
-import CarouselCard from '../../../components/cards/CarouselCard';
-import LoadingIndicator from '../../../components/reusable/indicators/LoadingIndicator';
-import { useMode } from '../../../context';
-
-const StyledStepper = styled(MobileStepper)(({ theme }) => ({
- background: theme.palette.backgroundB.dark,
- border: `1px solid ${theme.palette.backgroundB.lighter}`,
- borderRadius: theme.shape.borderRadiusLarge,
- color: theme.palette.backgroundA.light,
- overflow: 'hidden',
- padding: theme.spacing(1),
- height: '100%',
- '@media (max-width: 600px)': {
- width: '100%', // Full width on mobile screens
- padding: theme.spacing(0.5), // Reduced padding on mobile
- },
-}));
-
-const StyledCardDetails = styled(Box)(({ theme }) => ({
- display: 'flex',
- flexDirection: 'column',
- justifyContent: 'center',
- alignItems: 'center',
-}));
-
-const StyledSwipeableView = styled(SwipeableViews)(({ theme }) => ({
- '@media (max-width: 600px)': {
- width: '100%', // Full width on mobile screens
- overflow: 'hidden', // Hide overflow on mobile
- },
-}));
-
-const StyledContainer = styled(Container)(({ theme }) => ({
- display: 'flex',
- flexDirection: 'column',
- // Set a maximum height to prevent expansion. Adjust according to your needs.
- maxHeight: '100vh',
- overflow: 'auto', // Add scroll if content exceeds container size
- alignItems: 'center',
- background: theme.palette.backgroundB.darker,
- borderRadius: theme.shape.borderRadiusLarge,
- padding: theme.spacing(3),
- color: '#fff',
- '@media (max-width: 600px)': {
- padding: theme.spacing(1), // Reduced padding on mobile
- },
-}));
-
-// Assuming SwipeableViews and CarouselCard do not need custom styling here
-// If they do, use styled in a similar manner
-
-const TopCardsDisplay = () => {
- const { theme } = useMode();
- const theme2 = useTheme();
- const { selectedCollection } = useCollectionStore();
- const [top5Cards, setTop5Cards] = useState([]);
- const [activeStep, setActiveStep] = useState(0);
- const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
-
- useEffect(() => {
- const sortedCards = selectedCollection?.cards
- ?.map((card) => {
- const latestPrice = card?.latestPrice?.num ?? 0;
- const lastSavedPrice = card?.lastSavedPrice?.num ?? 0;
- if (latestPrice === undefined) {
- console.warn(`Price missing for card: ${card.name}`);
- return { ...card, diff: 0 };
- }
- return { ...card, diff: Math.abs(latestPrice - lastSavedPrice) };
- })
- .sort((a, b) => b.diff - a.diff || b.price - a.price)
- .slice(0, 5);
- setTop5Cards(sortedCards);
- }, [selectedCollection]);
-
- const maxSteps = top5Cards?.length;
- const handleNext = () => setActiveStep((prev) => prev + 1);
- const handleBack = () => setActiveStep((prev) => prev - 1);
- const isSmall = useMediaQuery(theme2.breakpoints.down('sm'));
- if (!selectedCollection) {
- return (
-
-
-
- );
- }
-
- return (
-
- {/* */}
-
-
-
- {top5Cards?.map((card, index) => (
-
-
-
- ))}
-
-
- {theme.direction === 'rtl' ? (
-
- ) : (
-
- )}{' '}
- Next
-
- }
- backButton={
-
- }
- />
-
-
- {/* */}
-
- );
-};
-
-export default TopCardsDisplay;
diff --git a/src/layout/collection/sub-components/TopCardsDisplayRow.jsx b/src/layout/collection/sub-components/TopCardsDisplayRow.jsx
index 825d56c..8e3a4db 100644
--- a/src/layout/collection/sub-components/TopCardsDisplayRow.jsx
+++ b/src/layout/collection/sub-components/TopCardsDisplayRow.jsx
@@ -1,24 +1,140 @@
-import { Grid } from '@mui/material';
-import TopCardsDisplay from './TopCardsDisplay';
+import React, { useState, useMemo } from 'react';
+import {
+ Grid,
+ Card,
+ CardMedia,
+ CardContent,
+ Typography,
+ Box,
+} from '@mui/material';
+import { Swiper, SwiperSlide } from 'swiper/react';
+import 'swiper/css';
+import 'swiper/css/effect-coverflow';
+import 'swiper/css/pagination';
+import 'swiper/css/navigation';
+import { Autoplay, Pagination, Navigation } from 'swiper/modules';
+import { useMode } from '../../../context';
+import useSelectedCollection from '../../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
+import placeHolder from '../../../assets/images/placeholder.jpeg';
+import GenericCard from '../../../components/cards/GenericCard';
+import { StyledSwiperSlide } from '../../../pages/pageStyles/StyledComponents';
+import MDBox from '../../REUSABLE_COMPONENTS/MDBOX';
+import { AspectRatioBox } from '../../../components/cards/styles/cardStyledComponents';
+import { FormBox } from '../../REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
+import CardDetail from '../../../components/cards/CardDetail';
+import CardDetailsContainer from '../../../components/cards/CardDetailsContainer';
-export const TopCardsDisplayRow = ({ isSmall, theme }) => (
-
-
-
+export const TopCardsDisplayRow = () => {
+ const { theme } = useMode();
+ const { selectedCollection } = useSelectedCollection();
+ const [activeCardIndex, setActiveCardIndex] = useState(0);
+
+ const handleSlideChange = (swiper) => setActiveCardIndex(swiper.realIndex);
+
+ const topFiveCards = useMemo(
+ () =>
+ selectedCollection?.cards?.sort((a, b) => b.price - a.price).slice(0, 5),
+ [selectedCollection?.cards]
+ );
+
+ return (
+
+
+ {topFiveCards?.map((card, index) => (
+
+
+
+
+
+
+
+
+
+
+
+
+ ))}
+
-
-);
+ );
+};
diff --git a/src/layout/collection/sub-components/TopFiveExpensiveCards.jsx b/src/layout/collection/sub-components/TopFiveExpensiveCards.jsx
deleted file mode 100644
index 014b255..0000000
--- a/src/layout/collection/sub-components/TopFiveExpensiveCards.jsx
+++ /dev/null
@@ -1,178 +0,0 @@
-import React from 'react';
-import StatisticsDisplaySection from './StatisticsDisplaySection';
-import { Box, Skeleton, Typography } from '@mui/material';
-
-const TopFiveExpensiveCards = ({ topFiveCards, isLoading, iconName }) => {
- const renderTopFiveCards = () => {
- if (isLoading || !topFiveCards) {
- return Array.from(new Array(5)).map((_, index) => (
-
-
-
-
- ));
- }
-
- return topFiveCards?.map((card, index) => (
-
- {index + 1}.
-
- {card?.name} - ${card?.price?.toFixed(2)}
-
-
- ));
- };
-
- return (
-
- );
-};
-
-export default TopFiveExpensiveCards;
-
-// import React from 'react';
-// import {
-// Box,
-// Card,
-// Grid,
-// Icon,
-// Paper,
-// Skeleton,
-// Typography,
-// useTheme,
-// } from '@mui/material';
-// import { styled } from '@mui/system';
-// import { useMode } from '../../../context';
-// import { StatisticHeader } from '../../../context/hooks/style-hooks/usePortfolioStyles';
-// import MDBox from '../../../layout/collection/MDBOX';
-
-// // Define styled components
-// const StatisticPaper = styled(Paper)(({ theme }) => ({
-// padding: theme.spacing(2),
-// flexGrow: 1,
-// color: theme.palette.text.secondary,
-// background: theme.palette.backgroundA.lightest,
-// boxShadow: theme.shadows[2],
-// borderRadius: theme.shape.borderRadius,
-// transition: 'box-shadow 0.3s',
-// '&:hover': {
-// boxShadow: theme.shadows[4],
-// },
-// }));
-
-// // const StatisticHeader = styled(Typography)(({ theme }) => ({
-// // marginBottom: theme.spacing(1),
-// // fontWeight: 'bold',
-// // color: theme.palette.backgroundA.dark,
-// // }));
-
-// const CardDetail = styled(Typography)(({ theme }) => ({
-// color: theme.palette.text.primary,
-// '&:first-of-type': {
-// marginRight: theme.spacing(1),
-// },
-// }));
-
-// const TopFiveExpensiveCards = ({ topFiveCards, isLoading, icon }) => {
-// const theme2 = useTheme();
-// const { theme } = useMode();
-
-// // Function to render skeleton loaders
-// const renderSkeletons = () => {
-// return Array.from(new Array(5)).map((_, index) => (
-//
-//
-//
-//
-// ));
-// };
-
-// return (
-//
-// {/* */}
-//
-//
-// Top Five Most Expensive Cards
-//
-//
-// {icon.component && (
-// // Icon JSX
-//
-// {icon.component}
-//
-// )}{' '}
-// {!topFiveCards || isLoading
-// ? renderSkeletons()
-// : topFiveCards.map((card, index) => (
-//
-//
-// {index + 1}.
-//
-//
-// {card?.name} - ${card?.price?.toFixed(2)}
-//
-//
-// ))}
-//
-//
-//
-// );
-// };
-
-// export default TopFiveExpensiveCards;
diff --git a/src/layout/collection/sub-components/TotalValueOfCollectionsDisplay.jsx b/src/layout/collection/sub-components/TotalValueOfCollectionsDisplay.jsx
deleted file mode 100644
index d8a20f3..0000000
--- a/src/layout/collection/sub-components/TotalValueOfCollectionsDisplay.jsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import React from 'react';
-import StatisticsDisplaySection from './StatisticsDisplaySection';
-import { Skeleton, Typography } from '@mui/material';
-
-const TotalValueOfCollectionsDisplay = ({ totalValue, iconName }) => {
- const renderTotalValueContent = () => {
- return totalValue != null ? (
- ${totalValue?.toFixed(2)}
- ) : (
-
- );
- };
-
- return (
-
- );
-};
-
-export default TotalValueOfCollectionsDisplay;
diff --git a/src/layout/deck/CardsDisplay.jsx b/src/layout/deck/CardsDisplay.jsx
deleted file mode 100644
index 1b27ab7..0000000
--- a/src/layout/deck/CardsDisplay.jsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import React from 'react';
-import { Box, Typography } from '@mui/material';
-import CardsGrid from '../../components/grids/deckBuilderGrids/CardsGrid';
-import { useMode } from '../../context';
-import {
- DeckCardsContainer,
- NoCardsTypography,
-} from '../../pages/pageStyles/StyledComponents';
-
-const CardsDisplay = ({ selectedDeck, isLoading }) => {
- const { theme } = useMode();
- return (
-
- {selectedDeck?.cards?.length > 0 ? (
-
- ) : (
- No cards to display
- )}
-
- );
-};
-
-export default CardsDisplay;
diff --git a/src/layout/deck/DeckDisplay.js b/src/layout/deck/DeckDisplay.js
deleted file mode 100644
index 3daed96..0000000
--- a/src/layout/deck/DeckDisplay.js
+++ /dev/null
@@ -1,166 +0,0 @@
-import React, { useContext, useEffect, useState } from 'react';
-import { useDeckStore } from '../../context/MAIN_CONTEXT/DeckContext/DeckContext';
-import { useMode, useUserContext } from '../../context';
-
-import DeckListToggle from './DeckListToggle';
-import DeckEditor from './DeckEditor';
-import CardsDisplay from './CardsDisplay';
-import {
- DeckCardsContainer,
- DeckDisplayBox,
- DeckDisplayPaper,
- DeckDisplayTitleTypography,
- DeckStyledButton,
-} from '../../pages/pageStyles/StyledComponents';
-import MDTypography from '../REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-import MDBox from '../REUSABLE_COMPONENTS/MDBOX';
-import SettingsIcon from '@mui/icons-material/Settings';
-import { Grid, IconButton } from '@mui/material';
-import { StyledContainerBoxPrimary } from '../../layout/REUSABLE_STYLED_COMPONENTS/ReusableStyledComponents';
-import SelectDeckList from '../../components/grids/deckBuilderGrids/SelectDeckList';
-import AppsIcon from '@mui/icons-material/Apps';
-
-const DeckDisplay = () => {
- const { theme } = useMode();
- const { setSelectedDeck, selectedDeck, allDecks, setSelectedCards } =
- useDeckStore();
- const [showAllDecks, setShowAllDecks] = useState(false);
- const [isLoading, setIsLoading] = useState(false);
- const handleSelectDeck = (deckId) => {
- const foundDeck = allDecks?.find((deck) => deck?._id === deckId);
- if (foundDeck) {
- setSelectedDeck(foundDeck);
- setSelectedCards(foundDeck?.cards?.slice(0, 30) || []);
- }
- };
- useEffect(() => {
- let isMounted = true;
- setIsLoading(true);
-
- const timeoutId = setTimeout(() => {
- if (isMounted) {
- handleSelectDeck(selectedDeck?._id);
- setIsLoading(false);
- }
- }, 1000);
-
- return () => {
- isMounted = false;
- clearTimeout(timeoutId);
- };
- }, [selectedDeck]);
- // useEffect(() => {
- // // Assuming setFormType is a function that can set the form context
- // setFormType('addDeckForm');
- // }, []);
- return (
-
- {/* */}
-
-
-
-
- Deck Display
-
- {
- console.log('Settings Clicked');
- }}
- size="large"
- >
-
-
-
-
-
-
-
-
-
- setShowAllDecks(!showAllDecks)}
- variant="contained"
- sx={{
- width: '100%',
- borderRadius: 0,
- borderTopLeftRadius: 4,
- borderTopRightRadius: 4,
- backgroundColor: theme.palette.backgroundA.dark,
- margin: theme.spacing(1),
- color: theme.palette.backgroundA.contrastTextA,
- display: 'flex',
- alignItems: 'center',
- '&:hover': {
- backgroundColor: theme.palette.backgroundA.light,
- },
- }}
- >
-
- {showAllDecks ? 'Hide Decks' : 'Show All Decks'}
-
-
-
- {showAllDecks && (
-
-
-
- )}
-
-
-
-
- {selectedDeck && (
-
-
-
- )}
-
-
-
-
-
- {/* */}
-
- );
-};
-
-export default DeckDisplay;
diff --git a/src/layout/deck/DeckEditor.jsx b/src/layout/deck/DeckEditor.jsx
index 6f55246..251c73b 100644
--- a/src/layout/deck/DeckEditor.jsx
+++ b/src/layout/deck/DeckEditor.jsx
@@ -1,45 +1,10 @@
import React, { useState, useEffect } from 'react';
-import {
- Paper,
- Typography,
- FormControlLabel,
- Switch,
- Box,
-} from '@mui/material';
-import DeckEditPanel from '../../components/dialogs/DeckEditPanel';
-import { useDeckStore } from '../../context/MAIN_CONTEXT/DeckContext/DeckContext';
-import useDeckStyles from '../../context/hooks/style-hooks/useDeckStyles';
-import { SwitchControl } from '../../pages/pageStyles/StyledComponents';
-import { useFormContext, useMode } from '../../context';
-import DeckSwitch from '../../components/buttons/other/DeckSwitch';
+import { Paper, Typography, Box } from '@mui/material';
+import { useMode } from '../../context';
+import DeckForm from '../../components/forms/DeckForm';
-const DeckEditor = () => {
- const { selectedDeck, setSelectedDeck } = useDeckStore();
+const DeckEditor = ({ deck, onClose }) => {
const { theme } = useMode();
- const {
- formStates, // Assuming this provides access to the current form state including errors
- formMethods, // Assuming this provides access to register, handleSubmit, etc.
- onSubmit,
- currentForm,
- toggleForm,
-
- // handleChange,
- // handleBlur,
- // handleFocus,
- // formMethods, // Assuming formMethods provides access to register, handleSubmit, etc.
- } = useFormContext();
-
- // const { currentForm: currentFormType } = formStates;
-
- const handleToggleEdit = () => {
- if (currentForm === 'updateDeckForm') {
- toggleForm('addDeckForm');
- setSelectedDeck(null);
- }
- if (currentForm === 'addDeckForm') {
- toggleForm('updateDeckForm');
- }
- };
return (
@@ -52,12 +17,8 @@ const DeckEditor = () => {
}}
>
- {selectedDeck ? 'Edit Deck' : 'Create New Deck'}
+ {deck ? 'Edit Deck' : 'Create New Deck'}
- {/* }
- label={isEditing ? 'Editing' : 'Adding'}
- /> */}
{
alignItems: 'center',
gap: 2,
}}
- >
-
-
+ >
-
+ {' '}
);
diff --git a/src/layout/deck/DeckListItem.jsx b/src/layout/deck/DeckListItem.jsx
new file mode 100644
index 0000000..6082779
--- /dev/null
+++ b/src/layout/deck/DeckListItem.jsx
@@ -0,0 +1,254 @@
+// import {
+// Box,
+// Card,
+// CardActionArea,
+// CardContent,
+// Chip,
+// Collapse,
+// Grid,
+// Typography,
+// useMediaQuery,
+// } from '@mui/material';
+// import { memo, useCallback, useEffect, useRef, useState } from 'react';
+// import { useFormContext, useMode } from '../../context';
+// import useDeckManager from '../../context/MAIN_CONTEXT/DeckContext/useDeckManager';
+// import useSelectedDeck from '../../context/MAIN_CONTEXT/DeckContext/useSelectedDeck';
+// import useDialogState from '../../context/hooks/useDialogState';
+// import PropTypes from 'prop-types';
+// import DeckBuilderIcon from '../REUSABLE_COMPONENTS/icons/DeckBuilderIcon';
+// import MDBox from '../REUSABLE_COMPONENTS/MDBOX';
+// import DeckEditor from './DeckEditor';
+// import MDTypography from '../REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
+// import useGridItems from '../../context/hooks/useGridItems';
+// import useLocalStorage from '../../context/hooks/useLocalStorage';
+// import { useLoading } from '../../context/hooks/useLoading';
+// import { defaultValues } from '../../context/simplified_constants';
+// import RCWrappedIcon from '../REUSABLE_COMPONENTS/RCWRAPPEDICON/RCWrappedIcon';
+// import RCInfoItem from '../REUSABLE_COMPONENTS/RCInfoItem';
+// import { roundToNearestTenth } from '../../context/Helpers';
+
+// const DeckListItem = ({
+// deck,
+// cards,
+// handleSelectAndShowDeck,
+// isEditPanelOpen,
+// }) => {
+// const { theme } = useMode();
+// const { deleteDeck, hasFetchedDecks } = useDeckManager();
+// const { handleSelectDeck, allDecks, deckHasBeenSelected } = useSelectedDeck();
+// const { isLoading } = useLoading();
+// const pageContext = 'Deck'; // Context to pass to GenericCard
+// const cardDisplay = useGridItems({
+// itemsPerPage: 8, // Define as per your requirement
+// cards: cards,
+// isLoading: isLoading('fetchDecks'), // Pass the actual loading state
+// hasFetched: hasFetchedDecks, // Pass the actual loading state
+// allItems: allDecks, // Pass the actual loading state
+// validSelection: deckHasBeenSelected,
+// type: 'deck',
+// pageContext,
+// deckId: deck?._id,
+// });
+// const handleSelection = useCallback(
+// (deck) => {
+// console.log('Deck Selected:', deck);
+// // handleSelectDeck(deck);
+// handleSelectAndShowDeck(deck);
+// },
+// [handleSelectAndShowDeck]
+// );
+
+// return (
+//
+//
+// handleSelection(deck)}
+// sx={{
+// display: 'flex',
+// flexDirection: 'row',
+// justifyContent: 'center',
+// flexGrow: 1,
+// }}
+// >
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+// handleSelection(deck)} />
+// {isEditPanelOpen && cardDisplay}
+// {/* {renderCardDisplayOnUpdate()} */}
+//
+// {/* {isEditPanelOpen && cardDisplay} */}
+//
+// );
+// };
+
+// DeckListItem.displayName = 'DeckListItem';
+
+// DeckListItem.propTypes = {
+// deck: PropTypes.object.isRequired,
+// isEditPanelOpen: PropTypes.bool.isRequired,
+// onToggleEditPanel: PropTypes.func.isRequired,
+// };
+
+// export default DeckListItem;
+import React, { useState, useEffect } from 'react';
+import PropTypes from 'prop-types';
+import {
+ Card,
+ CardActionArea,
+ CardContent,
+ Grid,
+ Collapse,
+} from '@mui/material';
+import MDBox from '../REUSABLE_COMPONENTS/MDBOX';
+import DeckBuilderIcon from '../REUSABLE_COMPONENTS/icons/DeckBuilderIcon';
+import RCInfoItem from '../REUSABLE_COMPONENTS/RCInfoItem';
+import DeckEditor from './DeckEditor';
+import RCWrappedIcon from '../REUSABLE_COMPONENTS/RCWRAPPEDICON/RCWrappedIcon';
+import { roundToNearestTenth } from '../../context/Helpers';
+import { useMode } from '../../context';
+
+const DeckListItem = ({
+ deck,
+ cards,
+ handleSelectAndShowDeck,
+ isEditPanelOpen,
+}) => {
+ const { theme } = useMode();
+ const infoItems = [
+ { label: 'Name', value: deck?.name },
+ { label: 'Value', value: `$${roundToNearestTenth(deck?.totalPrice)}` },
+ { label: 'Cards', value: deck?.totalQuantity },
+ ];
+
+ return (
+
+
+ handleSelectAndShowDeck(deck)}
+ sx={{
+ display: 'flex',
+ flexDirection: 'row',
+ justifyContent: 'center',
+ flexGrow: 1,
+ }}
+ >
+
+
+
+
+
+
+ {infoItems.map((item, index) => (
+
+ ))}
+
+
+
+
+ handleSelectAndShowDeck(deck)} />
+
+
+ );
+};
+
+const AnimatedInfoItem = ({ label, value, theme, delay }) => {
+ const [checked, setChecked] = useState(false);
+
+ useEffect(() => {
+ const timer = setTimeout(() => {
+ setChecked(true);
+ }, delay);
+ return () => clearTimeout(timer);
+ }, [delay]);
+
+ return (
+
+
+
+ );
+};
+
+AnimatedInfoItem.propTypes = {
+ label: PropTypes.string.isRequired,
+ value: PropTypes.string.isRequired,
+ theme: PropTypes.object.isRequired,
+ delay: PropTypes.number.isRequired,
+};
+
+DeckListItem.propTypes = {
+ deck: PropTypes.object.isRequired,
+ isEditPanelOpen: PropTypes.bool.isRequired,
+ handleSelectAndShowDeck: PropTypes.func.isRequired,
+};
+
+export default DeckListItem;
diff --git a/src/layout/deck/DeckListToggle.jsx b/src/layout/deck/DeckListToggle.jsx
deleted file mode 100644
index ae15c53..0000000
--- a/src/layout/deck/DeckListToggle.jsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from 'react';
-import { Button, Box } from '@mui/material';
-import AppsIcon from '@mui/icons-material/Apps';
-import SelectDeckList from '../../components/grids/deckBuilderGrids/SelectDeckList';
-
-import { useMode } from '../../context';
-import {
- DeckCardsContainer,
- DeckStyledButton,
-} from '../../pages/pageStyles/StyledComponents';
-
-const DeckListToggle = ({
- showAllDecks,
- setShowAllDecks,
- handleSelectDeck,
- allDecks,
-}) => {
- const { theme } = useMode();
- return (
- <>
- setShowAllDecks(!showAllDecks)}
- variant="contained"
- sx={{
- width: '100%',
- borderRadius: 0,
- borderTopLeftRadius: 4,
- borderTopRightRadius: 4,
- backgroundColor: theme.palette.backgroundA.dark,
- color: theme.palette.text.primary,
- '&:hover': {
- backgroundColor: theme.palette.backgroundA.light,
- },
- }}
- >
-
- {showAllDecks ? 'Hide Decks' : 'Show All Decks'}
-
- {showAllDecks && (
-
-
-
- )}
- >
- );
-};
-
-export default DeckListToggle;
diff --git a/src/layout/deck/DeckPageHeader.jsx b/src/layout/deck/DeckPageHeader.jsx
new file mode 100644
index 0000000..31c9b13
--- /dev/null
+++ b/src/layout/deck/DeckPageHeader.jsx
@@ -0,0 +1,101 @@
+import React from 'react';
+import styled from 'styled-components';
+import useSkeletonLoader from '../collection/collectionGrids/cards-datatable/useSkeletonLoader';
+import { Box, Card, Grid } from '@mui/material';
+import { useFormContext, useMode, useUserContext } from '../../context';
+import SimpleCard from '../REUSABLE_COMPONENTS/unique/SimpleCard';
+import SimpleSectionHeader from '../REUSABLE_COMPONENTS/unique/SimpleSectionHeader';
+import SimpleButton from '../REUSABLE_COMPONENTS/unique/SimpleButton';
+import uniqueTheme from '../REUSABLE_COMPONENTS/unique/uniqueTheme';
+import { PageHeaderSkeleton } from '../REUSABLE_COMPONENTS/SkeletonVariants';
+
+const FlexContainer = styled(Box)(({ theme }) => ({
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ padding: theme.spacing(1, 2),
+ flexDirection: 'row',
+ [theme.breakpoints.down('sm')]: {
+ flexDirection: 'column',
+ alignItems: 'flex-start',
+ },
+}));
+
+// Adjusting Header container for mobile view
+const HeaderContainer = styled(Box)(({ theme }) => ({
+ flex: 1,
+ maxWidth: '100%', // Allows the header to utilize full width on small screens
+ [theme.breakpoints.down('sm')]: {
+ marginBottom: theme.spacing(2),
+ },
+}));
+
+// Button container adjusted for mobile view
+const ButtonContainer = styled(Box)(({ theme }) => ({
+ flex: 1,
+ display: 'flex',
+ justifyContent: 'flex-end',
+ maxWidth: '100%',
+ [theme.breakpoints.down('sm')]: {
+ justifyContent: 'center',
+ width: '100%',
+ },
+}));
+
+const DeckPageHeader = ({ openAddDeckDialog }) => {
+ const { theme } = useMode();
+ const { setCurrentForm } = useFormContext();
+ const { user } = useUserContext();
+ if (!user) {
+ return ;
+ }
+
+ return (
+
+
+
+
+
+
+
+ {
+ setCurrentForm('addDeckForm');
+ openAddDeckDialog();
+ console.log('openAddDeckDialog');
+ }}
+ >
+ Add New Deck
+
+
+
+
+ );
+};
+
+export default DeckPageHeader;
diff --git a/src/layout/deck/index.jsx b/src/layout/deck/index.jsx
index fb44861..dba5459 100644
--- a/src/layout/deck/index.jsx
+++ b/src/layout/deck/index.jsx
@@ -1,42 +1,191 @@
-import { Box, Grid } from '@mui/material';
+import { Card, Collapse, Grid, Tab, Tabs } from '@mui/material';
import { useMode } from '../../context';
-import DeckDisplay from './DeckDisplay';
import MDBox from '../REUSABLE_COMPONENTS/MDBOX';
-import PageLayout from '../Containers/PageLayout';
+import PageLayout from '../REUSABLE_COMPONENTS/PageLayout';
import SearchComponent from '../../components/forms/search/SearchComponent';
+import DashboardBox from '../REUSABLE_COMPONENTS/DashboardBox';
+import DeckPageHeader from './DeckPageHeader';
+import useDialogState from '../../context/hooks/useDialogState';
+import DeckDialog from '../../components/dialogs/DeckDialog';
+import { useCallback, useEffect, useRef, useState } from 'react';
+import useSelectedDeck from '../../context/MAIN_CONTEXT/DeckContext/useSelectedDeck';
+import useLocalStorage from '../../context/hooks/useLocalStorage';
+import { DeckListItemSkeleton } from '../REUSABLE_COMPONENTS/SkeletonVariants';
+import DeckListItem from './DeckListItem';
+import useDeckManager from '../../context/MAIN_CONTEXT/DeckContext/useDeckManager';
+import RCHeader from '../REUSABLE_COMPONENTS/RCHeader';
+import DashboardLayout from '../REUSABLE_COMPONENTS/DashBoardLayout';
+import RCCardList from '../REUSABLE_COMPONENTS/RCCARDLIST/RCCardList';
+import FlexBetween from '../REUSABLE_COMPONENTS/FlexBetween';
const DeckBuilder = () => {
const { theme } = useMode();
+ const { selectedDeck, selectedDeckId, allDecks, updateDeck, allIds } =
+ useSelectedDeck();
+ const { fetchDecks } = useDeckManager();
+ const [showAllDecks, setShowAllDecks] = useState(false);
+ const { dialogState, openDialog, closeDialog } = useDialogState({
+ isEditDeckDialogOpen: false,
+ isAddDeckDialogOpen: false,
+ });
+ // const toggleDeckVisibility = () => setShowAllDecks(!showAllDecks);
+ const [decks, setDecks] = useLocalStorage('decks', {});
+ const [deckList, setDeckList] = useState([]);
+ const [openEditorDeckId, setOpenEditorDeckId] = useState(null);
+ const [activeTab, setActiveTab] = useState(0);
+ const tabs = [];
+ if (selectedDeckId) {
+ tabs.push();
+ }
+ const handleChange = (event, newValue) => {
+ if (newValue === 0 || (newValue === 1 && selectedDeckId)) {
+ setActiveTab(newValue);
+ }
+ };
+ const handleChangeTab = (event, newValue) => {
+ setActiveTab(newValue);
+ };
+ const handleSelectAndShowDeck = useCallback(
+ (deckId) => {
+ setOpenEditorDeckId(openEditorDeckId === deckId ? null : deckId);
+ setActiveTab(1); // Switch to Portfolio View tab
+ },
+ [openEditorDeckId]
+ );
+ const numDecks = allIds?.length || 0;
+ const nonSkeletonCount = useRef(0);
+
+ useEffect(() => {
+ if (!decks?.byId) return;
+
+ const minItems = 5;
+ const numRequired = minItems - numDecks > 0 ? minItems - numDecks : 0;
+ nonSkeletonCount.current = numDecks;
+
+ // Map decks to include an 'action' property
+ const allSkeletonDecks = [...Array(numRequired).keys()].map((index) => ({
+ component: (
+
+ ),
+ action: null, // Skeletons don't have an action
+ }));
+
+ const combinedDecks = allDecks
+ ?.map((deck, index) => ({
+ component: (
+
+
+ handleSelectAndShowDeck(deck)}
+ />{' '}
+
+
+ ),
+ action: () => handleSelectAndShowDeck(deck._id), // Here we include the action
+ key: deck?._id || `deck-${index}`,
+ name: deck?.name,
+ description: deck?.description,
+ tags: deck?.tags,
+ color: deck?.color,
+ cards: deck?.cards,
+ image: deck?.cards?.image,
+ }))
+ .concat(allSkeletonDecks);
+
+ setDeckList(combinedDecks);
+ }, [decks, showAllDecks, openEditorDeckId, handleSelectAndShowDeck]);
+
+ const preparedDecksData = deckList?.map((deck, index) => ({
+ ...deck,
+ action: () => handleSelectAndShowDeck(deck._id),
+ }));
return (
-
-
-
+
+
+
+ openDialog('isAddDeckDialogOpen')}
+ />
+
+
+
+
+
+ {selectedDeckId && }
+
+
+ {activeTab === 0 &&
+ allDecks?.map((deck) => (
+
+ {selectedDeck && (
+ setActiveTab(0)}
+ />
+ )}
+
+ ))}
+ {activeTab === 1 && (
+
+ deck._id === openEditorDeckId)}
+ isEditPanelOpen={true}
+ handleSelectAndShowDeck={() => setActiveTab(1)}
+ />
+
+ )}
+
+
+
+ {/*
+
+
+
+ openDialog('isAddDeckDialogOpen')}
+ decks={allDecks}
+ />
+
+
{
flexGrow: 1,
}}
>
-
+
+
+
-
+
+
+
+
+ openDialog('isAddDeckDialogOpen')
+ }
+ decks={decks}
+ />
+
+
+
+ {tabs}
+
+ {activeTab === 1 &&
+ openEditorDeckId &&
+ deckList?.map((deck, index) => (
+
+
+
+ handleSelectAndShowDeck(deck._id)
+ }
+ />
+
+
+ ))}
+
+
+
-
-
-
+
+ */}
+
+ closeDialog('isEditDeckDialogOpen')}
+ deckData={selectedDeck}
+ isNew={false}
+ />
+ closeDialog('isAddDeckDialogOpen')}
+ deckData={null} // Assuming new deck dialog doesn't need deck data
+ isNew={true}
+ />
+
);
};
diff --git a/src/layout/navigation/LogoSection.js b/src/layout/navigation/LogoSection.js
deleted file mode 100644
index 92d5753..0000000
--- a/src/layout/navigation/LogoSection.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import { ButtonBase } from '@mui/material';
-import { Link, useNavigate } from 'react-router-dom';
-import Logo from '../../assets/icons/deckIcon2.svg'; // Import SVG as a component
-import config from '../../config';
-
-// ==============================|| MAIN LOGO ||============================== //
-
-const LogoSection = () => {
- const navigate = useNavigate();
-
- const handleClick = () => {
- navigate(config?.defaultPath);
- };
-
- return (
-
-
-
- );
-};
-
-export default LogoSection;
diff --git a/src/layout/navigation/LongMenu.jsx b/src/layout/navigation/LongMenu.jsx
index 8a63783..0d1e3b1 100644
--- a/src/layout/navigation/LongMenu.jsx
+++ b/src/layout/navigation/LongMenu.jsx
@@ -15,7 +15,10 @@ const ITEM_HEIGHT = 48;
// Wrap your component with React.forwardRef to forward the ref
const LongMenu = React.forwardRef(
- ({ onEdit, onDelete, onStats, onView, onSelect, collectionId }, ref) => {
+ (
+ { onEdit, onDelete, onStats, onView, onSelect, collectionId, collection },
+ ref
+ ) => {
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
const handleClick = (event) => {
@@ -46,8 +49,6 @@ const LongMenu = React.forwardRef(
open={open}
onClose={handleClose}
sx={{
- // maxHeight: ITEM_HEIGHT * 4.5,
- // width: 250,
'& .MuiMenu-paper': {
maxHeight: ITEM_HEIGHT * 4.5,
width: 250,
@@ -78,7 +79,7 @@ const LongMenu = React.forwardRef(
{
text: 'Select Collection',
icon: ,
- action: () => onSelect(collectionId),
+ action: () => onSelect(collection),
},
{
text: 'Collection Stats',
diff --git a/src/layout/navigation/MenuCard.jsx b/src/layout/navigation/MenuCard.jsx
deleted file mode 100644
index c874637..0000000
--- a/src/layout/navigation/MenuCard.jsx
+++ /dev/null
@@ -1,131 +0,0 @@
-// material-ui
-import { styled, useTheme } from '@mui/material/styles';
-import {
- Avatar,
- Card,
- CardContent,
- Grid,
- LinearProgress,
- List,
- ListItem,
- ListItemAvatar,
- ListItemText,
- Typography,
- linearProgressClasses,
-} from '@mui/material';
-
-// types
-import PropTypes from 'prop-types';
-
-// assets
-import TableChartOutlinedIcon from '@mui/icons-material/TableChartOutlined';
-
-// styles
-const BorderLinearProgress = styled(LinearProgress)(({ theme }) => ({
- height: 10,
- borderRadius: 30,
- [`&.${linearProgressClasses.colorPrimary}`]: {
- backgroundColor: '#fff',
- },
- [`& .${linearProgressClasses.bar}`]: {
- borderRadius: 5,
- backgroundColor: theme.palette.primary.main,
- },
-}));
-
-const CardStyle = styled(Card)(({ theme }) => ({
- background: theme.palette.primary.light,
- marginBottom: '22px',
- overflow: 'hidden',
- position: 'relative',
- '&:after': {
- content: '""',
- position: 'absolute',
- width: '157px',
- height: '157px',
- background: theme.palette.primary[200],
- borderRadius: '50%',
- top: '-105px',
- right: '-96px',
- },
-}));
-
-// ==============================|| PROGRESS BAR WITH LABEL ||============================== //
-
-function LinearProgressWithLabel({ value, ...others }) {
- const theme = useTheme();
-
- return (
-
-
-
-
-
- Progress
-
-
-
- {`${Math.round(
- value
- )}%`}
-
-
-
-
-
-
-
- );
-}
-
-LinearProgressWithLabel.propTypes = {
- value: PropTypes.number,
-};
-
-// ==============================|| SIDEBAR MENU Card ||============================== //
-
-const MenuCard = () => {
- const theme = useTheme();
-
- return (
-
-
-
-
-
-
-
-
-
-
- Get Extra Space
-
- }
- secondary={ 28/23 GB}
- />
-
-
-
-
-
- );
-};
-
-export default MenuCard;
diff --git a/src/layout/navigation/MenuItemComponent.jsx b/src/layout/navigation/MenuItemComponent.jsx
deleted file mode 100644
index af55e97..0000000
--- a/src/layout/navigation/MenuItemComponent.jsx
+++ /dev/null
@@ -1,96 +0,0 @@
-import React from 'react';
-import {
- styled,
- MenuItem,
- ListItemIcon,
- ListItemText,
- Typography,
- Grow,
- ListItemAvatar,
- Avatar,
- Card,
- CardContent,
- ListItem,
-} from '@mui/material';
-import { useNavigate } from 'react-router-dom';
-import { useMode } from '../../context';
-import {
- StyledBox,
- StyledMenuItem,
-} from '../../pages/pageStyles/StyledComponents';
-import { useSpring, animated } from 'react-spring';
-import MDTypography from '../REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-const CardStyle = styled(Card)(({ theme }) => ({
- background: 'transparent',
- // marginBottom: '22px',
- height: '100%',
- width: '100%',
- overflow: 'hidden',
- position: 'relative',
- '&:after': {
- content: '""',
- position: 'absolute',
- // height: '100%',
- // width: '157px',
- // height: '157px',
- // background: theme.palette.primary[200],
- borderRadius: '50%',
- // top: '-105px',
- // right: '-96px',
- },
-}));
-const MenuItemComponent = ({ item, onClick, visibleItems, index }) => {
- const { theme } = useMode();
- const navigate = useNavigate();
-
- const itemAnimation = useSpring({
- from: { transform: 'scale(0)' },
- to: { transform: 'scale(1)' },
- delay: 200,
- });
-
- const handleClick = () => {
- navigate(item.to);
- if (onClick) onClick();
- };
-
- return (
- <>
-
-
-
- {item.icon}
- {' '}
-
-
-
- {item?.name}
-
- }
- // secondary={
- //
- // {item?.description}
- //
- // }
- />
- >
- );
-};
-
-export default MenuItemComponent;
diff --git a/src/layout/navigation/Navigation.jsx b/src/layout/navigation/Navigation.jsx
index 0ab7b22..f174af0 100644
--- a/src/layout/navigation/Navigation.jsx
+++ b/src/layout/navigation/Navigation.jsx
@@ -1,43 +1,34 @@
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useCallback } from 'react';
import {
- AppBar,
Toolbar,
IconButton,
- Box,
- Drawer,
List,
- Divider,
- Typography,
- useTheme,
Hidden,
- Card,
- CardContent,
ListItem,
- ListItemIcon,
- Avatar,
- ListItemAvatar,
ListItemText,
+ AppBar,
+ useMediaQuery,
} from '@mui/material';
import MenuIcon from '@mui/icons-material/Menu';
-import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
-import ChevronRightIcon from '@mui/icons-material/ChevronRight';
-import LogoSection from './LogoSection';
-import MenuItemComponent from './MenuItemComponent';
-import { useCartStore, useMode, useSidebarContext } from '../../context';
-import MenuCard from './MenuCard';
-import {
- StyledAppBar,
- StyledMenuItem,
- StyledToolbar,
- DrawerHeader,
- StyledBox,
- StyledSwipeableDrawer,
-} from '../../pages/pageStyles/StyledComponents';
-import { Navigate, useNavigate } from 'react-router-dom';
-import getMenuItemsData from './menuItemsData';
-import styled from 'styled-components';
+import { useCartStore, useMode } from '../../context';
+import { useNavigate } from 'react-router-dom';
import { useSpring, animated, useSprings } from 'react-spring';
-import MDTypography from '../REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
+import RCLogoSection from '../REUSABLE_COMPONENTS/RCLOGOSECTION/RCLogoSection';
+import {
+ Avatar,
+ Box,
+ Card,
+ CardContent,
+ DialogTitle,
+ Divider,
+ Drawer,
+ ModalClose,
+ Radio,
+ Sheet,
+ Typography,
+} from '@mui/joy';
+import { useCookies } from 'react-cookie';
+import { baseMenuItems } from '../../data/baseMenuItems';
const Navigation = ({ isLoggedIn }) => {
const { theme } = useMode();
const navigate = useNavigate();
@@ -46,130 +37,186 @@ const Navigation = ({ isLoggedIn }) => {
typeof navigator !== 'undefined' &&
/iPad|iPhone|iPod/.test(navigator.userAgent);
const [isOpen, setIsOpen] = useState(false); // Manage open state locally
- const [isMobileView, setIsMobileView] = useState(window.innerWidth < 768);
- const toggleSidebar = () => {
- setIsOpen(!isOpen);
- };
- const [menuItems, setMenuItems] = useState([]);
- useEffect(() => {
- const handleResize = () => setIsMobileView(window.innerWidth < 768);
- window.addEventListener('resize', handleResize);
- return () => window.removeEventListener('resize', handleResize);
- }, []);
+ const isMobileView = useMediaQuery(theme.breakpoints.down('sm'));
const iconColor = isMobileView ? theme.palette.primary.main : 'white';
+ const [cookies] = useCookies('authUser');
+ const username = cookies?.authUser?.username;
+ const menuItems = baseMenuItems({ cartCardQuantity: totalQuantity });
+ const toggleSidebar = useCallback(() => setIsOpen(!isOpen), [isOpen]);
+ const [springs] = useSprings(menuItems.length, (index) => ({
+ from: { opacity: 0, transform: 'translateY(-20px)' },
+ to: { opacity: 1, transform: 'translateY(0)' },
+ delay: index * 100,
+ }));
- // New state to track if component is mounted
- const [isMounted, setIsMounted] = useState(false);
-
- useEffect(() => {
- setIsMounted(true); // Set to true when component mounts
-
- // Fetch data as before
- const fetchData = async () => {
- const cartCardQuantity = totalQuantity;
- const items = await getMenuItemsData(
- isLoggedIn,
- cartCardQuantity,
- iconColor
- ); // Simulated fetch call
-
- if (isMounted) {
- // Check if component is still mounted before setting state
- setMenuItems(items.map((item) => ({ ...item, isVisible: true }))); // Assuming visibility logic is simplified
+ const ContentContainer = ({ type, content, clickAction, itemIndex }) => {
+ const handleClick = () => {
+ if (clickAction === 'navigate' && itemIndex !== undefined) {
+ navigate(menuItems[itemIndex].to);
+ } else {
+ toggleSidebar();
}
};
- fetchData();
-
- return () => setIsMounted(false); // Set to false when component unmounts
- }, [isLoggedIn, totalQuantity, iconColor, isMounted]); // Include isMounted in dependency array if it's used within the effect
+ return (
+ ({
- from: { opacity: 0, transform: 'translateY(-20px)' },
- to: { opacity: 1, transform: 'translateY(0)' },
- delay: index * 100, // Delay based on index
- }));
- const handleDrawerToggle = () => {
- toggleSidebar();
+ flexGrow: 1,
+ justifyContent: 'center',
+ height: '100%',
+ width: '100%',
+ maxWidth: clickAction === 'navigate' ? '100%' : '5rem',
+ boxShadow: 'none',
+ border: '3px solid',
+ borderColor: theme.palette.chartTheme.greenAccent.light,
+ '&:hover': { bgcolor: 'background.level1' },
+ }}
+ onClick={handleClick}
+ >
+
+ {content}
+
+
+ );
};
- const renderMenuItems = (type) =>
- springs.map((style, index) => (
-
+ const renderMenuItems = (type) => {
+ return springs.map((style, index) => (
+
navigate(menuItems[index].to)}
sx={{
- '&:hover': {
- backgroundColor: theme.palette.backgroundF.light,
- color: 'white',
- },
+ maxHeight: 64,
+ maxWidth: '100%',
+ '&:hover': { backgroundColor: theme.palette.backgroundF.light },
}}
>
-
-
- {menuItems[index].icon}
-
-
-
- {menuItems[index].name}
-
+
+ {menuItems[index]?.icon}
+
+ {menuItems[index]?.name}
+
+ >
}
+ itemIndex={index}
+ clickAction="navigate"
/>
));
+ };
return (
<>
-
-
+
+
+
+
+
+ }
+ clickAction={'toggle'}
+ index={0}
+ />
+
+
+ {!isMobileView && renderMenuItems('top')}
+
+
+ {username}
+
+
+
+ {/* */}
+
+
- {isMobileView ? (
-
-
-
-
-
-
- ) : (
- renderMenuItems('top')
- )}
-
-
-
-
+ Filters
+
+
{renderMenuItems('side')}
-
-
+
+
+ {/* */}
>
);
};
diff --git a/src/layout/navigation/SideBar.jsx b/src/layout/navigation/SideBar.jsx
deleted file mode 100644
index 50f50a1..0000000
--- a/src/layout/navigation/SideBar.jsx
+++ /dev/null
@@ -1,130 +0,0 @@
-import React from 'react';
-import {
- SwipeableDrawer,
- List,
- Divider,
- Hidden,
- ListItemText,
- Box,
- IconButton,
- Typography,
- ListItemButton,
- Collapse,
-} from '@mui/material';
-import MenuItemComponent from './MenuItemComponent';
-import { useMode, useSidebarContext } from '../../context';
-import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
-import ChevronRightIcon from '@mui/icons-material/ChevronRight';
-import {
- DrawerHeader,
- StyledBox,
- StyledSwipeableDrawer,
-} from '../../pages/pageStyles/StyledComponents';
-import { ExpandLess, ExpandMore } from '@mui/icons-material';
-import MenuCard from './MenuCard';
-
-// ==============================|| SIDEBAR DRAWER ||============================== //
-
-const SideBar = ({
- handleLogout,
- handleDrawer,
- isOpen,
- isMobileView,
- menuItemsData,
-}) => {
- const { theme } = useMode();
- const { visibleItems, setVisibleItems, menuItems, baseMenuItems } =
- useSidebarContext();
- const iOS =
- typeof navigator !== 'undefined' &&
- /iPad|iPhone|iPod/.test(navigator.userAgent);
- const renderMenuItems = () => {
- return menuItems?.map((item, index) => (
-
- ));
- };
- return (
-
-
-
- {' '}
-
-
- {theme.direction === 'ltr' ? (
-
- ) : (
-
- )}
-
-
-
- The App
-
-
-
- {/* THIS RENDERS THE VERTICAL MENU ITEMS */}
-
-
- {/*
-
- {open ? : }
- */}
- {/* */}
- {renderMenuItems()}
- {/* */}
-
-
-
-
-
- {/* Footer Section */}
-
- Footer Content
- {/* Footer Items */}
-
-
-
-
- );
-};
-
-export default SideBar;
diff --git a/src/layout/navigation/TopBar.jsx b/src/layout/navigation/TopBar.jsx
deleted file mode 100644
index 1ea562f..0000000
--- a/src/layout/navigation/TopBar.jsx
+++ /dev/null
@@ -1,123 +0,0 @@
-import React, { useState, useEffect } from 'react';
-import {
- Box,
- IconButton,
- ButtonBase,
- Avatar,
- CardActions,
- Button,
-} from '@mui/material';
-import { useNavigate } from 'react-router-dom';
-import { useMode, useSidebarContext } from '../../context';
-import LogoSection from './LogoSection';
-import MenuItemComponent from './MenuItemComponent';
-import MenuIcon from '@mui/icons-material/Menu';
-
-import {
- StyledAppBar,
- StyledMenuItem,
- StyledToolbar,
-} from '../../pages/pageStyles/StyledComponents';
-const TopBar = ({ isMobileView, isLoggedIn, handleDrawer }) => {
- const { theme } = useMode();
- const navigate = useNavigate();
- const { visibleItems, setVisibleItems, menuItems, baseMenuItems } =
- useSidebarContext();
-
- useEffect(() => {
- // Logic to set visibleItems
- setVisibleItems(Array(menuItems.length).fill(false));
- menuItems.forEach((_, index) => {
- setTimeout(() => {
- setVisibleItems((prev) => {
- const newVisible = [...prev];
- newVisible[index] = true;
- return newVisible;
- });
- }, index * 100);
- });
- }, [menuItems.length, setVisibleItems]);
-
- const renderMenuItems = () =>
- menuItems.map((item, index) => (
- navigate(item.to)}
- theme={theme}
- style={{
- opacity: visibleItems[index] ? 1 : 0,
- transform: visibleItems[index]
- ? 'translateY(0)'
- : 'translateY(-20px)',
- transition: 'opacity 0.3s ease, transform 0.3s ease',
- transitionDelay: `${index * 0.1}s`,
- }}
- >
-
-
- ));
-
- return (
-
-
- {isMobileView ? (
-
- {/* {renderMenuItems()} */}
-
-
-
-
-
- ) : (
-
- {renderMenuItems()}
-
- )}
-
-
- );
-};
-
-export default TopBar;
diff --git a/src/layout/navigation/menuItemsData.jsx b/src/layout/navigation/menuItemsData.jsx
deleted file mode 100644
index d5b722d..0000000
--- a/src/layout/navigation/menuItemsData.jsx
+++ /dev/null
@@ -1,98 +0,0 @@
-import React from 'react';
-import {
- Home as HomeIcon,
- Store as StoreIcon,
- ShoppingCart as CartIcon,
- Assessment as CollectionIcon,
- Person as ProfileIcon,
-} from '@mui/icons-material';
-import DeckBuilderIcon from '../../components/reusable/icons/DeckBuilderIcon';
-import { Badge } from '@mui/material';
-import { useCartStore } from '../../context/MAIN_CONTEXT/CartContext/CartContext';
-export const getMenuItemsData = (isLoggedIn, cartCardQuantity, iconColor) => {
- // const { cartCardQuantity } = useCartStore();
- try {
- const baseMenuItems = [
- { name: 'Home', icon: , to: '/home', requiresLogin: false },
- {
- name: 'Deck Builder',
- // icon: ,
- icon: ,
- to: '/deckbuilder',
- requiresLogin: false,
- },
- {
- name: 'Collection',
- icon: ,
- to: '/collection',
- requiresLogin: !isLoggedIn,
- },
- {
- name: 'Store',
- icon: ,
- to: '/store',
- requiresLogin: !isLoggedIn,
- },
- {
- name: 'Cart',
- icon: (
-
-
-
- ),
- to: '/cart',
- requiresLogin: !isLoggedIn,
- },
- {
- name: 'Profile',
- icon: ,
- to: '/profile',
- requiresLogin: isLoggedIn,
- },
- ];
-
- if (isLoggedIn) {
- return baseMenuItems.map((item) => ({
- ...item,
- requiresLogin: false,
- }));
- }
-
- // Processed menu items
- const processedMenuItems = isLoggedIn
- ? baseMenuItems.map((item) => ({ ...item, requiresLogin: false }))
- : baseMenuItems;
-
- return {
- baseMenuItems,
- menuItems: processedMenuItems,
- };
- } catch (error) {
- console.error('An error occurred in getMenuItemsData:', error);
- return {
- baseMenuItems: [],
- menuItems: [],
- };
- }
-};
-
-export default getMenuItemsData;
diff --git a/src/layout/profile/ProfileSection.js b/src/layout/profile/ProfileSection.js
index eac6940..1727666 100644
--- a/src/layout/profile/ProfileSection.js
+++ b/src/layout/profile/ProfileSection.js
@@ -1,6 +1,4 @@
import { useState, useRef, useEffect } from 'react';
-
-// material-ui
import {
Avatar,
Box,
@@ -22,10 +20,7 @@ import {
Switch,
Typography,
} from '@mui/material';
-
-// third-party
import PerfectScrollbar from 'react-perfect-scrollbar';
-
import { useNavigate } from 'react-router-dom';
import { useAuthContext, useMode } from '../../context';
import Transitions from '../Transitions';
diff --git a/src/layout/profile/index.jsx b/src/layout/profile/index.jsx
index 271dbb3..926a9ea 100644
--- a/src/layout/profile/index.jsx
+++ b/src/layout/profile/index.jsx
@@ -15,7 +15,7 @@ import team1 from '../../assets/images/bg1.jpg';
import team2 from '../../assets/images/bg1.jpg';
import team3 from '../../assets/images/bg1.jpg';
import team4 from '../../assets/images/bg1.jpg';
-import DashboardLayout from '../Containers/DashBoardLayout';
+import DashboardLayout from '../REUSABLE_COMPONENTS/DashBoardLayout';
import MDBox from '../REUSABLE_COMPONENTS/MDBOX';
import Header from './sub-components/Header';
import PlatformSettings from './sub-components/Settings';
diff --git a/src/layout/profile/sub-components/DefaultInfoCard.jsx b/src/layout/profile/sub-components/DefaultInfoCard.jsx
index 86538f0..33fb48a 100644
--- a/src/layout/profile/sub-components/DefaultInfoCard.jsx
+++ b/src/layout/profile/sub-components/DefaultInfoCard.jsx
@@ -1,30 +1,10 @@
-/**
-=========================================================
-* Material Dashboard 2 React - v2.1.0
-=========================================================
-
-* Product Page: https://www.creative-tim.com/product/material-dashboard-react
-* Copyright 2022 Creative Tim (https://www.creative-tim.com)
-
-Coded by www.creative-tim.com
-
- =========================================================
-
-* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-*/
-
-// prop-types is library for typechecking of props
import PropTypes from 'prop-types';
-
-// @mui material components
import Card from '@mui/material/Card';
import Divider from '@mui/material/Divider';
import Icon from '@mui/material/Icon';
import MDBox from '../../REUSABLE_COMPONENTS/MDBOX';
import MDTypography from '../../REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-// Material Dashboard 2 React components
-
function DefaultInfoCard({ color, icon, title, description, value }) {
return (
diff --git a/src/pages/sections/FeatureCardsSection.jsx b/src/layout/sections/FeatureCardsSection.jsx
similarity index 88%
rename from src/pages/sections/FeatureCardsSection.jsx
rename to src/layout/sections/FeatureCardsSection.jsx
index c565459..7597a0e 100644
--- a/src/pages/sections/FeatureCardsSection.jsx
+++ b/src/layout/sections/FeatureCardsSection.jsx
@@ -1,13 +1,10 @@
import React from 'react';
import { Grid } from '@mui/material';
-import { useTheme } from '@mui/system';
import { useMediaQuery } from '@mui/material';
-
-import { AnimatedFeatureCard } from '../../components/cards/AnimatedFeatureCard';
+import { AnimatedFeatureCard } from '../../layout/AnimatedFeatureCard';
import { useModalContext } from '../../context/UTILITIES_CONTEXT/ModalContext/ModalContext';
-import { useResponsiveStyles } from '../../context/hooks/style-hooks/useResponsiveStyles';
import { useMode } from '../../context';
-import pages from '../../assets/data/pages.json';
+import pages from '../../data/pages.json';
import {
StyledContainerBox,
StyledPaper,
diff --git a/src/layout/sections/HeroIconSection.jsx b/src/layout/sections/HeroIconSection.jsx
new file mode 100644
index 0000000..15a0d4d
--- /dev/null
+++ b/src/layout/sections/HeroIconSection.jsx
@@ -0,0 +1,139 @@
+import SaveIcon from '@mui/icons-material/Save';
+import AddIcon from '@mui/icons-material/Add';
+import CollectionsIcon from '@mui/icons-material/Collections';
+import pages from '../../data/pages.json';
+import placeHolder from '../../assets/images/placeholder.jpeg';
+import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
+import { Zoom, useMediaQuery } from '@mui/material';
+import SimpleCard from '../../layout/REUSABLE_COMPONENTS/unique/SimpleCard';
+import uniqueTheme from '../../layout/REUSABLE_COMPONENTS/unique/uniqueTheme';
+import { useMode } from '../../context';
+import { AspectRatio } from '@mui/joy';
+const heroCardData = [
+ {
+ id: 'herodata-1-store-add',
+ name: 'Add Cards From Store',
+ description: 'Add cards to your collection from the store.',
+ heroText: 'ADD',
+ icon: ,
+ heroIcon: 'AddIcon',
+ image: placeHolder,
+ },
+ {
+ id: 'herodata-2-deck-build',
+ name: 'Build Decks In Deck Builder',
+ description: 'Build decks using the deck builder.',
+ heroText: 'BUILD',
+ icon: ,
+ heroIcon: 'SaveIcon',
+ image: placeHolder,
+ },
+ {
+ id: 'herodata-3-collection-view',
+ name: 'Track Collection Value in Portfolio',
+ description:
+ 'View and analyze your portfolio performance using the Portfolios advanced statistics settings.',
+ heroText: 'TRACK',
+ icon: ,
+ heroIcon: 'CollectionsIcon',
+ image: placeHolder,
+ },
+];
+
+const HeroIconSection = ({ shouldShow }) => {
+ const { theme } = useMode();
+ const isMobileView = useMediaQuery(theme.breakpoints.down('sm'));
+ return (
+
+
+
+ {heroCardData?.map((card, index) => (
+
+
+
+
+
+ ))}
+
+
+
+ );
+};
+
+export default HeroIconSection;
diff --git a/src/layout/sections/HeroSection.jsx b/src/layout/sections/HeroSection.jsx
new file mode 100644
index 0000000..e8b0aec
--- /dev/null
+++ b/src/layout/sections/HeroSection.jsx
@@ -0,0 +1,291 @@
+import React, { useEffect, useMemo, useState } from 'react';
+import { ErrorBoundary, useMode, useStatisticsStore } from '../../context';
+import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
+import placeHolder from '../../assets/images/placeholder.jpeg';
+import { Swiper, SwiperSlide } from 'swiper/react';
+import 'swiper/css';
+import 'swiper/css/effect-coverflow';
+import 'swiper/css/pagination';
+import 'swiper/css/navigation';
+import {
+ EffectCoverflow,
+ Pagination,
+ Navigation,
+ Autoplay,
+} from 'swiper/modules';
+import MDTypography from '../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
+import { HeroSectionSkeleton } from '../../layout/REUSABLE_COMPONENTS/SkeletonVariants';
+import {
+ Box,
+ Card,
+ CardContent,
+ CardMedia,
+ Zoom,
+ useMediaQuery,
+} from '@mui/material';
+import pages from '../../data/pages.json';
+import HeroTextSection from './HeroTextSection';
+import HeroIconSection from './HeroIconSection';
+import HeroSwiper from './HeroSwiper';
+import FlexBetween from '../REUSABLE_COMPONENTS/FlexBetween';
+import RCHeader from '../REUSABLE_COMPONENTS/RCHeader';
+import styled from 'styled-components';
+import { ChartArea } from '../../pages/pageStyles/StyledComponents';
+import { useCardStoreHook } from '../../context/hooks/useCardStore';
+import useLocalStorage from '../../context/hooks/useLocalStorage';
+import { AspectRatio } from '@mui/joy';
+import { useLoading } from '../../context/hooks/useLoading';
+import useSkeletonLoader from '../collection/collectionGrids/cards-datatable/useSkeletonLoader';
+import {
+ ResponsiveContainer,
+ CartesianGrid,
+ AreaChart,
+ BarChart,
+ Bar,
+ LineChart,
+ XAxis,
+ YAxis,
+ Legend,
+ Line,
+ Tooltip,
+ Area,
+} from 'recharts';
+import DashboardBox from '../REUSABLE_COMPONENTS/DashboardBox';
+import BoxHeader from '../REUSABLE_COMPONENTS/BoxHeader';
+
+const HeroSection = () => {
+ const { theme } = useMode();
+ const { breakpoints } = theme;
+ const { introText } = pages;
+ const { fetchRandomCardsAndSet } = useCardStoreHook();
+ const [randomCards, setRandomCards] = useLocalStorage('randomCards', []);
+ const isMobileView = useMediaQuery(breakpoints.down('sm'));
+ const isMidView = useMediaQuery(breakpoints.down('md'));
+ const isFullView = useMediaQuery(breakpoints.up('lg'));
+ const { isLoading } = useLoading();
+ const { SkeletonLoader } = useSkeletonLoader();
+ const [activeCardIndex, setActiveCardIndex] = useState(0);
+ const [shouldShow, setShouldShow] = useState(false);
+ const defaultCards = new Array(45).fill({}).map((_, index) => ({
+ id: `default-${index}`,
+ name: `Placeholder ${index + 1}`,
+ description: `Description for Placeholder ${index + 1}`,
+ image: placeHolder,
+ }));
+ const cards = [...randomCards, ...defaultCards];
+ // const swiperConfig = {
+ // effect: 'coverflow',
+ // grabCursor: true,
+ // centeredSlides: true,
+ // loop: true,
+ // resizeObserver: true,
+ // spaceBetween: 10,
+ // coverflowEffect: {
+ // stretch: 0,
+ // modifier: 1,
+ // rotate: 0,
+ // depth: 200,
+ // slideShadows: false,
+ // },
+ // autoplay: {
+ // delay: 2500,
+ // disableOnInteraction: false,
+ // },
+ // modules: [EffectCoverflow, Pagination, Navigation, Autoplay],
+ // scrollbar: {
+ // el: '.swiper-scrollbar',
+ // draggable: true,
+ // },
+ // navigation: {
+ // nextEl: '.swiper-button-next',
+ // prevEl: '.swiper-button-prev',
+ // clickable: true,
+ // },
+ // className: 'swiper_container',
+ // };
+ useEffect(() => setShouldShow(true), []);
+ useEffect(() => fetchRandomCardsAndSet(), []);
+
+ const handleSlideChange = (swiper) => setActiveCardIndex(swiper.realIndex);
+ if (!randomCards.length) return ;
+
+ const chartData = useMemo(() => {
+ return randomCards[activeCardIndex]?.averagedChartData?.['30d']?.data || [];
+ }, [randomCards, activeCardIndex]);
+
+ if (!cards.length) {
+ return ;
+ }
+
+ return (
+
+
+
+
+ {!isMidView && (
+
+
+
+
+
+ {/* */}
+ {/* */}
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {' '}
+
+
+
+
+
+
+
+
+
+
+
+ )}
+
+
+
+ {' '}
+
+ );
+};
+
+export default HeroSection;
diff --git a/src/layout/sections/HeroSwiper.jsx b/src/layout/sections/HeroSwiper.jsx
new file mode 100644
index 0000000..40b80cb
--- /dev/null
+++ b/src/layout/sections/HeroSwiper.jsx
@@ -0,0 +1,164 @@
+import React, { useEffect, useRef } from 'react';
+import { Swiper, SwiperSlide } from 'swiper/react';
+import 'swiper/css';
+import 'swiper/css/effect-coverflow';
+import 'swiper/css/pagination';
+import 'swiper/css/navigation';
+import {
+ EffectCoverflow,
+ Pagination,
+ Navigation,
+ Autoplay,
+} from 'swiper/modules';
+import MDTypography from '../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
+import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
+import placeHolder from '../../assets/images/placeholder.jpeg';
+
+const HeroSwiper = ({
+ cards,
+ isMobileView,
+ handleSlideChange,
+ activeCardIndex,
+}) => {
+ const swiperRef = useRef(null);
+
+ const swiperConfig = {
+ effect: 'coverflow',
+ grabCursor: true,
+ centeredSlides: true,
+ loop: true,
+ resizeObserver: true,
+ spaceBetween: 10,
+ coverflowEffect: {
+ stretch: 0,
+ modifier: 1,
+ rotate: 0,
+ depth: 200,
+ slideShadows: false,
+ },
+ autoplay: {
+ delay: 2500,
+ disableOnInteraction: false,
+ },
+ modules: [EffectCoverflow, Pagination, Navigation, Autoplay],
+ scrollbar: {
+ el: '.swiper-scrollbar',
+ draggable: true,
+ },
+ navigation: {
+ nextEl: '.swiper-button-next',
+ prevEl: '.swiper-button-prev',
+ clickable: true,
+ },
+ className: 'swiper_container',
+ };
+
+ useEffect(() => {
+ // Ensuring the swiper instance is available
+ const swiperInstance = swiperRef.current?.swiper;
+ if (swiperInstance) {
+ // Listen to slideChange event
+ swiperInstance.on('slideChange', () => {
+ const { activeIndex } = swiperInstance;
+ handleSlideChange(activeIndex); // Assuming this function you pass handles updating activeCardIndex
+
+ // Check if the slide is every 4th slide (0-indexed, so we check for 3, 7, 11, ...)
+ if ((activeIndex + 1) % 4 === 0) {
+ swiperInstance.autoplay.stop();
+ setTimeout(() => {
+ swiperInstance?.autoplay?.start();
+ }, 10000); // Pause for 30 seconds
+ }
+ });
+ }
+ }, []);
+
+ return (
+
+
+ `${cards[index].name}`,
+ }}
+ style={{
+ minWidth: '150vw',
+ width: '100%',
+ alignItems: isMobileView ? 'center' : 'flex-start',
+ position: isMobileView ? 'absolute' : 'absolute',
+ height: isMobileView ? 'calc(100vh - 64px)' : null,
+ background: 'transparent',
+
+ // pb: '2rem',
+ ml: isMobileView ? '0' : '60vw',
+ // position: isMobileView ? 'absolute' : 'relative',
+ }}
+ onSlideChange={handleSlideChange}
+ >
+ {cards?.map((card, index) => (
+
+
+ {card.name}
+
+
+
+ ))}
+
+
+ );
+};
+
+export default HeroSwiper;
diff --git a/src/layout/sections/HeroTextSection.jsx b/src/layout/sections/HeroTextSection.jsx
new file mode 100644
index 0000000..cccd26e
--- /dev/null
+++ b/src/layout/sections/HeroTextSection.jsx
@@ -0,0 +1,65 @@
+import { Typography, Zoom, useMediaQuery } from '@mui/material';
+import MDBox from '../REUSABLE_COMPONENTS/MDBOX';
+import { useMode } from '../../context';
+
+const HeroTextSection = ({ shouldShow }) => {
+ const { theme } = useMode();
+ const isMobileView = useMediaQuery(theme.breakpoints.down('sm'));
+ return (
+
+
+
+
+ A New Era of Trading Card Games
+
+
+ Discover a revolutionary way to collect, play, and compete in your
+ favorite trading card games. Embrace a world where strategy and
+ creativity transcend boundaries.
+
+
+
+
+ );
+};
+
+export default HeroTextSection;
diff --git a/src/pages/sections/MainContentSection.jsx b/src/layout/sections/MainContentSection.jsx
similarity index 84%
rename from src/pages/sections/MainContentSection.jsx
rename to src/layout/sections/MainContentSection.jsx
index b97c8a2..ecdb4fa 100644
--- a/src/pages/sections/MainContentSection.jsx
+++ b/src/layout/sections/MainContentSection.jsx
@@ -14,16 +14,15 @@ import {
useAuthContext,
useCollectionStore,
useMode,
- usePageContext,
useUserContext,
} from '../../context';
import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
import MDTypography from '../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
import MDAvatar from '../../layout/REUSABLE_COMPONENTS/MDAVATAR';
import MDButton from '../../layout/REUSABLE_COMPONENTS/MDBUTTON';
-import useCardCronJob from '../../tests/useCardCronJob';
import SingleCardAnimation from '../../assets/animations/SingleCardAnimation';
-import CardChart from '../../tests/CardChart';
+import CardChart from '../../layout/CardChart';
+import useCardCronJob from '../../layout/useCardCronJob';
import {
StyledContainerBox,
StyledPaper,
@@ -32,15 +31,15 @@ import placeHolder from '../../assets/images/placeholder.jpeg';
import { DEFAULT_COLLECTION } from '../../context/constants';
import useCollectionManager from '../../context/MAIN_CONTEXT/CollectionContext/useCollectionManager';
import useSelectedCollection from '../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
+import SimpleButton from '../../layout/REUSABLE_COMPONENTS/unique/SimpleButton';
+import uniqueTheme from '../../layout/REUSABLE_COMPONENTS/unique/uniqueTheme';
const MainContentSection = () => {
const { theme } = useMode();
- const { authUser } = useAuthContext();
+ const { isLoggedIn } = useAuthContext();
const { user } = useUserContext();
-
const { hasFetchedCollections } = useCollectionManager();
const { allCollections, selectedCollection } = useSelectedCollection();
- // const isDataLoaded = allCollections && allCollections.length > 0;
const isMdUp = useMediaQuery(theme.breakpoints.up('md'));
const initialCardsData = hasFetchedCollections
? allCollections[0]?.cards[0]
@@ -63,7 +62,6 @@ const MainContentSection = () => {
{isMdUp && (
{
- {authUser && (
+ {isLoggedIn && (
{
- {
+ console.log('clicked');
+ }}
+ >
+ Manage Collections
+
+ {/* {
}}
>
Manage Collections
-
+ */}
View Purchase History
diff --git a/src/layout/store/StoreSearch.jsx b/src/layout/store/StoreSearch.jsx
index 51d2d99..420b6d6 100644
--- a/src/layout/store/StoreSearch.jsx
+++ b/src/layout/store/StoreSearch.jsx
@@ -1,9 +1,10 @@
import React, { useState } from 'react';
import { useMode } from '../../context';
import MDBox from '../REUSABLE_COMPONENTS/MDBOX';
-import PageLayout from '../Containers/PageLayout';
+import PageLayout from '../REUSABLE_COMPONENTS/PageLayout';
import { PortfolioBoxA } from '../../pages/pageStyles/StyledComponents';
import SearchComponent from '../../components/forms/search/SearchComponent';
+import { Card } from '@mui/material';
const StoreSearch = () => {
const { theme } = useMode();
diff --git a/src/tests/useCardCronJob.jsx b/src/layout/useCardCronJob.jsx
similarity index 65%
rename from src/tests/useCardCronJob.jsx
rename to src/layout/useCardCronJob.jsx
index eae3f04..33c8a20 100644
--- a/src/tests/useCardCronJob.jsx
+++ b/src/layout/useCardCronJob.jsx
@@ -36,37 +36,17 @@ const useCardCronJob = (initialCardData) => {
});
}, []);
- // const updateCardData = useCallback(() => {
- // setCardData((currentCard) => {
- // console.log('Updating card data:', cardData);
- // console.log('Current card data:', currentCard);
- // const newPriceHistory = {
- // num: (Math.random() * 10).toFixed(2), // or however you calculate new price
- // timestamp: new Date().toISOString(),
- // };
-
- // return {
- // ...currentCard,
- // quantity: currentCard.quantity + 1, // Increment quantity or however you update
- // dailyPriceHistory: [...currentCard.dailyPriceHistory, newPriceHistory],
- // };
- // });
- // }, []);
-
- // Simulate a cron job with useEffect and setInterval
useEffect(() => {
const intervalId = setInterval(() => {
- updatePriceHistory(); // Update price history every interval
- }, 120000); // Update every 5 seconds for example, adjust as needed
-
- // Cleanup function to clear interval when component unmounts or updates
+ updatePriceHistory();
+ }, 120000);
return () => clearInterval(intervalId);
}, [updatePriceHistory]);
const startUpdates = useCallback(() => {
console.log('Starting updates');
if (!intervalId) {
- const id = setInterval(updatePriceHistory, 120000); // Update every 2 minutes, adjust as needed
+ const id = setInterval(updatePriceHistory, 120000);
setIntervalId(id);
}
}, [updatePriceHistory, intervalId]);
@@ -85,13 +65,6 @@ const useCardCronJob = (initialCardData) => {
pauseUpdates();
}, [initialCardData, pauseUpdates]);
- // useEffect(() => {
- // return () => {
- // // Cleanup interval on component unmount
- // if (intervalId) clearInterval(intervalId);
- // };
- // }, [intervalId]);
-
return {
cardData,
updatePriceHistory,
diff --git a/src/pages/CartPage.js b/src/pages/CartPage.js
index 3e91a35..b9e0458 100644
--- a/src/pages/CartPage.js
+++ b/src/pages/CartPage.js
@@ -2,12 +2,11 @@ import React, { useEffect } from 'react';
import { useCookies } from 'react-cookie';
import { Box, Card, CardContent, Grid, useTheme } from '@mui/material';
import CartContent from '../layout/cart/CartContent';
-import { useCartStore, useMode, usePageContext } from '../context';
+import { useCartStore, useMode } from '../context';
import Checkout from '../layout/cart/cartPageContainers/Checkout';
-import PageLayout from '../layout/Containers/PageLayout';
+import PageLayout from '../layout/REUSABLE_COMPONENTS/PageLayout';
import { useLoading } from '../context/hooks/useLoading';
-import { CartSummary } from '../layout/cart/CartSummary';
-
+import CartSummary from '../layout/cart/CartSummary';
const CartPage = () => {
const { theme } = useMode();
const {
@@ -19,11 +18,9 @@ const CartPage = () => {
cartCardQuantity,
totalCost,
} = useCartStore();
- const { returnDisplay, setLoading } = usePageContext();
const { startLoading, stopLoading, setError, isPageLoading } = useLoading();
const calculateTotalPrice = getTotalCost();
- // useEffect hook to fetch cart data for user
useEffect(() => {
const fetchData = async () => {
startLoading('isPageLoading');
@@ -36,8 +33,6 @@ const CartPage = () => {
stopLoading('isPageLoading');
}
};
-
- // Fetch cart data if not already loaded
if (!cartData) {
fetchData();
}
@@ -50,16 +45,6 @@ const CartPage = () => {
console.error('Failed to adjust quantity in cart:', e);
}
};
- // Function to render the cart content grid
- const renderCartContent = () => (
-
-
-
- );
// Function to render the checkout and summary section
const renderCheckoutAndSummary = () => (
@@ -96,7 +81,13 @@ const CartPage = () => {
}}
>
- {renderCartContent()}
+
+
+ {' '}
{renderCheckoutAndSummary()}
@@ -107,7 +98,7 @@ const CartPage = () => {
{/* */}
{/* */}
- {isPageLoading && returnDisplay()}
+ {isPageLoading && Loading...
}
{/* {loadingStatus?.isLoading && returnDisplay()} */}
{
const { isPageLoading } = useLoading();
const { closeModal, returnDisplay, isModalOpen, modalContent } =
useLoadingAndModal();
+ const { hasFetchedDecks, fetchDecks } = useDeckManager();
+ const { allDecks } = useSelectedDeck();
+ useEffect(() => {
+ fetchDecks();
+ }, []);
+ // useEffect(() => {
+ // if (!hasFetchedDecks && allDecks.length <= 1) {
+ // fetchDecks();
+ // }
+ // }, []);
return (
{isPageLoading && returnDisplay()}
-
{isModalOpen && (
{
- const { theme } = useMode();
- const { tertiaryContent, secondaryContent, mainContentFeatureCard } =
- theme.skeletonLayouts;
-
- const homePageSkeletonConfigs = [
- {
- ...tertiaryContent,
- skeletons: [...tertiaryContent.baseSkeletons],
- },
- {
- ...secondaryContent,
- skeletons: [secondaryContent.baseSkeleton],
- },
- {
- ...secondaryContent,
- skeletons: [secondaryContent.baseSkeleton], // Assuming similar style for another secondary content
- },
- ...Array.from({ length: tiers.length }, () => ({
- ...mainContentFeatureCard,
- skeletons: [...mainContentFeatureCard.baseSkeletons],
- })),
- ];
-
- return homePageSkeletonConfigs;
-};
const HomePage = () => {
- const { theme } = useMode();
- const { tiers, introText } = pages;
- const { hasFetchedCollections } = useCollectionManager();
- const { allCollections, selectedCollection } = useSelectedCollection();
const {
allFeatureData,
showDetailsModal,
@@ -97,16 +51,16 @@ const HomePage = () => {
return (
- {renderSplashPage()}
+ {/* {renderSplashPage()} */}
{/* INTRO SECTION */}
{/* MAIN CONTENT SECTION */}
-
+ {/*
-
+ */}
{/* FEATURE CARDS SECTION */}
diff --git a/src/pages/LoginPage.jsx b/src/pages/LoginPage.jsx
index a245347..ee595b7 100644
--- a/src/pages/LoginPage.jsx
+++ b/src/pages/LoginPage.jsx
@@ -8,7 +8,7 @@ import Grid from '@mui/material/Grid';
import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
import Typography from '@mui/material/Typography';
import { createTheme, ThemeProvider } from '@mui/material/styles';
-import LoginForm from '../components/forms/LoginForm';
+import LoginForm from '../assets/currentlyUnused/LoginForm';
import { useAuthContext, useMode } from '../context';
import { Navigate, useNavigate } from 'react-router-dom';
import { useCookies } from 'react-cookie';
diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js
index 3b5c1df..5b83180 100644
--- a/src/pages/ProfilePage.js
+++ b/src/pages/ProfilePage.js
@@ -1,100 +1,8 @@
import React, { useState } from 'react';
-import {
- Box,
- Button,
- Typography,
- Avatar,
- IconButton,
- Container,
- Snackbar,
- Grid,
- Paper,
-} from '@mui/material';
-import { Edit as EditIcon } from '@mui/icons-material';
-import placeholder from '../assets/images/placeholder.jpeg';
-import { useUserContext } from '../context/MAIN_CONTEXT/UserContext/UserContext';
-import { useCookies } from 'react-cookie';
-import ThemeToggleButton from '../components/buttons/other/ThemeToggleButton';
-import ProfileForm from '../components/forms/ProfileForm';
-import useResponsiveStyles from '../context/hooks/style-hooks/useResponsiveStyles';
-import { useMode } from '../context';
-import UserStats from '../layout/profile/UserStats';
import Overview from '../layout/profile/index';
const ProfilePage = () => {
- const { updateUser } = useUserContext();
- const { theme } = useMode();
- const { isLarge } = useResponsiveStyles(theme);
- // const isLarge = useMediaQuery(theme.breakpoints.up('lg'));
- const [cookies] = useCookies(['user']);
- const user = cookies?.user;
- const [snackbarData, setSnackbarData] = useState({
- open: false,
- message: '',
- });
-
- const openSnackbar = (message) => {
- setSnackbarData({ open: true, message });
- };
-
- const openEdit = () => {
- openSnackbar('Edit mode enabled');
- };
-
- const handleSaveChanges = (data) => {
- updateUser(data);
- openSnackbar('Saved changes.');
- };
-
return ;
};
export default ProfilePage;
-{
- /* */
-}
-
-{
- /*
-
-
- {user?.userBasicData?.firstName || 'User Profile'}
-
- openEdit()}>
-
-
-
-
-
-
-
-
- Personal Information
-
-
-
-
-
-
-
- Statistics
-
-
-
-
-
-
- setSnackbarData({ ...snackbarData, open: false })}
- message={snackbarData.message}
- /> */
-}
-{
- /* */
-}
diff --git a/src/pages/StorePage.js b/src/pages/StorePage.js
index 47d93fc..2d682b4 100644
--- a/src/pages/StorePage.js
+++ b/src/pages/StorePage.js
@@ -1,11 +1,11 @@
import React, { useRef, useState } from 'react';
import { Grid } from '@mui/material';
-import GenericCardDialog from '../components/dialogs/cardDialog/GenericCardDialog';
+import GenericCardDialog from '../components/dialogs/GenericCardDialog';
import MDBox from '../layout/REUSABLE_COMPONENTS/MDBOX';
import StoreSearch from '../layout/store/StoreSearch';
import useLoadingAndModal from './pageStyles/useLoadingAndModal';
import HeroBanner from './pageStyles/HeroBanner';
-import PageLayout from '../layout/Containers/PageLayout';
+import PageLayout from '../layout/REUSABLE_COMPONENTS/PageLayout';
const StorePage = () => {
const { loadingStatus, returnDisplay, isModalOpen, modalContent } =
useLoadingAndModal();
diff --git a/src/pages/index.js b/src/pages/index.js
index 7160fd1..1e37abd 100644
--- a/src/pages/index.js
+++ b/src/pages/index.js
@@ -4,6 +4,6 @@ export { default as ProfilePage } from './ProfilePage';
export { default as DeckBuilderPage } from './DeckBuilderPage';
export { default as CollectionPage } from './CollectionPage';
export { default as CartPage } from './CartPage';
-export { default as SplashPage } from '../assets/animations/SplashPage';
+// export { default as SplashPage } from '../assets/animations/SplashPage';
export { default as StorePage } from './StorePage';
-export { default as LoginPage } from './LoginPage';
+// export { default as LoginPage } from '../save/LoginPage';
diff --git a/src/pages/pageStyles/StyledComponents.jsx b/src/pages/pageStyles/StyledComponents.jsx
index 2f1d46e..4114d43 100644
--- a/src/pages/pageStyles/StyledComponents.jsx
+++ b/src/pages/pageStyles/StyledComponents.jsx
@@ -61,8 +61,9 @@ export const StyledAppBar = styled(AppBar)(({ theme }) => ({
border: '2px solid white',
// left: -20,
// borderRadius: '30px',
- background:
- 'linear-gradient(90deg, rgba(13, 93, 150, 1) 0%, rgba(160, 214, 186, 1) 100%);', // Subtle blue to green gradient
+ background: '#141414',
+ // background:
+ // 'linear-gradient(90deg, rgba(13, 93, 150, 1) 0%, rgba(160, 214, 186, 1) 100%);', // Subtle blue to green gradient
}));
export const StyledToolBarContainer = styled(AppBar)(({ theme }) => ({
// display: 'flex',
@@ -71,7 +72,7 @@ export const StyledToolBarContainer = styled(AppBar)(({ theme }) => ({
// alignItems: 'center',
// width: '100%',
// Do not explicitly set the height here to allow Toolbar's default styling to take effect
- backgroundColor: theme.palette.backgroundA.darker,
+ // backgroundColor: theme.palette.backgroundA.darker,
// borderRadius: '30px',
flexGrow: 1,
@@ -464,7 +465,7 @@ export const CardListItem = styled(ListItem)(({ theme }) => ({
export const ChartArea = styled(Container)(({ theme }) => ({
height: '100%',
width: '100%',
- minHeight: '500px',
+ // minHeight: '500px',
position: 'relative',
flexGrow: 1,
padding: theme.spacing(2),
@@ -567,7 +568,7 @@ export const AspectRatioBoxSkeleton = styled(Box)(({ theme }) => ({
export const StyledCollectionListCard = styled(Card)(({ theme }) => ({
// margin: theme.spacing(1),
width: '100%',
- // height: '100%',
+ height: '100%',
flexGrow: 1,
transition: 'transform 0.3s ease-in-out',
boxShadow: '0 8px 40px -12px rgba(0,0,0,0.3)',
diff --git a/src/pages/pageStyles/useLoadingAndModal.jsx b/src/pages/pageStyles/useLoadingAndModal.jsx
index eefde2d..46935cf 100644
--- a/src/pages/pageStyles/useLoadingAndModal.jsx
+++ b/src/pages/pageStyles/useLoadingAndModal.jsx
@@ -1,12 +1,10 @@
// This is a conceptual example, adjust based on actual logic
-import { useModalContext, usePageContext } from '../../context';
+import { useModalContext } from '../../context';
const useLoadingAndModal = () => {
- const { returnDisplay } = usePageContext();
const { isModalOpen, modalContent, closeModal } = useModalContext();
return {
- returnDisplay,
isModalOpen,
modalContent,
closeModal,
diff --git a/src/pages/sections/HeroSection.jsx b/src/pages/sections/HeroSection.jsx
deleted file mode 100644
index b877815..0000000
--- a/src/pages/sections/HeroSection.jsx
+++ /dev/null
@@ -1,306 +0,0 @@
-import React, { useState } from 'react';
-import { useMode, useStatisticsStore } from '../../context';
-import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
-import placeHolder from '../../assets/images/placeholder.jpeg';
-import { Swiper, SwiperSlide } from 'swiper/react';
-
-// Import Swiper styles
-import 'swiper/css';
-import 'swiper/css/effect-coverflow';
-import 'swiper/css/pagination';
-import 'swiper/css/navigation';
-
-// Corrected imports for Swiper modules
-import {
- EffectCoverflow,
- Pagination,
- Navigation,
- Autoplay,
-} from 'swiper/modules';
-import MDTypography from '../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-import HeroSectionSkeleton from '../../layout/REUSABLE_COMPONENTS/SkeletonVariants';
-
-// const
-// return cards?.map((card, index) => (
-//
-// {/* */}
-//
-// {/* */}
-//
-// ));
-// };
-
-const HeroSection = () => {
- const { theme } = useMode();
- // const isXs = useMediaQuery(theme.breakpoints.down('sm'));
- const [activeCardIndex, setActiveCardIndex] = useState(0);
- const { topFiveCards } = useStatisticsStore();
- // Create 30 default card objects
- const defaultCards = new Array(30).fill({}).map((_, index) => ({
- id: `default-${index}`,
- name: `Placeholder ${index + 1}`,
- description: `Description for Placeholder ${index + 1}`,
- image: placeHolder, // Use the placeholder image for all default cards
- }));
-
- // Combine topFiveCards with defaultCards
- const cards = [...topFiveCards, ...defaultCards];
- const handleSlideChange = (swiper) => {
- setActiveCardIndex(swiper.realIndex);
- };
-
- if (!cards || !Array.isArray(cards) || !cards[activeCardIndex]) {
- return ;
- }
-
- return (
-
-
- {/* Ensure there's always a string value, even if it's empty */}
-
- {topFiveCards[activeCardIndex]?.name || ''}
-
-
- {/* Same for the description */}
-
- {topFiveCards[activeCardIndex]?.description || ''}
-
-
-
- {cards.map((card, index) => (
-
-
-
- ))}
-
-
-
- );
-};
-
-export default HeroSection;
-//
-// {return cards?.map((card, index) => (
-//
-// {/* */}
-//
-// {/* */}
-//
-// ))}
-//
-//
-//
-// );
-// };
-
-// export default HeroSection;
-// import React, { useState } from 'react';
-// import { Box, Typography } from '@mui/material';
-// import { Swiper, SwiperSlide } from 'swiper/react';
-// import 'swiper/css';
-// import 'swiper/css/effect-coverflow';
-// import 'swiper/css/pagination';
-// import 'swiper/css/navigation';
-// // import { EffectCoverflow, Pagination, Navigation } from 'swiper';
-// import { EffectCoverflow, Pagination, Navigation } from 'swiper/modules';
-
-// import MDBox from '../../layout/REUSABLE_COMPONENTS/MDBOX';
-// import placeHolder from '../../assets/images/placeholder.jpeg';
-// import { useStatisticsStore } from '../../context';
-
-// const HeroSection = () => {
-// const [activeCardIndex, setActiveCardIndex] = useState(0);
-// const { topFiveCards } = useStatisticsStore();
-
-// if (!topFiveCards || !Array.isArray(topFiveCards)) {
-// return null;
-// }
-
-// // Handle the slide change event
-// const handleSlideChange = (swiper) => {
-// setActiveCardIndex(swiper.realIndex);
-// };
-
-// const createSlider = (cards) => {
-// return (
-//
-// {cards.map((card, index) => (
-//
-//
-//
-//
-//
-// ))}
-//
-// );
-// };
-
-// return (
-//
-//
-// {topFiveCards[activeCardIndex]?.name}
-//
-// {createSlider(topFiveCards)}
-// {topFiveCards[activeCardIndex]?.description}
-//
-// );
-// };
-
-// export default HeroSection;
diff --git a/src/assets/serviceWorker.js b/src/serviceWorker.js
similarity index 100%
rename from src/assets/serviceWorker.js
rename to src/serviceWorker.js
diff --git a/src/tests/CardChart.jsx b/src/tests/CardChart.jsx
deleted file mode 100644
index 7612de5..0000000
--- a/src/tests/CardChart.jsx
+++ /dev/null
@@ -1,333 +0,0 @@
-import React, {
- useState,
- useEffect,
- useCallback,
- useLayoutEffect,
- useMemo,
- useRef,
-} from 'react';
-import {
- Avatar,
- Box,
- Button,
- Card,
- CardActions,
- CardContent,
- CardHeader,
- Container,
- Grid,
- IconButton,
- List,
- ListItem,
- Paper,
- Typography,
- useMediaQuery,
- useTheme,
-} from '@mui/material';
-import MoreVertIcon from '@mui/icons-material/MoreVert';
-import CardLinearChart from './CardLinearChart';
-import {
- ErrorBoundary,
- useCollectionStore,
- useMode,
- usePageContext,
-} from '../context';
-import useCardCronJob from './useCardCronJob';
-import initialCardData from './initialCardData';
-import { format } from 'date-fns';
-import LoadingCardAnimation from '../assets/animations/LoadingCardAnimation';
-import styled from 'styled-components';
-import MDButton from '../layout/REUSABLE_COMPONENTS/MDBUTTON';
-import { useLoading } from '../context/hooks/useLoading';
-
-// Adjust the padding, margin, and other styles as needed
-const ChartArea = styled(Box)(({ theme }) => ({
- width: '100%',
- height: '100%',
- padding: theme.spacing(2),
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- border: '1px solid #000',
- borderRadius: '5px',
-}));
-// A square, responsive container for the chart
-const SquareChartContainer = styled(Box)(({ theme }) => ({
- position: 'relative',
- width: '100%', // 100% of the parent width
- paddingTop: '100%', // Maintain aspect ratio (1:1)
- overflow: 'hidden',
- '& > *': {
- position: 'absolute',
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- },
-}));
-
-const CardChart = ({ cardData = initialCardData }) => {
- // STYLING AND MEDIA QUERY HOOKS
- const { theme } = useMode();
- const isLgUp = useMediaQuery(theme.breakpoints.up('lg'));
- const [imageUrl, setImageUrl] = useState(null);
- const { startUpdates, pauseUpdates, resetData } =
- useCardCronJob(initialCardData);
- const formatTimestamp = (timestamp) =>
- format(new Date(timestamp), "MMM do, yyyy 'at' HH:mm");
- const [chartDimensions, setChartDimensions] = useState({
- width: 0,
- height: 0,
- });
- const { returnDisplay } = usePageContext();
- const { isLoading } = useLoading();
- const safeCardData = cardData || { dailyPriceHistory: [] };
- useEffect(() => {
- if (cardData?.imageUrl) {
- console.log('Setting image url', cardData?.imageUrl);
- setImageUrl(cardData?.image);
- }
- }, [cardData?.imageUrl]);
-
- // const chartData = useMemo(
- // () =>
- // dailyPriceHistory?.map((priceEntry) => ({
- // x: priceEntry?.timestamp,
- // y: priceEntry?.num,
- // })),
- // [dailyPriceHistory] // dependency array
- // );
- const nivoReadyData = useMemo(
- () => [
- {
- id: cardData?.name || 'default',
- data: cardData?.dailyPriceHistory?.map(({ timestamp, num }) => ({
- x: timestamp,
- y: num,
- })),
- },
- ],
- [cardData]
- );
- const renderLoadingAnimation = () =>
- isLgUp && ;
- useEffect(() => {
- if (isLoading('fetchCollections')) {
- console.log('Fetching collections');
- }
- }, [isLoading('fetchCollections')]);
- // Add responsive chart dimension handling
- useEffect(() => {
- // Example of setting dynamic chart dimensions (could be more complex based on container size)
- const updateDimensions = () => {
- const width = window.innerWidth < 500 ? window.innerWidth : 500; // or some other logic
- const height = 300; // Fixed height or based on aspect ratio
- setChartDimensions({ width, height });
- };
-
- window.addEventListener('resize', updateDimensions);
- updateDimensions(); // Initial call
-
- return () => {
- window.removeEventListener('resize', updateDimensions); // Cleanup listener
- };
- }, []); // Empty array ensures this effect runs only once after initial render
- // Simplified for demonstration
- // const renderLoadingAnimation = () => {
- // return ;
- // };
- const renderHeaderWithAnimation = () => {
- return (
-
-
- // }
- action={
-
-
-
- }
- title="Card Cron Job Simulator"
- subheader={cardData?.name || 'Card Name'}
- sx={{
- padding: theme.spacing(1),
- margin: theme.spacing(1),
- }}
- />
- {/* Conditionally render animation based on size or other conditions */}
- {isLgUp && renderLoadingAnimation()}
-
- );
- };
- return (
-
-
-
-
- {renderHeaderWithAnimation()}
-
-
-
-
- {isLoading('fetchCollections') ? (
- returnDisplay()
- ) : (
-
-
-
- )}
-
-
-
-
-
-
- {['Start Updates', 'Pause Updates', 'Reset Data'].map(
- (text, index) => (
- {
- if (text === 'Start Updates') startUpdates();
- else if (text === 'Pause Updates') pauseUpdates();
- else if (text === 'Reset Data') resetData();
- }}
- color="primary"
- variant="contained"
- sx={{
- color: theme.palette.backgroundA.contrastText,
- background: theme.palette.backgroundF.darker,
- borderColor: theme.palette.backgroundB.darkest,
- borderWidth: 2,
- mt: 'auto',
- flexGrow: 1,
- justifySelf: 'bottom',
- bottom: 0,
- width: '100%',
- '&:hover': {
- color: theme.palette.backgroundA.contrastTextC,
- fontWeight: 'bold',
- background: theme.palette.backgroundF.dark,
- borderColor: theme.palette.backgroundB.darkest,
- border: `1px solid ${theme.palette.backgroundB.darkest}`,
- },
- }}
- >
- {text}
-
- )
- )}
-
- {/* */}
-
-
-
- {cardData?.dailyPriceHistory?.map((entry, index) => (
-
-
- Quantity: {cardData?.quantity}
-
-
- Price: ${entry?.num}
-
-
- {formatTimestamp(entry?.timestamp)}
-
-
- ))}
-
-
-
-
-
-
- );
-};
-
-export default CardChart;
diff --git a/src/tests/CardLinearChart.jsx b/src/tests/CardLinearChart.jsx
deleted file mode 100644
index 435596d..0000000
--- a/src/tests/CardLinearChart.jsx
+++ /dev/null
@@ -1,215 +0,0 @@
-import { Box, Tooltip, Typography, useMediaQuery } from '@mui/material';
-
-import { ResponsiveLine } from '@nivo/line';
-import { useCallback, useMemo, useState } from 'react';
-import { useMode } from '../context';
-import styled from 'styled-components';
-const AxisLabel = styled('div')(({ theme }) => ({
- position: 'absolute',
- textAlign: 'center',
- margin: theme.spacing(2),
- fontSize: '1rem',
- fontWeight: 'bold',
- color: theme.palette.text.primary,
-}));
-
-const ChartContainer = styled(Box)(({ theme }) => ({
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- width: '100%',
- height: 'auto',
- [theme.breakpoints.down('sm')]: {
- width: '150%', // Adjust width for mobile screens
- height: '300px', // Adjust height for mobile screens
- transform: 'translateX(10%)', // Shift the chart to the right by 50%
- },
-}));
-
-const CustomTooltip = ({ point }) => {
- const { theme } = useMode();
- const { serieId, data: { label, xFormatted, yFormatted } = {} } = point;
- return (
-
-
-
- {`Card: ${label}`}
-
-
- {`Time: ${new Date(xFormatted).toLocaleString()}`}
-
-
- {`Value: $${parseFloat(yFormatted).toFixed(2)}`}
-
-
-
- );
-};
-const parseDate = (dateString) => {
- const date = new Date(dateString);
- if (isNaN(date.getTime())) {
- console.error(`Invalid date: ${dateString}`);
- return null; // or a sensible default, or throw an error, depending on your needs
- }
- return date;
-};
-export const useEventHandlers = () => {
- const [hoveredData, setHoveredData] = useState(null);
- const handleMouseMove = useCallback((point) => {
- setHoveredData(point ? { x: point.data.x, y: point.data.y } : null);
- }, []);
- const handleMouseLeave = useCallback(() => setHoveredData(null), []);
- return { hoveredData, handleMouseMove, handleMouseLeave };
-};
-
-const CardLinearChart = ({ nivoReadyData, dimensions }) => {
- const { theme } = useMode();
-
- // Ensure all data points have valid dates
- const processedData = useMemo(() => {
- return nivoReadyData?.map((series) => ({
- ...series,
- data: series?.data?.map((point) => ({
- ...point,
- x: parseDate(point?.x) || point?.x, // Use the parsed date or fallback to the original value
- })),
- }));
- }, [nivoReadyData]);
-
- const chartProps = useMemo(
- () => ({
- data: processedData,
- margin: { top: 20, right: 20, bottom: 20, left: 35 },
- xScale: {
- type: 'time',
- format: 'time:%Y-%m-%dT%H:%M:%S.%LZ',
- useUTC: false,
- precision: 'second',
- },
- axisBottom: {
- tickRotation: 0,
- legend: 'Time',
- legendOffset: 36,
- legendPosition: 'middle',
- tickSize: 5,
- tickPadding: 5,
- tickValues: 'every 2 days',
- format: '%b %d',
- },
- enableSlices: 'x',
- yScale: { type: 'linear', min: 'auto', max: 'auto' },
- }),
- [nivoReadyData, processedData]
- );
-
- if (!processedData || !processedData?.length) {
- return No data available;
- }
- return (
-
-
-
- );
-};
-
-export default CardLinearChart;
-// const { theme } = useMode();
-// const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
-// const [isZoomed, setIsZoomed] = useState(false);
-// const { handleMouseMove, handleMouseLeave } = useEventHandlers();
-
-// if (
-// !nivoReadyData ||
-// nivoReadyData.length === 0 ||
-// !Array.isArray(nivoReadyData)
-// ) {
-// return No data available;
-// }
-
-// // Correct the date parsing logic
-// const processedData = nivoReadyData.map((series) => ({
-// ...series,
-// data: series.data.map((point) => ({
-// ...point,
-// x: parseDate(point.x) || point.x, // Use the parsed date or fallback to the original value
-// })),
-// }));
-
-// // Ensure all data points have valid dates
-// nivoReadyData?.forEach((series) => {
-// series?.data?.forEach((point) => {
-// const date = parseDate(point?.x);
-// if (!(date instanceof Date)) {
-// // Convert to date or handle error
-// console.warn('Invalid date found in chart data', date);
-
-// // Example of converting to date
-// const date = new Date(date);
-// if (date instanceof Date && !isNaN(date)) {
-// point.x = date;
-// }
-// }
-// });
-// });
-
-// Calculate chart properties based on nivoReadyData and dimensions
-// Minimal chart properties for testing
-// animate: true,
-// motionStiffness: 90,
-// motionDamping: 15,
-// axisLeft: {
-// orient: 'left',
-// legend: 'Price',
-// legendOffset: -40,
-// legendPosition: 'middle',
-// tickSize: 5,
-// tickPadding: 5,
-// },
-// pointSize: 10,
-// pointColor: { theme: 'background' },
-// pointBorderWidth: 2,
-// pointBorderColor: { from: 'serieColor' },
-// useMesh: true,
-// const chartProps = useMemo(
-// () => ({
-// data: processedData,
-// margin: { top: 50, right: 110, bottom: 50, left: 60 },
-// xScale: {
-// type: 'time',
-// format: 'time:%Y-%m-%dT%H:%M:%S.%LZ',
-// useUTC: false,
-// precision: 'second',
-// },
-// xFormat: 'time:%Y-%m-%d %H:%M:%S',
-// yScale: { type: 'linear', min: 'auto', max: 'auto' },
-// animate: true,
-// motionStiffness: 90,
-// motionDamping: 15,
-// axisLeft: {
-// orient: 'left',
-// legend: 'Price',
-// legendOffset: -40,
-// legendPosition: 'middle',
-// tickSize: 5,
-// tickPadding: 5,
-// },
-// pointSize: 10,
-// pointColor: { theme: 'background' },
-// pointBorderWidth: 2,
-// pointBorderColor: { from: 'serieColor' },
-// useMesh: true,
-// enableSlices: 'x',
-// }),
-// [processedData, theme, isMobile] // Add other dependencies as needed
-// ); // Add other dependencies as needed
-
-// console.log('Nivo Ready Data:', nivoReadyData);
-// console.log('Processed Data:', processedData);
-// console.log('Chart Dimensions:', dimensions);
diff --git a/src/tests/initialCardData.jsx b/src/tests/initialCardData.jsx
deleted file mode 100644
index 338d229..0000000
--- a/src/tests/initialCardData.jsx
+++ /dev/null
@@ -1,113 +0,0 @@
-const initialCardData = {
- archetype: [],
- atk: 3000,
- attribute: 'DARK',
- card_images: [
- /* array of card image objects */
- ],
- card_prices: [
- /* array of card price objects */
- ],
- card_set: {
- set_name: 'Ghosts From the Past: The 2nd Haunting',
- set_code: 'GFP2-EN125',
- set_rarity: 'Ultra Rare',
- set_rarity_code: '(UR)',
- set_price: {
- /* set price details */
- },
- },
- card_sets: [
- /* array of card set objects */
- ],
- chart_datasets: [
- /* array of chart data set objects */
- ],
- collectionId: '658cf52f32298ed0e5a25e5a',
- // dailyPriceHistory tracks a card's price history by saving one price and timestamp every 24 hours
- dailyPriceHistory: [
- {
- num: 1.03,
- timestamp: '2023-12-20T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec315a',
- },
- {
- num: 1.21,
- timestamp: '2023-12-21T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec315a',
- },
- {
- num: 1.17,
- timestamp: '2023-12-22T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec315a',
- },
- {
- num: 1.18,
- timestamp: '2023-12-23T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec315a',
- },
- {
- num: 1.27,
- timestamp: '2023-12-24T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec315a',
- },
- {
- num: 1.4,
- timestamp: '2023-12-25T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec315a',
- },
- {
- num: 1.49,
- timestamp: '2023-12-26T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec315a',
- },
- {
- num: 1.7,
- timestamp: '2023-12-27T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec315a',
- },
- {
- num: 1.73,
- timestamp: '2023-12-28T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec315a',
- },
- ],
- dataOfLastPriceUpdate: '2023-12-28T05:10:42.524Z',
- def: 2500,
- // eslint-disable-next-line max-len
- desc: '"Dark Magician" + 1 Dragon monster\nThis card\'s name becomes "Dark Magician" while on the field or in the GY. Your opponent cannot target Spells/Traps you control with card effects, also they cannot be destroyed by your opponent\'s card effects.',
- frameType: 'fusion',
- id: '41721210',
- image: 'https://images.ygoprodeck.com/images/cards/41721210.jpg',
- lastSavedPrice: {
- num: 1.03,
- timestamp: '2023-12-28T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec3158',
- },
- latestPrice: {
- num: 1.03,
- timestamp: '2023-12-28T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec3157',
- },
- level: 8,
- name: 'Dark Magician the Dragon Knight',
- price: 1.03,
- priceHistory: [
- {
- num: 1.03,
- timestamp: '2023-12-28T05:10:42.524Z',
- _id: '658d0676dc5934dc44ec3159',
- },
- ],
- quantity: 1,
- race: 'Dragon',
- rarity: 'Ultra Rare',
- tag: '',
- totalPrice: 1.03,
- type: 'Fusion Monster',
- watchList: false,
- __v: 0,
- _id: '658d0676dc5934dc44ec3156',
-};
-
-export default initialCardData;
diff --git a/src/zcleanup/AddButton.jsx b/src/zcleanup/AddButton.jsx
deleted file mode 100644
index 66a64d0..0000000
--- a/src/zcleanup/AddButton.jsx
+++ /dev/null
@@ -1,71 +0,0 @@
-// import { LoadingButton } from '@mui/lab';
-// import MDButton from '../../../layout/REUSABLE_COMPONENTS/MDBUTTON'; // Assuming MDButton is used elsewhere or can be removed if not needed
-// import AddIcon from '@mui/icons-material/Add'; // Make sure this import is used if you need it elsewhere in your component or remove it if it's unused
-// import { AddCircleOutlineOutlined } from '@mui/icons-material';
-// import { useMode } from '../../../context';
-// import MDTypography from '../../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-// import { getContextIcon } from '../../reusable/icons';
-// import { useLoading } from '../../../context/hooks/useLoading';
-
-// const getLabelAndVariant = (buttonSize, labelValue, action) => {
-// const labelTypeMap = {
-// extraSmall: null,
-// small: `${action}`,
-// medium: `${action}`,
-// // large: `${action}` + action === 'add' ? 'to ' : 'from ' + `${labelValue}`,
-// large: `${labelValue}`,
-// };
-// const buttonVariantMap = {
-// extraSmall: 'body4',
-// small: 'body3',
-// medium: 'body2',
-// large: 'body4',
-// };
-// return {
-// buttonLabel: labelTypeMap[buttonSize],
-// buttonVariant: buttonVariantMap[buttonSize],
-// };
-// };
-// // Styled add button
-// const AddButton = ({ buttonSize, handleCardAction, labelValue, action }) => {
-// const { theme } = useMode();
-// // const currentContextIcon = getContextIcon(labelValue);
-// const tempLabel = action === 'add' ? 'Add' : 'Remove';
-// const { startLoading, stopLoading, isLoading } = useLoading();
-// const { buttonLabel, buttonVariant } = getLabelAndVariant(
-// buttonSize,
-// tempLabel,
-// // labelValue,
-// action
-// );
-
-// return (
-// handleCardAction('add')}
-// startIcon={}
-// sx={{
-// width: '100%',
-// flexGrow: 1,
-// borderRadius: theme.shape.borderRadius,
-// maxWidth: '100%',
-// backgroundColor: theme.palette.success.main,
-// justifyContent: 'center',
-// alignItems: 'center',
-// display: 'flex',
-// }}
-// >
-//
-// {buttonLabel}
-//
-//
-// );
-// };
-
-// export default AddButton;
diff --git a/src/zcleanup/CollectionPortfolioContent.jsx b/src/zcleanup/CollectionPortfolioContent.jsx
deleted file mode 100644
index 8471e88..0000000
--- a/src/zcleanup/CollectionPortfolioContent.jsx
+++ /dev/null
@@ -1,58 +0,0 @@
-// // PortfolioContent.jsx
-// import React, { useEffect, useState } from 'react';
-// import { Grid } from '@mui/material';
-// // eslint-disable-next-line max-len
-// import { useCollectionStore } from '../../context/MAIN_CONTEXT/CollectionContext/CollectionContext';
-// import { useMode } from '../../context';
-// import DashboardLayout from '../Containers/DashBoardLayout';
-// import MDBox from '../REUSABLE_COMPONENTS/MDBOX';
-// import collectionPortfolioData from './data/collectionPortfolioData';
-// import ChartGridLayout from './collectionGrids/ChartGridLayout';
-// import StatisticsCardGrid from './collectionGrids/StatisticsCardsGrid';
-// import CollectionPortfolioHeader from './sub-components/CollectionPortfolioHeader';
-
-// const CollectionPortfolioContent = ({ selectedCards, removeCard, onBack }) => {
-// const { theme } = useMode();
-
-// const { selectedCollection, totalQuantity } = useCollectionStore();
-// const [collectionName, setCollectionName] = useState(
-// selectedCollection?.name || ''
-// );
-// const { columns, data } = collectionPortfolioData(
-// selectedCollection?.cards,
-// null,
-// null,
-// null
-// );
-
-// return (
-//
-//
-// {/* HEADER */}
-//
-//
-//
-// {/* STATISTICS FEATURE GRID */}
-//
-//
-//
-// {/* CHARTS */}
-//
-//
-//
-//
-//
-// );
-// };
-
-// export default CollectionPortfolioContent;
diff --git a/src/zcleanup/InputComponents/CardNameInput.js b/src/zcleanup/InputComponents/CardNameInput.js
deleted file mode 100644
index ac66225..0000000
--- a/src/zcleanup/InputComponents/CardNameInput.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// import React from 'react';
-// import { Input } from '@mui/material';
-// import { useCardStore } from '../../../context/CardContext/CardStore';
-
-// const CardNameInput = ({ value, setValue, handleChange }) => {
-// const { handleRequest } = useCardStore();
-// return (
-// {
-// if (event.key === 'Enter') {
-// handleRequest(value);
-// }
-// }}
-// value={value}
-// />
-// );
-// };
-
-// export default CardNameInput;
diff --git a/src/zcleanup/InputComponents/UpdateStatusBox.jsx b/src/zcleanup/InputComponents/UpdateStatusBox.jsx
deleted file mode 100644
index ff2863e..0000000
--- a/src/zcleanup/InputComponents/UpdateStatusBox.jsx
+++ /dev/null
@@ -1,100 +0,0 @@
-// import React, { useState, useEffect } from 'react';
-// import { Box, Typography } from '@mui/material';
-// import { useCombinedContext } from '../../../context/CombinedProvider';
-// import { useCookies } from 'react-cookie';
-
-// const UpdateStatusBox = ({ socket }) => {
-// const { allCollectionData, listOfMonitoredCards, listOfSimulatedCards } =
-// useCombinedContext();
-// const [currentTime, setCurrentTime] = useState(new Date());
-// const [updateStatus, setUpdateStatus] = useState('Waiting for updates...');
-// const [cookies] = useCookies(['authUser']);
-
-// useEffect(() => {
-// const timeInterval = setInterval(() => {
-// setCurrentTime(new Date());
-// }, 1000);
-
-// const handleStatusUpdate = (statusUpdate) => {
-// setUpdateStatus(statusUpdate.message || 'Waiting for updates...');
-// };
-
-// if (socket) {
-// socket.on('STATUS_UPDATE', handleStatusUpdate);
-// }
-
-// // Cleanup function
-// return () => {
-// clearInterval(timeInterval);
-// if (socket) {
-// socket.off('STATUS_UPDATE', handleStatusUpdate);
-// }
-// };
-// }, [socket]);
-
-// const sendUpdateRequest = () => {
-// if (socket) {
-// socket.emit('STATUS_UPDATE_REQUEST', {
-// message: 'Requesting status update...',
-// data: listOfMonitoredCards,
-// });
-// }
-// };
-
-// // Styling for dark theme
-// const styles = {
-// container: {
-// padding: '15px',
-// border: '2px solid #444',
-// borderRadius: '8px',
-// backgroundColor: '#222',
-// color: '#fff',
-// // margin: '20px auto',
-// boxShadow: '0 4px 8px rgba(0, 0, 0, 0.2)',
-// fontFamily: '"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
-// maxWidth: '400px',
-// display: 'flex',
-// flexDirection: 'column',
-// justifyContent: 'space-between',
-// alignItems: 'center',
-// height: '100%', // Adjust height here
-// width: '100%', // Adjust width here
-// },
-// statusBox: {
-// marginTop: '15px',
-// padding: '10px',
-// background: '#333',
-// borderRadius: '6px',
-// border: '1px solid #555',
-// },
-// button: {
-// padding: '10px 20px',
-// marginTop: '10px',
-// border: 'none',
-// borderRadius: '5px',
-// cursor: 'pointer',
-// backgroundColor: '#5CDB95',
-// color: 'white',
-// fontWeight: 'bold',
-// fontSize: '14px',
-// letterSpacing: '1px',
-// outline: 'none',
-// },
-// };
-
-// return (
-//
-//
-// Current Time: {currentTime.toLocaleTimeString()}
-//
-//
-// Update Status: {updateStatus}
-//
-//
-//
-// );
-// };
-
-// export default UpdateStatusBox;
diff --git a/src/zcleanup/InputComponents/UpdateStatusBox2.jsx b/src/zcleanup/InputComponents/UpdateStatusBox2.jsx
deleted file mode 100644
index 33f0a74..0000000
--- a/src/zcleanup/InputComponents/UpdateStatusBox2.jsx
+++ /dev/null
@@ -1,91 +0,0 @@
-// import React, { useState, useEffect } from 'react';
-// import { Snackbar, Typography, Box, Button } from '@mui/material';
-// import { useCookies } from 'react-cookie';
-// import { useCombinedContext, useMode } from '../../../context';
-// import { StyledChartBox } from '../../../pages/pageStyles/StyledComponents';
-
-// const UpdateStatusBox2 = ({ socket }) => {
-// const { listOfMonitoredCards, handleSendAllCardsInCollections } =
-// useCombinedContext();
-// const [currentTime, setCurrentTime] = useState(new Date());
-// const [updateStatus, setUpdateStatus] = useState('Waiting for cron...');
-// const [cookies] = useCookies(['authUser']);
-// const [snackbarData, setSnackbarData] = useState({
-// open: false,
-// message: '',
-// });
-
-// const userId = cookies?.authUser?.userId;
-// const { theme } = useMode();
-// const openSnackbar = (message) => {
-// setSnackbarData({ open: true, message });
-// };
-
-// useEffect(() => {
-// const timeInterval = setInterval(() => {
-// setCurrentTime(new Date());
-// }, 1000);
-
-// const handleStatusUpdate = (statusUpdate) => {
-// setUpdateStatus(
-// (prevStatus) =>
-// statusUpdate.message || prevStatus || 'Waiting for updates...'
-// );
-// };
-
-// socket?.on('INITIAL_RESPONSE', handleStatusUpdate);
-
-// return () => {
-// clearInterval(timeInterval);
-// socket?.off('INITIAL_RESPONSE', handleStatusUpdate);
-// };
-// }, [socket]); // Assuming `socket` is stable and doesn't change on every render
-
-// const handleTriggerCronJob = () => {
-// if (userId && listOfMonitoredCards.length > 0) {
-// handleSendAllCardsInCollections(userId, listOfMonitoredCards);
-// openSnackbar('Triggered the cron job.');
-// }
-// };
-
-// return (
-//
-//
-// Current Time: {currentTime.toLocaleTimeString()}
-//
-//
-// Update Status: {updateStatus}
-//
-//
-// setSnackbarData({ ...snackbarData, open: false })}
-// message={snackbarData.message}
-// />
-//
-// );
-// };
-
-// export default UpdateStatusBox2;
diff --git a/src/zcleanup/RemoveButton.jsx b/src/zcleanup/RemoveButton.jsx
deleted file mode 100644
index bb2c7ce..0000000
--- a/src/zcleanup/RemoveButton.jsx
+++ /dev/null
@@ -1,75 +0,0 @@
-// import { LoadingButton } from '@mui/lab';
-// import MDButton from '../../../layout/REUSABLE_COMPONENTS/MDBUTTON';
-// import RemoveIcon from '@mui/icons-material/Remove';
-// import { useMode } from '../../../context';
-// import { RemoveCircleOutlineOutlined } from '@mui/icons-material';
-// import MDTypography from '../../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-// import { getContextIcon } from '../../reusable/icons';
-// import { useLoading } from '../../../context/hooks/useLoading';
-// const getLabelAndVariant = (buttonSize, labelValue, action) => {
-// const labelTypeMap = {
-// extraSmall: null,
-// small: `${action}`,
-// medium: `${action}`,
-// large: `${action}` + action === 'add' ? 'to' : 'from' + `${labelValue}`,
-// };
-// const buttonVariantMap = {
-// extraSmall: 'body4',
-// small: 'body3',
-// medium: 'body2',
-// large: 'body4',
-// };
-// return {
-// buttonLabel: labelTypeMap[buttonSize],
-// buttonVariant: buttonVariantMap[buttonSize],
-// };
-// };
-// // Styled remove button
-// const RemoveButton = ({ buttonSize, handleCardAction, labelValue, action }) => {
-// const { theme } = useMode();
-// const currentContextIcon = getContextIcon(labelValue);
-// const { startLoading, stopLoading, isLoading } = useLoading();
-// const { buttonLabel, buttonVariant } = getLabelAndVariant(
-// buttonSize,
-// labelValue,
-// action
-// );
-
-// return (
-// handleCardAction('remove')}
-// // getButtonLabel={getButtonLabel}
-// startIcon={}
-// sx={{
-// width: '100%', // Button grows to fill the container
-// flexGrow: 1, // Grow to fill the parent container
-// // minWidth: buttonSize === 'small' ? '25px' : '100px', // Ensure buttons have a minimum width
-// backgroundColor: theme.palette.error.main,
-// borderRadius: theme.shape.borderRadius, // Use theme values for consistent styling
-// // width: '100%', // Button grows to fill the container
-// // minWidth: '100px', // Ensure buttons have a minimum width
-// maxWidth: '100%', // Ensure buttons have a maximum width
-// justifyContent: 'center',
-// alignItems: 'center',
-// display: 'flex',
-// // p: 1,
-// '&:hover': {
-// backgroundColor: theme.palette.error.dark,
-// },
-// }}
-// >
-//
-// {buttonLabel}
-//
-//
-// );
-// };
-
-// export default RemoveButton;
diff --git a/src/zcleanup/SelectCollection.jsx b/src/zcleanup/SelectCollection.jsx
deleted file mode 100644
index f6b68d5..0000000
--- a/src/zcleanup/SelectCollection.jsx
+++ /dev/null
@@ -1,84 +0,0 @@
-// import React, { useState, useCallback } from 'react';
-// import { Box, Card, Grid, Skeleton } from '@mui/material';
-// import { useCollectionStore } from '../../context/MAIN_CONTEXT/CollectionContext/CollectionContext';
-// import { useFormContext, useMode } from '../../context';
-// import SelectCollectionHeader from './sub-components/SelectCollectionHeader';
-// import CollectionDialog from '../../components/dialogs/CollectionDialog';
-// import DashboardLayout from '../Containers/DashBoardLayout';
-// import MDBox from '../REUSABLE_COMPONENTS/MDBOX';
-// import SelectCollectionList from './collectionGrids/collections-list/SelectCollectionList';
-// import CollectionListStats from './collectionGrids/CollectionListStats';
-// import LoadingIndicator from '../../components/reusable/indicators/LoadingIndicator';
-
-// const SelectCollection = () => {
-// const { theme } = useMode();
-// const [isDialogOpen, setDialogOpen] = useState(false);
-// const { currentForm } = useFormContext();
-// const openNewDialog = useCallback((addOrEdit) => {
-// setDialogOpen(true); // Correctly opens the dialog
-// }, []);
-// const handleDialogToggle = () => setDialogOpen(!isDialogOpen);
-// const handleCloseDialog = () => setDialogOpen(false);
-// const { allCollections, selectedCollection } = useCollectionStore();
-
-// return (
-//
-//
-//
-//
-//
-// {' '}
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
-
-// {isDialogOpen && (
-//
-// )}
-//
-//
-// );
-// };
-
-// export default SelectCollection;
diff --git a/src/zcleanup/dataDisplay/CardCountDisplay.jsx b/src/zcleanup/dataDisplay/CardCountDisplay.jsx
deleted file mode 100644
index 7f85461..0000000
--- a/src/zcleanup/dataDisplay/CardCountDisplay.jsx
+++ /dev/null
@@ -1,42 +0,0 @@
-// import React from 'react';
-// import { Grid, Typography } from '@mui/material';
-// import { styled } from '@mui/material/styles';
-// import PropTypes from 'prop-types';
-
-// // Styled components
-// const StyledGrid = styled(Grid)(({ theme }) => ({
-// padding: theme.spacing(1),
-// backgroundColor: theme.palette.backgroundA.lightest,
-// borderRadius: theme.shape.borderRadius,
-// boxShadow: theme.shadows[2],
-// textAlign: 'center',
-// }));
-
-// const CardCountDisplay = ({ quantity, label, className }) => {
-// const totalItems = quantity && quantity.totalItems ? quantity.totalItems : 0;
-
-// return (
-//
-//
-//
-// {label}: {totalItems}
-//
-//
-//
-// );
-// };
-
-// CardCountDisplay.propTypes = {
-// quantity: PropTypes.shape({
-// totalItems: PropTypes.number,
-// }),
-// label: PropTypes.string,
-// className: PropTypes.string,
-// };
-
-// export default CardCountDisplay;
diff --git a/src/zcleanup/dataDisplay/CartTotal.jsx b/src/zcleanup/dataDisplay/CartTotal.jsx
deleted file mode 100644
index 1f65e9e..0000000
--- a/src/zcleanup/dataDisplay/CartTotal.jsx
+++ /dev/null
@@ -1,10 +0,0 @@
-// import React from 'react';
-// import { Typography } from '@mui/material';
-
-// const CartTotal = ({ total }) => (
-//
-// {`Total: $${total}`} {/* Ensure this is a string or number */}
-//
-// );
-
-// export default CartTotal;
diff --git a/src/zcleanup/dataDisplay/StatBox.jsx b/src/zcleanup/dataDisplay/StatBox.jsx
deleted file mode 100644
index 34fa85d..0000000
--- a/src/zcleanup/dataDisplay/StatBox.jsx
+++ /dev/null
@@ -1,43 +0,0 @@
-// import { Box, Typography, useTheme } from '@mui/material';
-// import ProgressCircle from './ProgressCircle';
-// import { tokens } from '../../../assets/tokens';
-
-// const StatBox = ({ title, subtitle, icon, progress, increase }) => {
-// const theme = useTheme();
-// const colors = tokens(theme.palette.mode);
-
-// return (
-//
-//
-//
-// {icon}
-//
-// {title}
-//
-//
-//
-//
-//
-//
-
-//
-//
-// {subtitle}
-//
-//
-// {increase}
-//
-//
-//
-// );
-// };
-
-// export default StatBox;
diff --git a/src/zcleanup/dataDisplay/StatCard.jsx b/src/zcleanup/dataDisplay/StatCard.jsx
deleted file mode 100644
index a2655b1..0000000
--- a/src/zcleanup/dataDisplay/StatCard.jsx
+++ /dev/null
@@ -1,17 +0,0 @@
-// import React from 'react';
-// import { Card, CardContent, Typography } from '@mui/material';
-
-// const StatCard = ({ title, value }) => (
-//
-//
-//
-// {title}
-//
-//
-// {value}
-//
-//
-//
-// );
-
-// export default StatCard;
diff --git a/src/zcleanup/renderFullWidthAddButton.jsx b/src/zcleanup/renderFullWidthAddButton.jsx
deleted file mode 100644
index 2d231aa..0000000
--- a/src/zcleanup/renderFullWidthAddButton.jsx
+++ /dev/null
@@ -1,185 +0,0 @@
-// import React, { useCallback, useEffect, useMemo } from 'react';
-// import { Box } from '@mui/material';
-// import { useMode } from '../../../context';
-// import { getContextIcon } from '../../../components/reusable/icons/index';
-// import AddButton from './AddButton';
-// import RemoveButton from './RemoveButton';
-// import MDTypography from '../../../layout/REUSABLE_COMPONENTS/MDTYPOGRAPHY/MDTypography';
-// import { useCardActions } from '../../../context/hooks/useCardActions';
-// import { useDeckStore } from '../../../context/MAIN_CONTEXT/DeckContext/DeckContext';
-// import { useCartStore } from '../../../context/MAIN_CONTEXT/CartContext/CartContext';
-// import useSelectedCollection from '../../../context/MAIN_CONTEXT/CollectionContext/useSelectedCollection';
-// import useCollectionManager from '../../../context/MAIN_CONTEXT/CollectionContext/useCollectionManager';
-// import { DEFAULT_COLLECTION } from '../../../context/constants';
-
-// // Utility function for deriving label and variant
-// export const renderFullWidthAddButton = (
-// buttonSize,
-// labelValue,
-// context,
-// card,
-// page,
-// onClick,
-// closeModal,
-// onSuccess,
-// onFailure,
-// cardSize
-// ) => {
-// const currentContextIcon = getContextIcon(labelValue);
-// const stackDirection = buttonSize === 'extraSmall' ? 'column' : 'row';
-// const { addOneToCollection, removeOneFromCollection } =
-// useCollectionManager();
-// const { selectedCollection, allCollections, handleSelectCollection } =
-// useSelectedCollection();
-// const {
-// addOneToDeck,
-// removeOneFromDeck,
-// selectedDeck,
-// allDecks,
-// setSelectedDeck,
-// } = useDeckStore();
-// const { addOneToCart, removeOneFromCart, cartData } = useCartStore();
-// useEffect(() => {
-// if (context === 'Deck' && !selectedDeck && allDecks?.length > 0) {
-// console.warn('No deck selected. Defaulting to first deck.');
-// setSelectedDeck(allDecks[0]);
-// }
-// if (
-// (context === 'Collection' && !selectedCollection) ||
-// selectedCollection === null ||
-// selectedCollection === DEFAULT_COLLECTION ||
-// !allCollections?.length > 0
-// ) {
-// console.warn('No collection selected. Defaulting to first collection.');
-// // handleSelectCollection(allCollections[0]);
-// }
-// }, [
-// context,
-// selectedCollection,
-// allCollections,
-// selectedDeck,
-// allDecks,
-// cartData,
-// ]);
-// const addActions = useMemo(() => {
-// Collection: addOneToCollection;
-// Deck: addOneToDeck;
-// Cart: addOneToCart;
-// return addActions;
-// }, [addOneToCollection, addOneToDeck, addOneToCart]);
-// const removeActions = useMemo(() => {
-// Collection: removeOneFromCollection;
-// Deck: removeOneFromDeck;
-// Cart: removeOneFromCart;
-// return removeActions;
-// }, [removeOneFromCollection, removeOneFromDeck, removeOneFromCart]);
-
-// const handleCardActionsAtContext = useCallback(
-// (context, card) => {
-// switch (context) {
-// case 'Collection':
-// handleSelectCollection(card);
-// break;
-// case 'Deck':
-// setSelectedDeck(card);
-// break;
-// case 'Cart':
-// addOneToCart(card);
-// break;
-// default:
-// break;
-// }
-// },
-// [addOneToCart, handleSelectCollection, setSelectedDeck]
-// );
-// const { performAction, count } = useCardActions(
-// context,
-// card,
-// selectedCollection,
-// selectedDeck,
-// addOneToCollection,
-// removeOneFromCollection,
-// addOneToDeck,
-// removeOneFromDeck,
-// addOneToCart,
-// removeOneFromCart,
-// onSuccess,
-// onFailure,
-// page
-// );
-// const handleCardAction = useCallback(
-// async (actionType) => {
-// console.log('SET LOADING FOR ', actionType);
-// console.log('SET LOADING RESPONSE FOR CARD ', card);
-// // onClick?.();
-// performAction(actionType);
-// closeModal?.();
-// try {
-// await new Promise((resolve) => setTimeout(resolve, 500));
-
-// if (actionType === 'add') {
-// console.log(`Adding ${card?.name} to ${labelValue}`);
-
-// onSuccess?.();
-// } else if (actionType === 'remove') {
-// console.log(`Removing ${card?.name} from ${labelValue}`);
-// performAction(actionType);
-
-// onSuccess?.();
-// }
-// } catch (error) {
-// console.error('Action failed:', error);
-// onFailure?.(error);
-// } finally {
-// console.log('SET LOADING RESPONSE FOR CARD ', card);
-// // closeModal();
-// }
-// },
-// [card, labelValue, onSuccess, onFailure, closeModal]
-// );
-
-// return (
-//
-//
-// {currentContextIcon || ''}
-//
-//
-//
-//
-//
-//
-// );
-// };