Skip to content

Commit

Permalink
show turnstile error as well
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikskog committed Sep 5, 2024
1 parent 98e294a commit 8a7d985
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/events/components/Attendance/AttendButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ const FAILED_CAPTCHA_ERROR_TEXT = (
<li>Last inn siden på nytt og prøv igjen.</li>
<li>Prøv en annen nettleser. Vi vet at det har vært problemer med Firefox.</li>
<li>
Hvis du fortsatt får feil, så send en e-post til [email protected] så vi melder deg på manuelt. Vi setter
pris på om du kan oppgi hvilken nettleser og operativsystem du bruker for å kunne skjønne bedre hva som går
galt.
Hvis du fortsatt får feil, så send en e-post til [email protected] så vi melder deg på manuelt. Vi setter pris på om du

Check failure on line 27 in src/events/components/Attendance/AttendButton.tsx

View workflow job for this annotation

GitHub Actions / ESLint

src/events/components/Attendance/AttendButton.tsx#L27

Replace `·pris·på·om·du⏎········kan·oppgi·eventuell·feilmelding·og·hvilken·nettleser·og·operativsystem·du·bruker·for·å·kunne` with `⏎········pris·på·om·du·kan·oppgi·eventuell·feilmelding·og·hvilken·nettleser·og·operativsystem·du·bruker·for·å·kunne⏎·······` (prettier/prettier)
kan oppgi eventuell feilmelding og hvilken nettleser og operativsystem du bruker for å kunne skjønne bedre hva som går galt.
</li>
</ul>
</>
Expand Down
3 changes: 3 additions & 0 deletions src/events/components/Attendance/CaptchaModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface ICaptchaModalProps {
const CaptchaModal: FC<ICaptchaModalProps> = (props: ICaptchaModalProps) => {
const { showModal, toggleModal, setCaptcha, header, text, errorText } = props;
const [showErrorText, setShowErrorText] = useState(true);
const [turnstileError, setTurnstileError] = useState<string | null>(null);

const validCaptcha = (token: string | null) => {
if (token) {
Expand All @@ -27,6 +28,7 @@ const CaptchaModal: FC<ICaptchaModalProps> = (props: ICaptchaModalProps) => {
const onError = (error: Error) => {
console.log('Error from captcha failure:', error);
setShowErrorText(true);
setTurnstileError(error.message);
};

if (!showModal) return null;
Expand All @@ -36,6 +38,7 @@ const CaptchaModal: FC<ICaptchaModalProps> = (props: ICaptchaModalProps) => {
<h1>{header}</h1>
<p>{text}</p>
{showErrorText && <p>{errorText}</p>}
{turnstileError && <p>Error message: {turnstileError}</p>}
<Turnstile sitekey={OW4_TURNSTILE_PUBLIC_KEY} onVerify={validCaptcha} onError={onError} />
</Modal>
);
Expand Down

0 comments on commit 8a7d985

Please sign in to comment.