refactor: remove SocketContext and related dependencies from OrdersTab and ProfilePage components for improved performance and code clarity
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect, useContext } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Container,
|
||||
Paper,
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
} from '@mui/material';
|
||||
import { useLocation, useNavigate, Navigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import SocketContext from '../contexts/SocketContext.js';
|
||||
|
||||
// Import extracted components
|
||||
import OrdersTab from '../components/profile/OrdersTab.js';
|
||||
@@ -19,7 +18,7 @@ import CartTab from '../components/profile/CartTab.js';
|
||||
import LoginComponent from '../components/LoginComponent.js';
|
||||
|
||||
// Functional Profile Page Component
|
||||
const ProfilePage = (props) => {
|
||||
const ProfilePage = () => {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
@@ -211,7 +210,7 @@ const ProfilePage = (props) => {
|
||||
}
|
||||
|
||||
if (showLogin) {
|
||||
return <LoginComponent open={showLogin} handleClose={handleLoginClose} location={location} socket={props.socket} />;
|
||||
return <LoginComponent open={showLogin} handleClose={handleLoginClose} location={location}/>;
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
@@ -284,7 +283,7 @@ const ProfilePage = (props) => {
|
||||
|
||||
{tabValue === 0 && <CartTab onOrderSuccess={handleGoToOrders} paymentCompletion={paymentCompletion} onClearPaymentCompletion={handleClearPaymentCompletion} />}
|
||||
{tabValue === 1 && <OrdersTab orderIdFromHash={orderIdFromHash} />}
|
||||
{tabValue === 2 && <SettingsTab socket={props.socket} />}
|
||||
{tabValue === 2 && <SettingsTab/>}
|
||||
|
||||
</Box>
|
||||
</Paper>
|
||||
@@ -294,8 +293,7 @@ const ProfilePage = (props) => {
|
||||
|
||||
// Wrap with socket context
|
||||
const ProfilePageWithSocket = (props) => {
|
||||
const {socket,socketB} = useContext(SocketContext);
|
||||
return <ProfilePage {...props} socket={socket} socketB={socketB} />;
|
||||
return <ProfilePage {...props}/>;
|
||||
};
|
||||
|
||||
export default ProfilePageWithSocket;
|
||||
Reference in New Issue
Block a user