Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4113 | Rev 4405 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3585 stevensc 1
/* eslint-disable react/prop-types */
1 www 2
import React, { useEffect, useState } from "react";
3585 stevensc 3
import { withRouter } from "react-router";
1 www 4
import styled from "styled-components";
5
import BasicSettings from "./basic-settings/BasicSettings";
6
import Browsers from "./browsers/Browsers";
7
import ChangeImage from "./change-image/ChangeImage";
8
import ChangePassword from "./change-password/ChangePassword";
9
import Devices from "./devices/Devices";
10
import Ips from "./ips/Ips";
11
import Location from "./location/Location";
12
import Notifications from "./notifications/Notifications";
13
import Privacy from "./privacy/Privacy";
14
import SocialNetworks from "./social-networks/SocialNetworks";
15
import Transactions from "./transactions/Transactions";
1963 steven 16
import CloseAccount from "./close-account/CloseAccount";
1 www 17
 
18
const StyledNavTabs = styled.div`
19
  a {
20
    cursor: pointer;
21
    &.active {
22
      color: blue;
23
    }
24
  }
25
`;
26
 
27
const TABS = {
28
  BASIC: "BASIC",
29
  NOTIFICATIONS: "NOTIFICATIONS",
30
  CHANGE_PASSWORD: "CHANGE_PASSWORD",
31
  CHANGE_IMAGE: "CHANGE_IMAGE",
32
  LOCATION: "LOCAITON",
33
  PRIVACY: "PRIVACY",
34
  SOCIAL_NETWORKS: "SOCIAL_NETWORKS",
35
  TRANSACTIONS: "TRANSACTIONS",
36
  BROWSERS: "BROWSERS",
37
  IPS: "IPS",
38
  DEVICES: "DEVICES",
1963 steven 39
  CLOSE_ACCOUNT: "CLOSE_ACCOUNT",
1 www 40
};
41
 
