Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const ErrorWrapper = styled.div`
color: ${Colour["text-error"]};
outline: none;
${Font["body-sm-semibold"]}
display: flex;
gap: ${Spacing["spacing-4"]};
align-items: center;
`;

export const TryAgain = styled.button`
Expand Down
30 changes: 21 additions & 9 deletions src/components/fields/e-signature-field/e-signature-field.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Form } from "@lifesg/react-design-system/form";
import { ExclamationCircleFillIcon } from "@lifesg/react-icons/exclamation-circle-fill";
import { CanceledError } from "axios";
import isEmpty from "lodash/isEmpty";
import { useEffect, useRef, useState } from "react";
Expand Down Expand Up @@ -191,10 +192,13 @@ export const ESignatureField = (props: IGenericFieldProps<IESignatureFieldSchema
if (uploadErrorCount > 0) {
return (
<ErrorWrapper>
{uploadRuleRef.current?.errorMessage || ERROR_MESSAGES.ESIGNATURE.UPLOAD}
<TryAgain type="button" onClick={() => handleChange(signatureDataURL)}>
Please try again.
</TryAgain>
<ExclamationCircleFillIcon />
<span>
{uploadRuleRef.current?.errorMessage || ERROR_MESSAGES.ESIGNATURE.UPLOAD}
<TryAgain type="button" onClick={() => handleChange(signatureDataURL)}>
Please try again.
</TryAgain>
</span>
{uploadErrorCount >= 3 && (
<RefreshAlert type="warning" data-testid="upload-refresh-alert">
Refresh this page if you cannot upload your signature.
Expand All @@ -207,10 +211,13 @@ export const ESignatureField = (props: IGenericFieldProps<IESignatureFieldSchema
if (loadErrorCount > 0 && hasValue(value)) {
return (
<ErrorWrapper>
Failed to load.
<TryAgain type="button" onClick={() => loadImage(value.fileId, value.fileUrl)}>
Please try again.
</TryAgain>
<ExclamationCircleFillIcon />
<span>
Failed to load.
<TryAgain type="button" onClick={() => loadImage(value.fileId, value.fileUrl)}>
Please try again.
</TryAgain>
</span>
{loadErrorCount >= 3 && (
<RefreshAlert type="warning" data-testid="load-refresh-alert">
Refresh this page if your signature failed to load.
Expand All @@ -220,7 +227,12 @@ export const ESignatureField = (props: IGenericFieldProps<IESignatureFieldSchema
);
}

return <ErrorWrapper>{error?.message}</ErrorWrapper>;
return (
<ErrorWrapper>
<ExclamationCircleFillIcon />
<span>{error?.message}</span>
</ErrorWrapper>
);
};

return (
Expand Down