Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 3183 Rev 3184
Línea 56... Línea 56...
56
  }, [settedPrivacy]);
56
  }, [settedPrivacy]);
Línea 57... Línea 57...
57
 
57
 
58
  const onSubmitHandler = async (data) => {
58
  const onSubmitHandler = async (data) => {
59
    // profile/my-profiles/extended', [ 'id' => $user_profile_id_encrypted]
59
    // profile/my-profiles/extended', [ 'id' => $user_profile_id_encrypted]
60
    // https://leaderslinked.com/profile/my-profiles/extended/MzU4NDg3ODcg
-
 
61
    setLoading(true);
60
    // https://leaderslinked.com/profile/my-profiles/extended/MzU4NDg3ODcg
62
    const formData = new FormData();
61
    const formData = new FormData();
-
 
62
    Object.entries(data).map(async ([key, value]) => {
63
    Object.entries(data).map(([key, value]) => {
63
      setLoading(true);
64
      if (value === 'pr') {
64
      if (value === 'pr') {
65
        const accessibilityData = new FormData()
65
        const accessibilityData = new FormData()
66
        accessibilityData.append('accessibility', 'aa')
66
        accessibilityData.append('accessibility', 'aa')
-
 
67
        const { data } = await axios.post(`/group/my-groups/accessibility/${groupId}`, accessibilityData)
67
        axios.post(`/group/my-groups/accessibility/${groupId}`, accessibilityData)
68
        if (data.success) {
-
 
69
          setSettedAccesibility(data.data)
-
 
70
          setLoading(false)
-
 
71
        }
-
 
72
 
68
          .then(({ data }) => data.success && setSettedAccesibility(data.data))
73
        setLoading(false)
69
      }
74
      }
70
      formData.append(key, value)
75
      formData.append(key, value)
-
 
76
    })
-
 
77
 
-
 
78
    if (!loading) {
71
    })
79
      setLoading(true)
72
    await axios.post(`/group/my-groups/privacy/${groupId}`, formData)
80
      await axios.post(`/group/my-groups/privacy/${groupId}`, formData)
73
      .then((response) => {
81
        .then((response) => {
74
        const resData = response.data;
82
          const resData = response.data;
75
        (resData);
83
          (resData);
76
        if (resData.success) {
84
          if (resData.success) {
77
          setSettedPrivacy(resData.data);
85
            setSettedPrivacy(resData.data);
78
          handleModalOpen();
-
 
79
        } else {
-
 
80
          const resError = resData.data;
-
 
81
          if (resError.constructor.name === "Object") {
-
 
82
            Object.entries(resError).map(([key, value]) => {
-
 
83
              if (key in getValues()) {
-
 
84
                setError(key, {
-
 
85
                  type: "manual",
-
 
86
                  message: Array.isArray(value) ? value[0] : value,
-
 
87
                });
-
 
88
              }
-
 
89
            });
86
            handleModalOpen();
-
 
87
          } else {
-
 
88
            const resError = resData.data;
-
 
89
            if (resError.constructor.name === "Object") {
-
 
90
              Object.entries(resError).map(([key, value]) => {
-
 
91
                if (key in getValues()) {
-
 
92
                  setError(key, {
-
 
93
                    type: "manual",
-
 
94
                    message: Array.isArray(value) ? value[0] : value,
-
 
95
                  });
-
 
96
                }
-
 
97
              });
90
          } else {
98
            } else {
91
            addNotification({
99
              addNotification({
92
              style: "danger",
100
                style: "danger",
93
              msg: resError,
101
                msg: resError,
-
 
102
              });
94
            });
103
            }
95
          }
104
          }
96
        }
105
        });
97
      });
106
    }
98
    setLoading(false);
107
    setLoading(false);
Línea 99... Línea 108...
99
  };
108
  };
100
 
109