PluginProbe ʕ •ᴥ•ʔ
Presto Player / trunk
Presto Player vtrunk
4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / src / admin / dashboard / components / Onboarding / UserInfo.js
presto-player / src / admin / dashboard / components / Onboarding Last commit date
Done.js 1 month ago Integrations.js 1 month ago PremiumFeatures.js 1 month ago UserInfo.js 1 month ago Welcome.js 1 month ago
UserInfo.js
178 lines
1 import { useState } from "react";
2 import {
3 Button,
4 Text,
5 Title,
6 Container,
7 Input,
8 Checkbox,
9 } from "@bsf/force-ui";
10 import { ChevronRight, ChevronLeft } from "lucide-react";
11 import wpApiFetch from "@wordpress/api-fetch";
12 import { toast } from "@bsf/force-ui";
13
14 const { __ } = wp.i18n;
15
16 const UserInfo = ({ goToNextStep, goToPreviousStep, userInfoData = {}, setUserInfoData }) => {
17 const formData = userInfoData;
18 const [isSaving, setIsSaving] = useState(false);
19
20 const updateField = (field, value) => {
21 setUserInfoData((prev) => ({ ...prev, [field]: value }));
22 };
23
24 const handleSubmit = async () => {
25 setIsSaving(true);
26
27 try {
28 await wpApiFetch({
29 path: "/presto-player/v1/onboarding/save-user-info",
30 method: "POST",
31 data: {
32 firstName: formData.firstName,
33 lastName: formData.lastName,
34 email: formData.email,
35 optIn: formData.optIn,
36 },
37 });
38 } catch (error) {
39 toast.error(__("Error!", "presto-player"), {
40 description: __("Failed to save your information. Please try again.", "presto-player"),
41 });
42 setIsSaving(false);
43 return;
44 }
45
46 setIsSaving(false);
47 goToNextStep();
48 };
49
50 const handleSkip = () => {
51 goToNextStep();
52 };
53
54 return (
55 <div>
56 <Container direction="column" gap="lg" className="gap-6">
57 {/* Header */}
58 <Container direction="column" gap="xs">
59 <Title
60 size="lg"
61 tag="h2"
62 title={__("Get the best start", "presto-player")}
63 />
64 <Text size={14} weight={400} color="secondary">
65 {__(
66 "Get helpful updates, new features, and tips to make your website better, while helping us improve Presto Player.",
67 "presto-player"
68 )}
69 </Text>
70 </Container>
71
72 {/* Form Fields */}
73 <div className="grid grid-cols-2 gap-6">
74 {/* First Name */}
75 <div>
76 <Input
77 size="md"
78 label={__("First Name", "presto-player")}
79 placeholder={__("First Name", "presto-player")}
80 value={formData.firstName}
81 onChange={(value) => updateField("firstName", value)}
82 />
83 </div>
84
85 {/* Last Name */}
86 <div>
87 <Input
88 size="md"
89 label={__("Last Name", "presto-player")}
90 placeholder={__("Last Name", "presto-player")}
91 value={formData.lastName}
92 onChange={(value) => updateField("lastName", value)}
93 />
94 </div>
95
96 {/* Email - full width */}
97 <div className="col-span-2">
98 <Input
99 size="md"
100 type="email"
101 label={__("Email", "presto-player")}
102 placeholder={__("Email", "presto-player")}
103 value={formData.email}
104 onChange={(value) => updateField("email", value)}
105 />
106 </div>
107
108 {/* Opt-In Checkbox */}
109 <div className="col-span-2 flex items-start gap-2 [&>div]:mt-[1px]">
110 <Checkbox
111 size="sm"
112 id="optIn"
113 checked={formData.optIn}
114 onChange={(checked) => updateField("optIn", checked)}
115 />
116 <label htmlFor="optIn" className="cursor-pointer">
117 <Text size={14} weight={400} color="secondary">
118 {__(
119 "Get notified about updates, tips and new features. Plus help us improve by sharing how you use the plugin.",
120 "presto-player"
121 )}{" "}
122 <a
123 href="https://prestoplayer.com/share-usage-data/"
124 target="_blank"
125 rel="noopener noreferrer"
126 className="text-text-secondary underline"
127 onClick={(e) => e.stopPropagation()}
128 >
129 {__("Learn more", "presto-player")}
130 </a>
131 </Text>
132 </label>
133 </div>
134 </div>
135
136 {/* Divider */}
137 <hr className="border-t border-solid border-border-subtle border-b-0 m-0 w-full" />
138
139 {/* Footer Buttons */}
140 <Container
141 direction="row"
142 align="center"
143 className="justify-between"
144 >
145 <Button
146 icon={<ChevronLeft />}
147 variant="outline"
148 onClick={goToPreviousStep}
149 >
150 {__("Back", "presto-player")}
151 </Button>
152 <Container direction="row" align="center" gap="sm">
153 <Button
154 className="text-text-tertiary"
155 variant="ghost"
156 onClick={handleSkip}
157 >
158 {__("Skip", "presto-player")}
159 </Button>
160 <Button
161 iconPosition="right"
162 icon={<ChevronRight />}
163 onClick={handleSubmit}
164 disabled={isSaving}
165 >
166 {isSaving
167 ? __("Saving...", "presto-player")
168 : __("Continue", "presto-player")}
169 </Button>
170 </Container>
171 </Container>
172 </Container>
173 </div>
174 );
175 };
176
177 export default UserInfo;
178