Skip to content

Commit

Permalink
fix color select issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lesdyman committed Aug 5, 2024
1 parent 5b78c4c commit 63b000a
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions src/Pages/BaseLayout/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,6 @@ export const BaseLayout = () => {
getProduct();
}, [location, getProduct]);

const activeColor = () => {
const currentColor = location.pathname.split('-');
return currentColor
.filter(
(_el, index) => index === currentColor.length - 1
|| index === currentColor.length - 2,
)
.join(' ');
};

const activeCapacity = () => {
const currentCapacity = location.pathname.split('-');

Expand All @@ -118,18 +108,6 @@ export const BaseLayout = () => {
window.location.href = '#/phones';
};

// const redirectByColor = (color: string) => {
// const pathSegments = location.pathname.split('/');
// if (gadget?.color) {
// pathSegments[pathSegments.length - 1] = pathSegments[
// pathSegments.length - 1
// ].replace(gadget.color, color);
// const newPath = pathSegments.join('/');
// navigate(newPath);
// window.location.reload();
// }
// };

const redirectByColor = (color: string) => {
navigate(
`${gadget?.namespaceId}-${gadget?.capacity.toLowerCase()}-${color.replace(' ', '-')}`,
Expand Down Expand Up @@ -187,7 +165,7 @@ export const BaseLayout = () => {
<div className="colors">
{gadget?.colorsAvailable.map((color) => (
<div
className={`color ${color.replace(' ', '')} ${activeColor().includes(` ${color}`) ? 'activeColor' : ''}`}
className={`color ${color.replace(' ', '')} ${color === gadget.color ? 'activeColor' : ''}`}
key={color}
onClick={() => redirectByColor(color)}
style={{ cursor: 'pointer' }}
Expand Down

0 comments on commit 63b000a

Please sign in to comment.