| 13 | }; |
| 14 | |
| 15 | function useSteps(path: string) { |
| 16 | const steps: Step[] = [ |
| 17 | { |
| 18 | name: 'Create an account', |
| 19 | status: 'pending', |
| 20 | match: '/onboarding', |
| 21 | }, |
| 22 | { |
| 23 | name: 'Create a project', |
| 24 | status: 'pending', |
| 25 | match: '/onboarding/project', |
| 26 | }, |
| 27 | { |
| 28 | name: 'Connect your data', |
| 29 | status: 'pending', |
| 30 | match: '/onboarding/(.+)/connect', |
| 31 | }, |
| 32 | { |
| 33 | name: 'Verify', |
| 34 | status: 'pending', |
| 35 | match: '/onboarding/(.+)/verify', |
| 36 | }, |
| 37 | ]; |
| 38 | |
| 39 | // @ts-ignore |
| 40 | const matchIndex = steps.findLastIndex((step) => |
| 41 | path.match(new RegExp(step.match)), |
| 42 | ); |
| 43 | |
| 44 | return steps.map((step, index) => { |
| 45 | if (index < matchIndex) { |
| 46 | return { ...step, status: 'completed' }; |
| 47 | } |
| 48 | if (index === matchIndex) { |
| 49 | return { ...step, status: 'current' }; |
| 50 | } |
| 51 | return step; |
| 52 | }); |
| 53 | } |
| 54 | |
| 55 | export const OnboardingSteps = ({ className }: Props) => { |
| 56 | const location = useLocation(); |