This should work
import {
reactExtension,
Checkbox,
Link,
useExtensionCapability,
useBuyerJourneyIntercept,
useApplyAttributeChange
} from “@shopify/ui-extensions-react/checkout”;
import React, { useState } from “react”;
// Set the entry point for the extension
export default reactExtension(“purchase.checkout.payment-method-list.render-after”, () => );
function App() {
// Set up the app state
const [isChecked, setIsChecked] = useState(false);
const [validationError, setValidationError] = useState(“”);
const canBlockProgress = useExtensionCapability(“block_progress”);
const applyAttributeChange =
useApplyAttributeChange();
const handleCheckboxChange = () => {
setIsChecked(!isChecked);
applyAttributeChange({
key: ‘requestedFreeGift’,
type: ‘updateAttribute’,
value: isChecked ? true : false,
});
setValidationError(“”);
};
useBuyerJourneyIntercept(({ canBlockProgress }) => {
if (canBlockProgress && !isChecked) {
return {
behavior: “block”,
reason: “Please indicate that you accept the Terms and Conditions”,
perform: (result) => {
if (result.behavior === “block”) {
setValidationError(“Please indicate that you accept the Terms and Conditions”);
}
},
};
}
return {
behavior: “allow”,
perform: () => {
clearValidationErrors();
},
};
});
function clearValidationErrors() {
setValidationError(“”);
}
return (
I agree Terms and Conditions.
);
}
Note: In shopify.extension.toml file set
[extensions.capabilities]
block_progress = true