42
const AccountSettings = (props) => {
43
  // props destructuring
44
  const {
45
    facebook,
46
    google,
47
    twitter,
48
    socialNetworkRoutes,
49
    routeTransactions,
50
    routeAddFunds,
51
    routeBrowsers,
52
    routeIPs,
53
    routeDevices,
54
    balance,
55
    amounts,
4113 efrain 56
    timezones
1 www 57
  } = props.backendVars;
58
 
59
  const [currentTab, setCurrentTab] = useState(TABS.BASIC);
60
 
3585 stevensc 61
  const handleChangeTab = (event, tab) => {
1 www 62
    event.preventDefault();
63
    setCurrentTab(tab);
64
  };
65
 
66
  const TabRender = () => {
67
    switch (currentTab) {
68
      case TABS.BASIC:
4113 efrain 69
        return <BasicSettings timezones={timezones} />;
1 www 70
      case TABS.NOTIFICATIONS:
71
        return <Notifications />;
72
      case TABS.CHANGE_PASSWORD:
73
        return <ChangePassword />;
74
      case TABS.CHANGE_IMAGE:
75
        return <ChangeImage />;
76
      case TABS.LOCATION:
77
        return <Location />;
78
      case TABS.PRIVACY:
79
        return <Privacy />;
80
      case TABS.SOCIAL_NETWORKS:
81
        return (
82
          <SocialNetworks
83
            facebook={facebook}
84
            twitter={twitter}
85
            google={google}
86
            socialNetworkRoutes={socialNetworkRoutes}
87
          />
88
        );
89
      case TABS.TRANSACTIONS:
90
        return (
91
          <Transactions
92
            routeTransactions={routeTransactions}
93
            routeAddFunds={routeAddFunds}
94
            balance={balance}
95
            amounts={amounts}
96
          />
97
        );
98
      case TABS.BROWSERS:
99
        return <Browsers routeBrowsers={routeBrowsers} />;
100
      case TABS.IPS:
101
        return <Ips routeIPs={routeIPs} />;
102
      case TABS.DEVICES:
103
        return <Devices routeDevices={routeDevices} />;
1963 steven 104
      case TABS.CLOSE_ACCOUNT:
105
        return <CloseAccount />;
1 www 106
      case TABS.default:
107
        return <BasicSettings />;
108
    }
109
  };
110
 
111
  useEffect(() => {
112
    const searchParam = new URLSearchParams(props.location.search);
113
    const tab = searchParam.get("tab");
114
    if (tab === "nav-basic") setCurrentTab(TABS.BASIC);
115
    if (tab === "nav-notification") setCurrentTab(TABS.NOTIFICATIONS);
116
    if (tab === "nav-password") setCurrentTab(TABS.CHANGE_PASSWORD);
117
    if (tab === "nav-image") setCurrentTab(TABS.CHANGE_IMAGE);
118
    if (tab === "nav-location") setCurrentTab(TABS.LOCATION);
119
    if (tab === "nav-privacy") setCurrentTab(TABS.PRIVACY);
120
    if (tab === "nav-social-networks") setCurrentTab(TABS.SOCIAL_NETWORKS);
121
    if (tab === "nav-transactions") setCurrentTab(TABS.TRANSACTIONS);
122
    if (tab === "nav-browsers") setCurrentTab(TABS.BROWSERS);
123
    if (tab === "nav-ips") setCurrentTab(TABS.IPS);
124
    if (tab === "nav-devices") setCurrentTab(TABS.DEVICES);
125
  }, [props.location]);
126
 
127
  return (
128
    <section className="profile-account-setting">
129
      <div className="container">
130
        <div className="account-tabs-setting">
2633 stevensc 131
          <h1>Configuración de la cuenta</h1>
1 www 132
          <div className="row">
2646 stevensc 133
            <div className="col-lg-4">
1 www 134
              <div className="acc-leftbar">
135
                <StyledNavTabs
136
                  className="nav nav-tabs"
137
                  id="nav-tab"
138
                  role="tablist"
139
                >
140
                  <a
3585 stevensc 141
                    href="#"
2629 stevensc 142
                    className={`nav-item nav-link`}
1 www 143
                    onClick={(e) => handleChangeTab(e, TABS.BASIC)}
3585 stevensc 144
                    >
2629 stevensc 145
                    <i className="la la-user" />Básica
1 www 146
                  </a>
147
                  <a
3585 stevensc 148
                    href="#"
2629 stevensc 149
                    className={`nav-item nav-link`}
1 www 150
                    onClick={(e) => handleChangeTab(e, TABS.NOTIFICATIONS)}
151
                  >
2629 stevensc 152
                    <i className="la la-cogs" />Notificaciones
1 www 153
                  </a>
154
                  <a
3585 stevensc 155
                    href="#"
2629 stevensc 156
                    className={`nav-item nav-link`}
1 www 157
                    onClick={(e) => handleChangeTab(e, TABS.CHANGE_PASSWORD)}
3585 stevensc 158
                    >
2629 stevensc 159
                    <i className="fa fa-lock" />Cambiar clave
1 www 160
                  </a>
161
                  <a
3585 stevensc 162
                    href="#"
2629 stevensc 163
                    className={`nav-item nav-link`}
1 www 164
                    onClick={(e) => handleChangeTab(e, TABS.CHANGE_IMAGE)}
3585 stevensc 165
                    >
2629 stevensc 166
                    <i className="fa fa-image" />Cambiar imagen
1 www 167
                  </a>
168
                  <a
3585 stevensc 169
                    href="#"
2629 stevensc 170
                    className={`nav-item nav-link`}
1 www 171
                    onClick={(e) => handleChangeTab(e, TABS.LOCATION)}
3585 stevensc 172
                    >
2629 stevensc 173
                    <i className="fa fa-map-marker" />Ubicación
1 www 174
                  </a>
175
                  <a
3585 stevensc 176
                    href="#"
2629 stevensc 177
                    className={`nav-item nav-link`}
1 www 178
                    onClick={(e) => handleChangeTab(e, TABS.PRIVACY)}
3585 stevensc 179
                    >
2629 stevensc 180
                    <i className="fa fa-user-secret" />Privacidad
1 www 181
                  </a>
182
                  <a
3585 stevensc 183
                    href="#"
2629 stevensc 184
                    className={`nav-item nav-link`}
1 www 185
                    onClick={(e) => handleChangeTab(e, TABS.SOCIAL_NETWORKS)}
3585 stevensc 186
                    >
2629 stevensc 187
                    <i className="fa fa-facebook" />Redes Sociales
1 www 188
                  </a>
4397 stevensc 189
                  {/* <a
3585 stevensc 190
                    href="#"
2629 stevensc 191
                    className={`nav-item nav-link`}
1 www 192
                    onClick={(e) => handleChangeTab(e, TABS.TRANSACTIONS)}
3585 stevensc 193
                    >
2629 stevensc 194
                    <i className="fa fa-money" />Transacciones
4397 stevensc 195
                  </a> */}
1963 steven 196
                  <a
3585 stevensc 197
                    href="#"
2629 stevensc 198
                    className={`nav-item nav-link`}
1963 steven 199
                    onClick={(e) => handleChangeTab(e, TABS.CLOSE_ACCOUNT)}
200
                  >
201
                    <i className="fa fa-trash"></i>Cerrar cuenta
202
                  </a>
1 www 203
                </StyledNavTabs>
204
              </div>
205
            </div>
2646 stevensc 206
            <div className="col-lg-8">
1966 steven 207
              <div className="tab-content h-100" id="nav-tabContent">
208
                <div className="tab-pane fade active show h-100">
209
                  {TabRender()}
210
                </div>
1 www 211
              </div>
212
            </div>
213
          </div>
214
        </div>
215
      </div>
216
    </section>
217
  );
218
};
219
 
220
export default withRouter(AccountSettings);