-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathindex.jsx
More file actions
79 lines (70 loc) · 2.61 KB
/
index.jsx
File metadata and controls
79 lines (70 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright (c) 2025, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import React from 'react'
import {useTheme} from '@chakra-ui/react'
import PropTypes from 'prop-types'
import {useIntl} from 'react-intl'
import StatusBar from '@salesforce/retail-react-app/app/components/order-status-bar/status-bar'
const steps = ['Ordered', 'Dispatched', 'Out for delivery', 'Delivered']
const OrderStatusBar = ({currentStepLabel}) => {
const theme = useTheme()
const intl = useIntl()
const getLocalizedMessage = (status) => {
switch (status) {
case 'Ordered':
return intl.formatMessage({id: 'status_bar.ordered', defaultMessage: 'Ordered'})
case 'Dispatched':
return intl.formatMessage({
id: 'status_bar.dispatched',
defaultMessage: 'Dispatched'
})
case 'Out for delivery':
return intl.formatMessage({
id: 'status_bar.out_for_delivery',
defaultMessage: 'Out for delivery'
})
case 'Delivered':
return intl.formatMessage({id: 'status_bar.delivered', defaultMessage: 'Delivered'})
default:
return status
}
}
// Convert steps to the format expected by StatusBar component
const statusBarSteps = steps.map((step) => ({
label: getLocalizedMessage(step),
status: step,
description: `Order status: ${getLocalizedMessage(step)}`
}))
// Find current step index
let currentStep = steps.findIndex((step) => step === currentStepLabel)
if (currentStep === -1) currentStep = 0
// Define colors using theme
const colors = {
completed: theme.colors.teal[100], // completed steps
current: theme.colors.blue[900], // current step
future: theme.colors.gray[200], // future steps
completedText: theme.colors.black[600], // completed steps text
currentText: 'white', // current step text
futureText: theme.colors.black[600] // future steps text
}
return (
<StatusBar
steps={statusBarSteps}
currentStep={currentStep}
colors={colors}
ariaLabel="Order Status Steps"
width={1080}
height={50}
chevronWidth={24}
radius={25}
/>
)
}
OrderStatusBar.propTypes = {
currentStepLabel: PropTypes.string
}
export default OrderStatusBar