Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P2PS] farrah/P2PS-2345/fix: remove disclaimer modal #15076

Merged
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
31 changes: 0 additions & 31 deletions packages/p2p/src/components/app-content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,18 @@ import { useModalManagerContext } from 'Components/modal-manager/modal-manager-c
import TemporarilyBarredHint from 'Components/temporarily-barred-hint';
import { buy_sell } from 'Constants/buy-sell';
import { useStores } from 'Stores';
import { getHoursDifference } from 'Utils/date-time';
import { localize } from './i18next';

const INTERVAL_DURATION = 24; // 24 hours

const AppContent = ({ order_id }) => {
const { buy_sell_store, general_store } = useStores();
const { showModal, hideModal } = useModalManagerContext();
let timeout;
const {
notifications: { setP2POrderProps },
client: { loginid },
} = useStore();
const notification_count = useP2PNotificationCount();
const is_system_maintenance = useIsSystemMaintenance();
const history = useHistory();

const handleDisclaimerTimeout = time_lapsed => {
timeout = setTimeout(() => {
showModal({ key: 'DisclaimerModal', props: { handleDisclaimerTimeout } });
// Display the disclaimer modal again after 24 hours
}, (INTERVAL_DURATION - time_lapsed) * 3600000);
};

React.useEffect(() => {
if (
!general_store.should_show_dp2p_blocked &&
!is_system_maintenance &&
!general_store.counterparty_advert_id
) {
const time_lapsed = getHoursDifference(localStorage.getItem(`p2p_${loginid}_disclaimer_shown`));
if (time_lapsed === undefined || time_lapsed > INTERVAL_DURATION) {
showModal({ key: 'DisclaimerModal', props: { handleDisclaimerTimeout } });
} else {
handleDisclaimerTimeout(time_lapsed);
}
}

return () => {
clearTimeout(timeout);
};
}, []);

React.useEffect(() => {
buy_sell_store.setTableType(buy_sell.BUY);
return reaction(
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions packages/p2p/src/constants/modals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ export const Modals = {
/* webpackChunkName: "delete-payment-method-error-modal" */ 'Components/modal-manager/modals/delete-payment-method-error-modal'
)
),
DisclaimerModal: React.lazy(
() => import(/* webpackChunkName: "disclaimer-modal" */ 'Components/modal-manager/modals/disclaimer-modal')
),
EmailLinkBlockedModal: React.lazy(
() =>
import(
Expand Down
15 changes: 0 additions & 15 deletions packages/p2p/src/utils/date-time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,3 @@ export const millisecondsToTimer = (distance: number): string => {

return `${toDoubleDigits(hours)}:${toDoubleDigits(minutes)}:${toDoubleDigits(seconds)}`;
};

/**
* Calculate the difference in hours between the current time and a given time.
*
* @param {string} time_set - The time to compare against.
* @returns {number|undefined} The difference in hours between the current time and the given time. Returns `undefined` if the input is invalid.
*/
export const getHoursDifference = (time_set: string): number | undefined => {
if (!time_set) return undefined;
const current_time = new Date();
const updated_time = new Date(time_set);
const difference = current_time.getTime() - updated_time.getTime();
const hours_difference = Math.floor(difference / 1000 / 60 / 60);
return hours_difference;
};
Loading