diff --git a/src/components/BuySellForm/BuySellForm.tsx b/src/components/BuySellForm/BuySellForm.tsx
index 7a471bd8..f4439c91 100644
--- a/src/components/BuySellForm/BuySellForm.tsx
+++ b/src/components/BuySellForm/BuySellForm.tsx
@@ -141,6 +141,7 @@ const BuySellForm = ({ advertId, isModalOpen, onRequestClose }: TBuySellFormProp
formState: { isValid },
getValues,
handleSubmit,
+ setValue,
} = useForm({
defaultValues: {
amount: min_order_amount_limit ?? 1,
@@ -254,6 +255,7 @@ const BuySellForm = ({ advertId, isModalOpen, onRequestClose }: TBuySellFormProp
)}
minLimit={min_order_amount_limit_display ?? '0'}
paymentMethodNames={payment_method_names}
+ setValue={setValue as unknown as (name: string, value: string) => void}
/>
diff --git a/src/components/BuySellForm/__tests__/BuySellForm.spec.tsx b/src/components/BuySellForm/__tests__/BuySellForm.spec.tsx
index ac39a18e..4f878bf8 100644
--- a/src/components/BuySellForm/__tests__/BuySellForm.spec.tsx
+++ b/src/components/BuySellForm/__tests__/BuySellForm.spec.tsx
@@ -153,6 +153,7 @@ jest.mock('react-hook-form', () => ({
amount: 1,
})),
handleSubmit: mockHandleSubmit,
+ setValue: jest.fn(),
}),
}));
diff --git a/src/components/FileDropzone/FileDropzone.scss b/src/components/FileDropzone/FileDropzone.scss
index 6e01ba67..adb3838a 100644
--- a/src/components/FileDropzone/FileDropzone.scss
+++ b/src/components/FileDropzone/FileDropzone.scss
@@ -1,11 +1,15 @@
@mixin file-dropzone-message {
- display: block;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
max-width: 16.8rem;
opacity: 1;
pointer-events: none;
position: absolute;
transform: translate3d(0, 0, 0);
- transition: transform 0.25s ease, opacity 0.15s linear;
+ transition:
+ transform 0.25s ease,
+ opacity 0.15s linear;
@include mobile {
max-width: 26rem;
diff --git a/src/components/Modals/AdCreateEditErrorModal/AdCreateEditErrorModal.tsx b/src/components/Modals/AdCreateEditErrorModal/AdCreateEditErrorModal.tsx
index 52552c6a..237aeab6 100644
--- a/src/components/Modals/AdCreateEditErrorModal/AdCreateEditErrorModal.tsx
+++ b/src/components/Modals/AdCreateEditErrorModal/AdCreateEditErrorModal.tsx
@@ -12,20 +12,15 @@ type TAdCreateEditErrorModalProps = {
type ErrorContent = {
[key in TErrorCodes]?: {
- description: string;
title: string;
};
};
const errorContent: ErrorContent = {
[ERROR_CODES.ADVERT_SAME_LIMITS]: {
- description:
- 'Please set a different minimum and/or maximum order limit. \n\nThe range of your ad should not overlap with any of your active ads.',
title: 'You already have an ad with this range',
},
[ERROR_CODES.DUPLICATE_ADVERT]: {
- description:
- 'You already have an ad with the same exchange rate for this currency pair and order type. \n\nPlease set a different rate for your ad.',
title: 'You already have an ad with this rate',
},
};
@@ -49,7 +44,7 @@ const AdCreateEditErrorModal = ({
{(errorCode && errorContent?.[errorCode]?.title) ?? 'Something’s not right'}
- {(errorCode && errorContent?.[errorCode]?.description) ?? errorMessage}
+ {errorMessage}
);
};
diff --git a/src/pages/orders/components/OrderDetailsCard/OrderDetailsCardFooter/OrderDetailsCardFooter.tsx b/src/pages/orders/components/OrderDetailsCard/OrderDetailsCardFooter/OrderDetailsCardFooter.tsx
index c1e7675f..59abac3a 100644
--- a/src/pages/orders/components/OrderDetailsCard/OrderDetailsCardFooter/OrderDetailsCardFooter.tsx
+++ b/src/pages/orders/components/OrderDetailsCard/OrderDetailsCardFooter/OrderDetailsCardFooter.tsx
@@ -1,11 +1,14 @@
-import { OrderDetailsCancelModal, OrderDetailsComplainModal } from '@/components/Modals';
+import { useEffect } from 'react';
+import { OrderDetailsCancelModal, OrderDetailsComplainModal, OrderDetailsConfirmModal } from '@/components/Modals';
+import { ERROR_CODES } from '@/constants';
+import { api } from '@/hooks';
import { useModalManager } from '@/hooks/custom-hooks';
import { useOrderDetails } from '@/providers/OrderDetailsProvider';
import { Button, useDevice } from '@deriv-com/ui';
import './OrderDetailsCardFooter.scss';
// TODO: Implement functionality for each button when integrating with the API and disable buttons while chat is loading
-const OrderDetailsCardFooter = () => {
+const OrderDetailsCardFooter = ({ sendFile }: { sendFile: (file: File) => void }) => {
const { orderDetails } = useOrderDetails();
const {
id,
@@ -15,10 +18,34 @@ const OrderDetailsCardFooter = () => {
shouldShowOnlyComplainButton,
shouldShowOnlyReceivedButton,
} = orderDetails;
+
const { isMobile } = useDevice();
const { hideModal, isModalOpenFor, showModal } = useModalManager({ shouldReinitializeModals: false });
+ const { error, isError, mutate } = api.order.useConfirm();
const textSize = isMobile ? 'md' : 'sm';
+ //TODO: handle email verification, invalid verification, and rating modals.
+ const handleModalDisplay = (isError: boolean, isBuyOrderForUser: boolean, code?: string) => {
+ if (isError) {
+ if (code === ERROR_CODES.ORDER_EMAIL_VERIFICATION_REQUIRED) {
+ showModal('EmailVerificationModal');
+ } else if (
+ code === ERROR_CODES.INVALID_VERIFICATION_TOKEN ||
+ code === ERROR_CODES.EXCESSIVE_VERIFICATION_REQUESTS
+ ) {
+ showModal('InvalidVerificationLinkModal');
+ } else if (code === ERROR_CODES.EXCESSIVE_VERIFICATION_FAILURES && isBuyOrderForUser) {
+ showModal('EmailLinkBlockedModal');
+ }
+ } else if (!isBuyOrderForUser) {
+ showModal('RatingModal');
+ }
+ };
+
+ useEffect(() => {
+ handleModalDisplay(isError, isBuyOrderForUser, error?.error?.code);
+ }, [error?.error, isBuyOrderForUser, isError]);
+
if (
!shouldShowCancelAndPaidButton &&
!shouldShowComplainAndReceivedButton &&
@@ -28,6 +55,11 @@ const OrderDetailsCardFooter = () => {
return null;
}
+ const onClickPaid = () => {
+ hideModal();
+ mutate({ id });
+ };
+
return (
{shouldShowCancelAndPaidButton && (
@@ -42,7 +74,7 @@ const OrderDetailsCardFooter = () => {
>
Cancel order
-
+ showModal('OrderDetailsConfirmModal')} size='lg' textSize={textSize}>
I’ve paid
@@ -100,6 +132,15 @@ const OrderDetailsCardFooter = () => {
onRequestClose={hideModal}
/>
)}
+ {!!isModalOpenFor('OrderDetailsConfirmModal') && (
+