Skip to content

Commit

Permalink
attempting to updated collectionStats object for selector so that it …
Browse files Browse the repository at this point in the history
…sets marker on chart
  • Loading branch information
reedoooo committed Apr 27, 2024
1 parent 18900b5 commit 63db60b
Show file tree
Hide file tree
Showing 31 changed files with 841 additions and 643 deletions.
13 changes: 13 additions & 0 deletions src/assets/themes/base/customColorPalettes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ const greenAccent = {
contrastText: '#dbf5ee', // Most contrasting or lightest, could be adjusted
secondary: '#5CDB95',
};
// const greenPalette = {
// 50: '#b7ebde', // Even lighter than the lightest
// 100: '#94e2cd', // Lightest shade
// 200: '#70d8bd', // Lighter shade
// 300: '#4cceac', // Light shade, also 'crystalGreen' with opacity adjusted for full hex
// 400: '#3da58a', // Default, mid-light
// 500: '#18b984', // Main green used in the primary color
// 600: '#159b76', // Slightly darker and less saturated than 500
// 700: '#12875f', // Darker and more muted green
// 800: '#0f7348', // Dark, rich green
// 900: '#2e7c67' // Darkest shade, used for the deepest contrast
// };

// const primaryPalette = {
// main: '#18b984', // Greenish shade vibrant and suitable for primary buttons and icons
// light: '#4cceac', // Lighter green for backgrounds or less emphasized components
Expand Down
8 changes: 3 additions & 5 deletions src/components/cards/GenericCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { usePopover } from '../../context/hooks/usePopover';
import GenericActionButtons from '../../layout/REUSABLE_COMPONENTS/GenericActionButtons';
import useDialogState from '../../context/hooks/useDialogState';
import useManager from '../../context/useManager';
import { useCompileCardData } from '../../context/MISC_CONTEXT/AppContext/useCompileCardData';
const getQuantity = ({
card,
cart,
Expand Down Expand Up @@ -60,13 +59,12 @@ const GenericCard = React.forwardRef((props, ref) => {
selectedDeck,
selectedCollection,
cart,
checkForCardInContext,
} = useManager();
const { setContext, setIsContextSelected } = useSelectedContext();
const { isCardInContext } = useCompileCardData();
const { dialogState, openDialog } = useDialogState();
const { setHoveredCard, setIsPopoverOpen, hoveredCard } = usePopover();
const { enqueueSnackbar } = useSnackbar(); // Assuming useOverlay has enqueueSnackbar method
const { card, context, page, quantityIndex, isDeckCard } = props;
const { card, context, page, isDeckCard } = props;

const effectiveContext =
typeof context === 'object' ? context.pageContext : context;
Expand Down Expand Up @@ -106,7 +104,7 @@ const GenericCard = React.forwardRef((props, ref) => {
useEffect(() => {
setIsPopoverOpen(hoveredCard === card);
}, [hoveredCard, card, setIsPopoverOpen]);
const isInContext = isCardInContext(card);
const isInContext = checkForCardInContext(card);
const name = card?.name;
const imgUrl = card?.card_images?.[0]?.image_url || placeholder;
const price = `Price: ${
Expand Down
3 changes: 3 additions & 0 deletions src/components/forms/Factory/RCDynamicForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const RCDynamicForm = ({
userInterfaceOptions = {},
initialData,
updatedData,
additonalData,
}) => {
if (!inputs || typeof inputs !== 'object') {
console.error('Invalid inputs provided to RCDynamicForm:', inputs);
Expand Down Expand Up @@ -86,6 +87,8 @@ const RCDynamicForm = ({
label={fieldConfig.label}
placeholder={fieldConfig.placeholder}
error={!!error}
name={fieldConfig.name}
context={fieldConfig.context}
// helperText={error ? <RCFieldError name={fieldName} /> : null}
initialValue={fieldConfig.initialValue}
helperText={error ? error.message : null}
Expand Down
35 changes: 20 additions & 15 deletions src/components/forms/Factory/RCInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import RCSwitch from './RCSwitch';
import useBreakpoint from '../../../context/hooks/useBreakPoint';
import { nanoid } from 'nanoid';
import useManager from '../../../context/useManager';
import useSelectorActions from '../../../context/hooks/useSelectorActions';
const RCInput = forwardRef(
(
{
Expand All @@ -45,18 +46,19 @@ const RCInput = forwardRef(
const { isMobile } = useBreakpoint();
const { updateEntityField, selectedCollection, selectedCollectionId } =
useManager();
const handleSelectChange = (event) => {
const selectedValue = event.target.value;
onChange(selectedValue); // Update local form state
if (type === 'select') {
updateEntityField(
'collections',
selectedCollectionId,
'selectedChartDataKey',
selectedValue
);
}
};
const { handleSelectChange } = useSelectorActions();
// const handleSelectChange = (event) => {
// const selectedValue = event.target.value;
// // onChange(selectedValue); // Update local form state
// if (type === 'select') {
// updateEntityField(
// 'collections',
// selectedCollectionId,
// 'selectedChartDataKey',
// selectedValue
// );
// }
// };
const [inputValue, setInputValue] = useState('');
const handleKeyDown = (event) => {
if (event.key === 'Enter' && inputValue.trim()) {
Expand Down Expand Up @@ -106,7 +108,10 @@ const RCInput = forwardRef(
labelId={`${rest?.name}-select-label`}
id={`${rest?.name}-select`}
value={value || ''}
onChange={handleSelectChange}
onChange={(e) => {
onChange(e.target.value);
handleSelectChange(e, rest.name, rest.context);
}}
// onChange={(e) => {
// console.log(e.target.value);
// console.log(
Expand Down Expand Up @@ -142,8 +147,8 @@ const RCInput = forwardRef(
},
}}
>
{options?.map((option) => (
<MenuItem key={option.value} value={option.value}>
{options?.map((option, index) => (
<MenuItem key={`${option.value}-${index}`} value={option.value}>
{option.label}
</MenuItem>
))}
Expand Down
23 changes: 16 additions & 7 deletions src/components/forms/formsConfig.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { z } from 'zod';
import useAuthManager from '../../context/MAIN_CONTEXT/AuthContext/useAuthManager';
import { useCardStoreHook } from '../../context/MAIN_CONTEXT/CardContext/useCardStore';
import useManager from '../../context/useManager';
import { useCompileCardData } from '../../context/MISC_CONTEXT/AppContext/useCompileCardData';
import useSelectorActions from '../../context/hooks/useSelectorActions';
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------- FORM KEYS -----------------------------------
Expand Down Expand Up @@ -71,8 +71,7 @@ const formFieldKeys = {
const getFormFieldHandlers = () => {
const { signup, login } = useAuthManager();
const { handleRequest } = useCardStoreHook();
const { setSelectedTimeRange, setSelectedStat, setSelectedTheme } =
useCompileCardData();
const { setTime, setStat, setTheme } = useSelectorActions();
const {
addCollection,
updateCollection,
Expand All @@ -99,7 +98,7 @@ const getFormFieldHandlers = () => {
},
updateCollectionForm: (formData, additionalData) => {
console.log('Update Collection Form Data:', formData, additionalData);
updateCollection(formData, additionalData);
updateCollection(formData);
},
updateDeckForm: (formData) => {
console.log('Update Deck Form Data:', formData);
Expand All @@ -122,17 +121,17 @@ const getFormFieldHandlers = () => {
},
statRangeForm: (formData) => {
console.log('Stat Range Form Data:', formData);
setSelectedStat(formData);
setStat(formData);
// setSearchSettings(formData, additionalData);
},
themeRangeForm: (formData) => {
console.log('Theme Range Form Data:', formData);
setSelectedTheme(formData);
setTheme(formData);
// setSearchSettings(formData, additionalData);
},
timeRangeForm: (formData) => {
console.log('Time Range Selector Form Data:', formData);
setSelectedTimeRange(formData);
setTime(formData);
},
searchSettingsForm: (formData, additionalData) => {
console.log(
Expand Down Expand Up @@ -227,6 +226,7 @@ const signupFormFields = {
const authFormFields = signupFormFields;
const addDeckFormFields = {
name: {
context: 'Deck',
label: 'Name',
type: 'text',
placeHolder: 'Enter deck name',
Expand All @@ -239,6 +239,7 @@ const addDeckFormFields = {
required: true,
},
description: {
context: 'Deck',
label: 'Description',
type: 'text',
placeHolder: 'Enter deck description',
Expand All @@ -258,6 +259,7 @@ const addDeckFormFields = {
const updateDeckFormFields = {
...addDeckFormFields,
tags: {
context: 'Deck',
label: 'Tags',
type: 'chips',
placeholder: 'Enter a tag',
Expand All @@ -269,6 +271,7 @@ const updateDeckFormFields = {
required: false, // Adjust based on whether tags are actually required or not
},
color: {
context: 'Deck',
label: 'Color',
type: 'select',
defaultValue: 'blue',
Expand All @@ -293,6 +296,8 @@ const updateDeckFormFields = {
const deckFormFields = updateDeckFormFields;
const collectionFormFields = {
name: {
context: 'Collection',

label: 'Name',
type: 'text',
placeHolder: 'Enter collection name',
Expand All @@ -304,6 +309,7 @@ const collectionFormFields = {
required: true,
},
description: {
context: 'Collection',
label: 'Description',
type: 'text',
placeHolder: 'Enter collection description',
Expand Down Expand Up @@ -354,6 +360,7 @@ const collectionSearchFormFields = {
};
const statRangeFormFields = {
statRange: {
context: 'Collection',
name: 'statRange',
label: 'Statistics Range',
type: 'select',
Expand All @@ -378,6 +385,7 @@ const statRangeFormFields = {
};
const timeRangeFormFields = {
timeRange: {
context: 'Collection',
name: 'timeRange',
label: 'Time Range',
type: 'select',
Expand All @@ -401,6 +409,7 @@ const timeRangeFormFields = {
};
const themeRangeFormFields = {
themeRange: {
context: 'Collection',
name: 'themeRange',
label: 'Theme Range',
type: 'select',
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/hooks/useFormSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { useState, useCallback } from 'react';

const useFormSelect = (initialValues, formKey) => {
const useFormSelect = (initialValues) => {
const [selectedValues, setSelectedValues] = useState(initialValues);

const handleChange = useCallback(
Expand Down
63 changes: 35 additions & 28 deletions src/context/Helpers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,39 @@ export const formatDateBasedOnRange = (range) => {

return formatMap[range] || formatMap.default;
};
export const createMarkers = (selected) => {
if (!selected || !selected.collectionStatistics) return [];
// export const createMarkers = (selected) => {
// if (!selected || !selected.collectionStatistics) return [];

const { highPoint, lowPoint, avgPrice, percentageChange } =
selected.collectionStatistics;
return [
{
axis: 'y',
value: percentageChange,
lineStyle: { stroke: '#b0413e', strokeWidth: 2 },
legend: `${selected.name} High`,
legendOrientation: 'vertical',
},
{
axis: 'y',
value: lowPoint,
lineStyle: { stroke: '#b0413e', strokeWidth: 2 },
legend: `${selected.name} Low`,
legendOrientation: 'vertical',
},
{
axis: 'y',
value: avgPrice,
lineStyle: { stroke: '#b0413e', strokeWidth: 2 },
legend: `${selected.name} Avg`,
legendOrientation: 'vertical',
},
];
};
// // const { highPoint, lowPoint, avgPrice, percentageChange } =
// // selected.collectionStatistics;
// selected?.collectionStatistics
// .get(selected.selectedChartDataKey)
// .data.get(selected.selectedStat);

// return [
// {
// key: 'percentageChange',
// axis: 'y',
// value: percentageChange,
// lineStyle: { stroke: '#b0413e', strokeWidth: 2 },
// legend: `${selected.name} High`,
// legendOrientation: 'vertical',
// },
// {
// kay: 'lowPoint',
// axis: 'y',
// value: lowPoint,
// lineStyle: { stroke: '#b0413e', strokeWidth: 2 },
// legend: `${selected.name} Low`,
// legendOrientation: 'vertical',
// },
// {
// key: 'avgPrice',
// axis: 'y',
// value: avgPrice,
// lineStyle: { stroke: '#b0413e', strokeWidth: 2 },
// legend: `${selected.name} Avg`,
// legendOrientation: 'vertical',
// },
// ];
// };
Loading

0 comments on commit 63db60b

Please sign in to comment.