diff --git a/package.json b/package.json index 188f28cc..4cfcfb6e 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "next": "^13.3.1", "notistack": "^3.0.1", "react": "^18.2.0", + "react-countdown-circle-timer": "^3.2.1", "react-dom": "^18.2.0", "sass": "^1.48.0", "sharp": "^0.32.6" diff --git a/src/components/Elements/Progress/index.tsx b/src/components/Elements/Progress/index.tsx deleted file mode 100644 index 81996ea2..00000000 --- a/src/components/Elements/Progress/index.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { - Box, - LinearProgress, - linearProgressClasses, - styled, - Typography, -} from '@mui/material'; - -import theme from '@/utils/muiTheme'; - -const BorderLinearProgress = styled(LinearProgress)(({ theme }) => ({ - height: 20, - borderRadius: 5, - [`&.${linearProgressClasses.colorPrimary}`]: { - backgroundColor: '#eeeff4', - }, - [`& .${linearProgressClasses.bar}`]: { - borderRadius: 5, - backgroundColor: theme.palette.primary['light'], - }, -})); - -export type Section = { - name: string; - value: number; -}; - -interface ProgressProps { - progress: number; - sections: Section[]; -} - -export const Progress = ({ progress, sections }: ProgressProps) => { - return ( - - - {sections - .filter((s) => s.value > 0) - .map(({ name, value }, index) => ( -
- - 0 ? value : -15}%`} // Adjust to center the text below the divisor - zIndex='2' - > - {`${name}`} - -
- ))} -
- ); -}; diff --git a/src/components/Elements/SaleInfoPanel/index.module.scss b/src/components/Elements/SaleInfoPanel/index.module.scss index 60162965..2f17047d 100644 --- a/src/components/Elements/SaleInfoPanel/index.module.scss +++ b/src/components/Elements/SaleInfoPanel/index.module.scss @@ -2,12 +2,11 @@ display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: auto auto; - gap: 2em; - padding: 1.5em; - border-radius: .5em; - box-shadow: 0 2px 5px 2px rgba(0, 0, 0, 0.2); + grid-column-gap: 0.75rem; + grid-row-gap: 0; + margin-top: 1rem; } .gridItem { - color: #181336 -} \ No newline at end of file + color: #181336; +} diff --git a/src/components/Elements/SaleInfoPanel/index.tsx b/src/components/Elements/SaleInfoPanel/index.tsx index 17495ce3..e625eaa8 100644 --- a/src/components/Elements/SaleInfoPanel/index.tsx +++ b/src/components/Elements/SaleInfoPanel/index.tsx @@ -12,6 +12,7 @@ import { useCoretimeApi } from '@/contexts/apis'; import { SaleInfo, SalePhase } from '@/models'; import { DetailCard } from './DetailCard'; +import styles from './index.module.scss'; interface SaleInfoGridProps { saleInfo: SaleInfo; @@ -43,14 +44,7 @@ export const SaleInfoPanel = ({ }; return ( - + { + const theme = useTheme(); + const router = useRouter(); + + const onManage = () => { + router.push({ + pathname: '/regions', + query: { ...router.query }, + }); + }; + const minuteSeconds = 60; + const hourSeconds = 3600; + const daySeconds = 86400; + + const [remainingTime, setRemainingTime] = useState(0); + const [daysDuration, setDaysDuration] = useState(0); + + useEffect(() => { + let _remainingTime; + if (currentPhase == SalePhase.Interlude) { + _remainingTime = Math.floor( + (endpoints.interlude.end - Date.now()) / 1000 + ); + } else if (currentPhase == SalePhase.Leadin) { + _remainingTime = Math.floor((endpoints.leadin.end - Date.now()) / 1000); + } else if (currentPhase == SalePhase.Regular) { + _remainingTime = Math.floor((endpoints.fixed.end - Date.now()) / 1000); + } else return; + + const days = Math.ceil(_remainingTime / daySeconds); + const _daysDuration = days * daySeconds; + + setDaysDuration(_daysDuration); + setRemainingTime(_remainingTime); + }, [endpoints, currentPhase]); + + const timerProps = { + isPlaying: true, + size: 96, + strokeWidth: 2, + }; + + const renderTime = (dimension: string, time: number) => { + return ( +
+ + {time} + + + {dimension} + +
+ ); + }; + + const getTimeSeconds = (time: number) => (minuteSeconds - time) | 0; + const getTimeMinutes = (time: number) => + ((time % hourSeconds) / minuteSeconds) | 0; + const getTimeHours = (time: number) => + ((time % daySeconds) / hourSeconds) | 0; + const getTimeDays = (time: number) => (time / daySeconds) | 0; + + if (remainingTime <= 0) return <>; + + return ( + + + + Current Phase + + + + + + {currentPhase} + Ends in: + + + {({ elapsedTime, color }) => ( + + {renderTime('days', getTimeDays(daysDuration - elapsedTime))} + + )} + + ({ + shouldRepeat: remainingTime - totalElapsedTime > hourSeconds, + })} + > + {({ elapsedTime, color }) => ( + + {renderTime('hours', getTimeHours(daySeconds - elapsedTime))} + + )} + + ({ + shouldRepeat: remainingTime - totalElapsedTime > minuteSeconds, + })} + > + {({ elapsedTime, color }) => ( + + {renderTime( + 'minutes', + getTimeMinutes(hourSeconds - elapsedTime) + )} + + )} + + ({ + shouldRepeat: remainingTime - totalElapsedTime > 0, + })} + > + {({ elapsedTime, color }) => ( + + {renderTime('seconds', getTimeSeconds(elapsedTime))} + + )} + + + + + ); +}; diff --git a/src/components/Elements/Selectors/NetworkSelector/index.tsx b/src/components/Elements/Selectors/NetworkSelector/index.tsx index 10754192..a8f67e10 100644 --- a/src/components/Elements/Selectors/NetworkSelector/index.tsx +++ b/src/components/Elements/Selectors/NetworkSelector/index.tsx @@ -1,12 +1,4 @@ -import { - Box, - FormControl, - InputLabel, - MenuItem, - Select, - Typography, -} from '@mui/material'; -import { useTheme } from '@mui/material'; +import { Box, FormControl, MenuItem, Select, Typography } from '@mui/material'; import Image from 'next/image'; import { useRouter } from 'next/router'; @@ -30,8 +22,6 @@ const RelaySelect = () => { ); }; - const theme = useTheme(); - const menuItems = [ { value: NetworkType.ROCOCO, @@ -47,12 +37,23 @@ const RelaySelect = () => { return network !== NetworkType.NONE ? ( - Network