Fix ConfirmationButton usage in pricing page and e2e tests
- Update pricing page to use ConfirmationButton API correctly (isConfirming, onConfirm, onCancel, onActionClick) - Fix e2e tests to set up response listeners before navigation - Fix validation error selector to use .first() for multiple matches - All 9 e2e tests now passing
This commit is contained in:
parent
1874c3a057
commit
1ef5ebe493
2 changed files with 64 additions and 38 deletions
|
|
@ -49,6 +49,7 @@ export default function AdminPricingPage() {
|
|||
const [errors, setErrors] = useState<ValidationErrors>({});
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [success, setSuccess] = useState(false);
|
||||
const [isConfirming, setIsConfirming] = useState(false);
|
||||
|
||||
const fetchConfig = useCallback(async () => {
|
||||
setError(null);
|
||||
|
|
@ -180,12 +181,16 @@ export default function AdminPricingPage() {
|
|||
},
|
||||
});
|
||||
|
||||
const handleSave = () => {
|
||||
if (!formData) return;
|
||||
const handleConfirmSave = () => {
|
||||
if (!formData) {
|
||||
setIsConfirming(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const validationErrors = validateForm(formData);
|
||||
if (Object.keys(validationErrors).length > 0) {
|
||||
setErrors(validationErrors);
|
||||
setIsConfirming(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -199,6 +204,7 @@ export default function AdminPricingPage() {
|
|||
eur_min_sell: formData.eur_min_sell,
|
||||
eur_max_sell: formData.eur_max_sell,
|
||||
});
|
||||
setIsConfirming(false);
|
||||
};
|
||||
|
||||
if (isLoading || !formData) {
|
||||
|
|
@ -385,16 +391,19 @@ export default function AdminPricingPage() {
|
|||
|
||||
<div style={formStyles.actions}>
|
||||
<ConfirmationButton
|
||||
onClick={handleSave}
|
||||
disabled={hasErrors || isSaving}
|
||||
confirmMessage={t("pricing.confirmSave")}
|
||||
style={{
|
||||
isConfirming={isConfirming}
|
||||
onConfirm={handleConfirmSave}
|
||||
onCancel={() => setIsConfirming(false)}
|
||||
onActionClick={() => setIsConfirming(true)}
|
||||
actionLabel={isSaving ? tCommon("saving") : t("pricing.save")}
|
||||
confirmLabel={tCommon("confirm")}
|
||||
cancelLabel={tCommon("cancel")}
|
||||
isLoading={isSaving}
|
||||
actionButtonStyle={{
|
||||
...buttonStyles.primary,
|
||||
...(hasErrors || isSaving ? buttonStyles.disabled : {}),
|
||||
}}
|
||||
>
|
||||
{isSaving ? tCommon("saving") : t("pricing.save")}
|
||||
</ConfirmationButton>
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue