Skip to content

Commit bdcbb30

Browse files
authored
Slider Update
Signed-off-by: Naman Verma <149177973+Namanv0509@users.noreply.github.com>
1 parent 77b2471 commit bdcbb30

1 file changed

Lines changed: 100 additions & 21 deletions

File tree

src/components/PricingAddons/index.js

Lines changed: 100 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ import {
2828
import AcademyIcon from "./AcademyIcon";
2929
import { useStyledDarkMode } from "../../theme/app/useStyledDarkMode";
3030

31+
const learnerOptions = [
32+
{ learners: 0, monthlyPerUser: 0 },
33+
{ learners: 50, monthlyPerUser: 1.73 },
34+
{ learners: 150, monthlyPerUser: 1.73 },
35+
{ learners: 250, monthlyPerUser: 1.38 },
36+
{ learners: 500, monthlyPerUser: 0.87 },
37+
{ learners: 1000, monthlyPerUser: 0.59 },
38+
];
39+
3140
const addOns = [
3241
{
3342
id: "academy",
@@ -214,35 +223,105 @@ export const PricingAddons = ({ isYearly = false }) => {
214223
{/* Quantity Slider */}
215224
<Box>
216225
<Box sx={{ display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2 }}>
217-
<Typography variant="h6" fontWeight="600" sx={{ fontSize: "1.1rem" }}>
218-
Quantity: {quantity} {selectedAddon.unitLabel}
226+
<Typography variant="h6" fontWeight="600">
227+
Quantity:{" "}
228+
{selectedAddon.id === "academy"
229+
? selectedAddon.learnerOptions[quantityIndex].learners === 1001
230+
? "1,000+"
231+
: selectedAddon.learnerOptions[quantityIndex].learners
232+
: quantityIndex}{" "}
233+
{selectedAddon.unitLabel}
219234
</Typography>
220235
<Chip
221-
label={formatPrice((isYearly ? selectedAddon.yearlyPrice : selectedAddon.basePrice) * quantity)}
236+
label={formatPrice(totalPrice)}
222237
color="primary"
223238
variant="outlined"
224-
sx={{ fontWeight: "bold", fontSize: "0.9rem" }}
239+
sx={{
240+
fontWeight: "bold",
241+
fontSize: "0.9rem",
242+
transition: "all 0.3s ease-in-out",
243+
}}
225244
/>
226245
</Box>
227246

228247
<Box sx={{ px: 1 }}>
229-
<Slider
230-
value={quantity}
231-
onChange={handleQuantityChange}
232-
min={1}
233-
max={selectedAddon.maxUnits}
234-
step={1}
235-
valueLabelDisplay="auto"
236-
sx={{ mb: 2 }}
237-
/>
238-
<Box sx={{ display: "flex", justifyContent: "space-between" }}>
239-
<Typography variant="body2" color="text.secondary">
240-
1
241-
</Typography>
242-
<Typography variant="body2" color="text.secondary">
243-
{selectedAddon.maxUnits}
244-
</Typography>
245-
</Box>
248+
{selectedAddon.id === "academy" ? (
249+
<Slider
250+
value={quantityIndex}
251+
onChange={handleQuantityChange}
252+
min={0}
253+
max={selectedAddon.learnerOptions.length - 1}
254+
step={null}
255+
marks={selectedAddon.learnerOptions.map((option, index) => ({
256+
value: index,
257+
}))}
258+
valueLabelDisplay="auto"
259+
valueLabelFormat={(value) => {
260+
const option = selectedAddon.learnerOptions[value];
261+
const learners = option.learners === 1001 ? 1001 : option.learners;
262+
const basePrice = learners === 0 ? option.monthlyPerUser : learners * option.monthlyPerUser;
263+
const price = labLearners ? basePrice * 2 : basePrice;
264+
return `${option.learners === 1001 ? "1,000+" : option.learners} (${formatPrice(price)})`;
265+
}}
266+
sx={{
267+
color: "primary.main",
268+
"& .MuiSlider-markLabel": {
269+
color: "text.primary",
270+
},
271+
"& .MuiSlider-thumb": {
272+
width: 20,
273+
height: 20,
274+
"&:hover, &.Mui-focusVisible": {
275+
boxShadow: "0 0 0 8px rgba(0, 179, 159, 0.16)",
276+
},
277+
},
278+
"& .MuiSlider-rail": {
279+
opacity: 0.3,
280+
},
281+
"& .MuiSlider-track": {
282+
border: "none",
283+
},
284+
}}
285+
aria-label="Number of theory learners for Academy add-on"
286+
/>
287+
) : (
288+
<Slider
289+
value={quantityIndex}
290+
onChange={handleQuantityChange}
291+
min={1}
292+
max={selectedAddon.maxUnits}
293+
step={1}
294+
valueLabelDisplay="auto"
295+
valueLabelFormat={(value) => `${value} (${formatPrice(selectedAddon.basePrice * value)})`}
296+
sx={{
297+
color: "primary.main",
298+
"& .MuiSlider-thumb": {
299+
width: 20,
300+
height: 20,
301+
"&:hover, &.Mui-focusVisible": {
302+
boxShadow: "0 0 0 8px rgba(0, 179, 159, 0.16)",
303+
},
304+
},
305+
"& .MuiSlider-rail": {
306+
opacity: 0.3,
307+
},
308+
"& .MuiSlider-track": {
309+
border: "none",
310+
},
311+
mb: 2,
312+
}}
313+
/>
314+
)}
315+
{selectedAddon.id !== "academy" && (
316+
<Box sx={{ display: "flex", justifyContent: "space-between" }}>
317+
<Typography variant="body2" color="text.secondary">
318+
1
319+
</Typography>
320+
<Typography variant="body2" color="text.secondary">
321+
{selectedAddon.maxUnits}
322+
</Typography>
323+
</Box>
324+
)}
246325
</Box>
247326
</Box>
248327

0 commit comments

Comments
 (0)