Skip to content

Commit

Permalink
fix redux in register
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufginanjar committed Sep 30, 2022
1 parent fc33b34 commit 05db5f6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pages/register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import React, { useState as _useState } from 'react';
import { Form } from 'react-bootstrap';
import { uid } from 'uid';
import { useRouter as _useRouter } from 'next/router';
import { login as stateLogin } from '../store/authSlice';
import { useDispatch } from 'react-redux';
import Swal from 'sweetalert2';
import {
createUserWithEmailAndPassword,
getAuth,
ref,
set,
getDatabase,
onValue,
} from '../firebase/clientApp';
const registerState = {
username: '',
Expand Down Expand Up @@ -38,6 +41,7 @@ export default function signup() {
const { name, value } = e.target;
setUser({ ...user, [name]: value });
};
const dispatch = useDispatch();
const handleRegister = async () => {
if ((username, password, email === '')) {
await Toast.fire({
Expand All @@ -63,6 +67,11 @@ export default function signup() {
bio,
}
);
const dataRef = ref(db, `/users/${auth.currentUser.uid}`);
onValue(dataRef, (snapshot) => {
const data = snapshot.val();
dispatch(stateLogin(data))
});
await Toast.fire({
icon: 'success',
title:
Expand Down

0 comments on commit 05db5f6

Please sign in to comment.