Update frontend/src/components/admin/PlanForm.jsx
Browse files
frontend/src/components/admin/PlanForm.jsx
CHANGED
|
@@ -15,6 +15,7 @@ export default function PlanForm({ plan, onSave, onCancel, isLoading }) {
|
|
| 15 |
const [description, setDescription] = useState("");
|
| 16 |
const [maxStudents, setMaxStudents] = useState("1");
|
| 17 |
const [isActive, setIsActive] = useState(true);
|
|
|
|
| 18 |
|
| 19 |
useEffect(() => {
|
| 20 |
if (plan) {
|
|
@@ -24,6 +25,7 @@ export default function PlanForm({ plan, onSave, onCancel, isLoading }) {
|
|
| 24 |
setDescription(plan.description || "");
|
| 25 |
setMaxStudents(String(plan.max_students || 1));
|
| 26 |
setIsActive(plan.is_active ?? true);
|
|
|
|
| 27 |
} else {
|
| 28 |
setName("");
|
| 29 |
setBillingPeriod("monthly");
|
|
@@ -31,6 +33,7 @@ export default function PlanForm({ plan, onSave, onCancel, isLoading }) {
|
|
| 31 |
setDescription("");
|
| 32 |
setMaxStudents("1");
|
| 33 |
setIsActive(true);
|
|
|
|
| 34 |
}
|
| 35 |
}, [plan]);
|
| 36 |
|
|
@@ -46,6 +49,7 @@ export default function PlanForm({ plan, onSave, onCancel, isLoading }) {
|
|
| 46 |
description: description || null,
|
| 47 |
max_students: maxStudentsNumber,
|
| 48 |
is_active: isActive,
|
|
|
|
| 49 |
});
|
| 50 |
}
|
| 51 |
|
|
@@ -133,17 +137,28 @@ export default function PlanForm({ plan, onSave, onCancel, isLoading }) {
|
|
| 133 |
/>
|
| 134 |
</div>
|
| 135 |
|
| 136 |
-
{/* Bottom Row:
|
| 137 |
<div className="flex items-center justify-between pt-1">
|
| 138 |
-
<
|
| 139 |
-
<
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
<div className="flex gap-2">
|
| 148 |
<button
|
| 149 |
type="button"
|
|
|
|
| 15 |
const [description, setDescription] = useState("");
|
| 16 |
const [maxStudents, setMaxStudents] = useState("1");
|
| 17 |
const [isActive, setIsActive] = useState(true);
|
| 18 |
+
const [isDefault, setIsDefault] = useState(false);
|
| 19 |
|
| 20 |
useEffect(() => {
|
| 21 |
if (plan) {
|
|
|
|
| 25 |
setDescription(plan.description || "");
|
| 26 |
setMaxStudents(String(plan.max_students || 1));
|
| 27 |
setIsActive(plan.is_active ?? true);
|
| 28 |
+
setIsDefault(plan.is_default ?? false);
|
| 29 |
} else {
|
| 30 |
setName("");
|
| 31 |
setBillingPeriod("monthly");
|
|
|
|
| 33 |
setDescription("");
|
| 34 |
setMaxStudents("1");
|
| 35 |
setIsActive(true);
|
| 36 |
+
setIsDefault(false);
|
| 37 |
}
|
| 38 |
}, [plan]);
|
| 39 |
|
|
|
|
| 49 |
description: description || null,
|
| 50 |
max_students: maxStudentsNumber,
|
| 51 |
is_active: isActive,
|
| 52 |
+
is_default: isDefault,
|
| 53 |
});
|
| 54 |
}
|
| 55 |
|
|
|
|
| 137 |
/>
|
| 138 |
</div>
|
| 139 |
|
| 140 |
+
{/* Bottom Row: Checkboxes and Buttons */}
|
| 141 |
<div className="flex items-center justify-between pt-1">
|
| 142 |
+
<div className="flex flex-col gap-2">
|
| 143 |
+
<label className="inline-flex items-center gap-2 text-xs text-stone-700">
|
| 144 |
+
<input
|
| 145 |
+
type="checkbox"
|
| 146 |
+
className="rounded border-stone-300"
|
| 147 |
+
checked={isActive}
|
| 148 |
+
onChange={(e) => setIsActive(e.target.checked)}
|
| 149 |
+
/>
|
| 150 |
+
Active / visible to students
|
| 151 |
+
</label>
|
| 152 |
+
<label className="inline-flex items-center gap-2 text-xs text-stone-700">
|
| 153 |
+
<input
|
| 154 |
+
type="checkbox"
|
| 155 |
+
className="rounded border-stone-300"
|
| 156 |
+
checked={isDefault}
|
| 157 |
+
onChange={(e) => setIsDefault(e.target.checked)}
|
| 158 |
+
/>
|
| 159 |
+
Default membership plan (max 2)
|
| 160 |
+
</label>
|
| 161 |
+
</div>
|
| 162 |
<div className="flex gap-2">
|
| 163 |
<button
|
| 164 |
type="button"
|