|
1
|
import React from "react" |
|
2
|
import { useLearningPath } from "../../../../providers/LearningPath" |
|
3
|
import { Button } from "docs-ui" |
|
4
|
import { ArrowDownLeftMini, ArrowDownMini } from "@medusajs/icons" |
|
5
|
|
|
6
|
type LearningPathStepActionsType = { |
|
7
|
onFinish?: () => void |
|
8
|
onClose?: () => void |
|
9
|
setCollapsed: React.Dispatch<React.SetStateAction<boolean>> |
|
10
|
} & React.AllHTMLAttributes<HTMLDivElement> |
|
11
|
|
|
12
|
export const LearningPathStepActions = ({ |
|
13
|
onFinish, |
|
14
|
onClose, |
|
15
|
setCollapsed, |
|
16
|
}: LearningPathStepActionsType) => { |
|
17
|
const { hasNextStep, nextStep, endPath } = useLearningPath() |
|
18
|
|
|
19
|
const handleFinish = () => { |
|
20
|
if (onFinish) { |
|
21
|
onFinish() |
|
22
|
} else { |
|
23
|
endPath() |
|
24
|
} |
|
25
|
} |
|
26
|
|
|
27
|
return ( |
|
28
|
<div className="flex p-docs_1 justify-between items-center"> |
|
29
|
<div> |
|
30
|
<Button |
|
31
|
onClick={() => setCollapsed(true)} |
|
32
|
variant="secondary" |
|
33
|
className="!text-medusa-fg-subtle !p-[6px]" |
|
34
|
> |
|
35
|
<ArrowDownLeftMini className="flip-y hidden md:inline" /> |
|
36
|
<ArrowDownMini className="inline md:hidden" /> |
|
37
|
</Button> |
|
38
|
</div> |
|
39
|
<div className="flex gap-docs_0.5 items-center"> |
|
40
|
{hasNextStep() && ( |
|
41
|
<> |
|
42
|
<Button onClick={onClose} variant="secondary"> |
|
43
|
Close |
|
44
|
</Button> |
|
45
|
<Button onClick={nextStep} variant="primary"> |
|
46
|
Next |
|
47
|
</Button> |
|
48
|
</> |
|
49
|
)} |
|
50
|
{!hasNextStep() && ( |
|
51
|
<Button onClick={handleFinish} variant="primary"> |
|
52
|
Finish |
|
53
|
</Button> |
|
54
|
)} |
|
55
|
</div> |
|
56
|
</div> |
|
57
|
) |
|
58
|
} |