refactor: replace socket prop usage with window.socketManager for consistent socket handling across components

This commit is contained in:
sebseb7
2025-07-23 08:08:58 +02:00
parent 9982527f35
commit 4e6b63a6a4
10 changed files with 56 additions and 145 deletions

View File

@@ -1,10 +1,9 @@
import React, { Component } from 'react';
import { Navigate } from 'react-router-dom';
import { Box, CircularProgress, Typography } from '@mui/material';
import SocketContext from '../contexts/SocketContext.js';
class PaymentSuccess extends Component {
static contextType = SocketContext;
constructor(props) {
super(props);
@@ -73,19 +72,10 @@ class PaymentSuccess extends Component {
};
checkMolliePaymentStatus = (paymentId) => {
const { socket } = this.context;
if (!socket || !socket.connected) {
console.error('Socket not connected');
this.setState({
redirectUrl: '/profile#cart',
processing: false,
error: 'Connection error'
});
return;
}
socket.emit('checkMollieIntent', { paymentId }, (response) => {
window.socketManager.emit('checkMollieIntent', { paymentId }, (response) => {
if (response.success) {
console.log('Payment Status:', response.payment.status);
console.log('Is Paid:', response.payment.isPaid);