Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1 | Rev 2647 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 2646
Línea 1... Línea 1...
1
import {axios} from "../../../utils";
1
import { axios } from "../../../utils";
2
import React, { useEffect, useRef, useState } from "react";
2
import React, { useEffect, useRef, useState } from "react";
3
import { useForm } from "react-hook-form";
3
import { useForm } from "react-hook-form";
4
import { connect } from "react-redux";
4
import { connect } from "react-redux";
5
import styled from "styled-components";
5
import styled from "styled-components";
6
import { addNotification } from "../../../redux/notification/notification.actions";
6
import { addNotification } from "../../../redux/notification/notification.actions";
Línea 117... Línea 117...
117
      formData.append(key, value);
117
      formData.append(key, value);
118
    });
118
    });
119
    await axios
119
    await axios
120
      .post("/account-settings/location", formData)
120
      .post("/account-settings/location", formData)
121
      .then((response) => {
121
      .then((response) => {
122
        const resData = response.data;        
122
        const resData = response.data;
123
        if (resData.success) {
123
        if (resData.success) {
124
          addNotification({
124
          addNotification({
125
            style: "success",
125
            style: "success",
126
            msg: resData.data.message,
126
            msg: resData.data.message,
127
          });
127
          });
128
        } else {
128
        } else {
129
          if (typeof resData.data === "object") {
129
          if (typeof resData.data === "object") {
130
            resData.data;
130
            resData.data;
131
            Object.entries(resData.data).map(([key, value]) => {              
131
            Object.entries(resData.data).map(([key, value]) => {
132
              setError(key, { type: "manual", message: value[0] });
132
              setError(key, { type: "manual", message: value[0] });
133
            });
133
            });
134
          } else {
134
          } else {
135
            const errorMessage =
135
            const errorMessage =
136
              typeof resData.data === "string"
136
              typeof resData.data === "string"
Línea 158... Línea 158...
158
    });
158
    });
159
    setLoading(false);
159
    setLoading(false);
160
  }, []);
160
  }, []);
Línea 161... Línea 161...
161
 
161
 
162
  return (
-
 
163
    <div
162
  return (
164
      className="acc-setting"
-
 
165
      style={{
163
    <div className="settings-container">
166
        position: "relative",
-
 
167
      }}
-
 
168
    >
164
      <h2>Cambiar Ubicación</h2>
169
      <h3>Básica</h3>
165
      <div className="acc-setting_content">
-
 
166
        <form onSubmit={handleSubmit(handleOnSubmit)}>
170
      <form onSubmit={handleSubmit(handleOnSubmit)}>
167
          <div className="d-flex flex-wrap" style={{ gap: '1rem' }}>
171
        <div className="cp-field">
168
            <div className="cp-field">
172
          <label htmlFor="first_name">Ubicación</label>
169
              <label htmlFor="first_name">Ubicación</label>
173
          <div className="cpp-fiel">
170
              <div className="cpp-fiel">
174
            <UbicationInput
171
                <UbicationInput
175
              onGetAddress={getAddressHandler}
172
                  onGetAddress={getAddressHandler}
176
              settedQuery={watch("formatted_address")}
173
                  settedQuery={watch("formatted_address")}
177
            />
174
                />
-
 
175
                <i className="fa fa-map-marker"></i>
-
 
176
              </div>
-
 
177
              {
-
 
178
                <FormErrorFeedback>
-
 
179
                  {errors?.formatted_address?.message}
-
 
180
                </FormErrorFeedback>
-
 
181
              }
-
 
182
            </div>
-
 
183
            <button type="submit" className="btn btn-secondary">
-
 
184
              Guardar
178
            <i className="fa fa-map-marker"></i>
185
            </button>
179
          </div>
-
 
180
          {
-
 
181
            <FormErrorFeedback>
-
 
182
              {errors?.formatted_address?.message}
-
 
183
            </FormErrorFeedback>
-
 
184
          }
186
          </div>
185
        </div>
-
 
186
        <div className="save-stngs pd2">
-
 
187
          <ul>
-
 
188
            <li>
-
 
189
              <button type="submit" className="btn-save-basic">
-
 
190
                Guardar
-
 
191
              </button>
-
 
192
            </li>
-
 
193
          </ul>
187
        </form>
194
        </div>
-
 
195
        {/* <!--save-stngs end--> */}
-
 
196
        {/* <?php echo $this->form()->closeTag($form); ?>	 */}
-
 
197
      </form>
188
      </div>
198
      {loading && (
189
      {loading &&
199
        <StyledSpinnerContainer>
190
        <StyledSpinnerContainer>
200
          <Spinner />
191
          <Spinner />
201
        </StyledSpinnerContainer>
192
        </StyledSpinnerContainer>
202
      )}
193
      }
203
    </div>
194
    </div>
204
  );
195
  );
Línea 205... Línea -...
205
};
-
 
206
 
-
 
207
// const mapStateToProps = (state) => ({
-
 
208
 
-
 
209
// })
196
};
210
 
197
 
211
const mapDispatchToProps = {
198
const mapDispatchToProps = {
Línea 212... Línea 199...
212
  addNotification: (notification) => addNotification(notification),
199
  addNotification: (notification) => addNotification(notification),