<file_sep><?php

namespace App\Http\Controllers;

use App\Http\Requests\PersonalInformationUser as RequestsPersonalInformationUser;
use App\Http\Requests\PersonalInformationUserRequest;
use App\Models\PersonalInformationUser;
use Illuminate\Http\Request;

class PersonalInformationUserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(PersonalInformationUserRequest $request)
    {
        // dd($request->all());
        $data = PersonalInformationUser::create($request->all());
        return response()->json(['response'=>$data],200);
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\PersonalInformationUser  $personalInformationUser
     * @return \Illuminate\Http\Response
     */
    public function show(PersonalInformationUser $personalInformationUser)
    {
        //
    }


    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\PersonalInformationUser  $personalInformationUser
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, PersonalInformationUser $personalInformationUser)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\PersonalInformationUser  $personalInformationUser
     * @return \Illuminate\Http\Response
     */
    public function destroy(PersonalInformationUser $personalInformationUser)
    {
        //
    }

    public function getPersonalDataByUserId(Request $request)
    {
        $userId = $request->post('user_id');
        $personalInformation = PersonalInformationUser::firstOrFail()->where('users_id',$userId);
        return response()->json(['response'=>$personalInformation],200);
    }
}
<file_sep><?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class PersonalInformationUser extends Model
{
    use HasFactory;

    protected $fillable = [
        'users_id',
        'name',
        'lastname',
        'day_of_birth',
        'document_number',
        'document_type_id',
        'profile_picture',
        'phone_number',
        'address'
    ];
}
<file_sep>

export const fetch_form = ({formulario}) => {

    var formulario = document.getElementById('formulario');
    formulario.addEventListener('submit', function(e){
        console.log('evento de click')
    })

}
<file_sep><?php

use App\Http\Controllers\PersonalInformationUserController;
use App\Http\Controllers\UsersController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});


Route::post('login', [UsersController::class, 'login']);

Route::group(['middleware' => ['cors']],function(){
    Route::post('register', [UsersController::class, 'register']);
});

Route::Resource('personalInformation', PersonalInformationUserController::class)->except(['create', 'edit']);
Route::post('getPersonalInformation',[PersonalInformationUserController::class,'getPersonalDataByUserId']);
<file_sep>import React, {useState} from 'react'
import {Container} from '@material-ui/core';

const Form_registro = () => {
    const [email, setEmail] = useState("")
    const [password, setPass] = useState("")
    const [form_data, setForm_data] = useState([])

    const handdleSubmit = async e => {
        // fetch o axios
        e.preventDefault()
        let form = document.getElementById('form_registro')
        // let form = document.getElementById('form_registro')
        // console.log(form)
        // console.log('hola');
        let data =  new FormData(form)
        data = JSON.stringify({email,password})
        console.log(data)
        await fetch('http://127.0.0.1:8000/api/register',{
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: data,
            
        }) .then(datos => datos.json())                                                                                        
            .then(dataFormRegistro => {
                console.log(dataFormRegistro.errors.email)
                setForm_data(dataFormRegistro)
            })
    }

    return (
        <div>
            <h1>Formulario de registro</h1>
             <Container>
                <form onSubmit= {handdleSubmit} id="form_registro" >
                    <label > Email</label>
                    <input 
                        onChange = {({target : {value}}) => setEmail(value) } 
                        value = {email}
                        name = "correo"
                    />

                    <label > Password </label>
                    <input 
                        onChange = {({target : {value}}) => setPass(value) } 
                        value = {password}
                        name = "password"   
                    />
                    <input type="submit" value="submit"/>

                </form>

                <div>Form data: {JSON.stringify({email, pass: password})} </div>
                
                <div>
                    {form_data.map( data => (
                        <p> ${data} </p> //data. cosasssss ctmr
                    ))}
                </div>

                {/* <form action="hola.php" method="post" id="formulario">
                    <InputLabel htmlFor="email">Ingrese su Mail</InputLabel>
                    <Input id="email" type="email" aria-describedby="email-helper" />
                    <FormHelperText id="email-helper">Ingrese su mail </FormHelperText>

                    <InputLabel htmlFor="pwd">Ingrese su contraseña</InputLabel>
                    <Input id="pwd" type="<PASSWORD>" aria-describedby="password-helper" />
                    <FormHelperText id="password-helper">Ingrese su pass</FormHelperText>

                    <Button variant="contained" color="primary" type="submit">
                        Inciar sesión
                    </Button>
                </form> */}

     

                {/* <Grid container>
                
                        <Grid item md={12}>
                            <FormControl >
                                <InputLabel htmlFor="email">Ingrese su Mail</InputLabel>
                                <Input id="email" type="email" aria-describedby="email-helper" />
                                <FormHelperText id="email-helper">Ingrese su mail </FormHelperText>
                            </FormControl>
                        </Grid>

                        <Grid item md={12}>
                            <FormControl>
                                <InputLabel htmlFor="pwd">Ingrese su contraseña</InputLabel>
                                <Input id="pwd" type="<PASSWORD>" aria-describedby="password-helper" />
                                <FormHelperText id="password-helper">Ingrese su pass</FormHelperText>
                            </FormControl>
                        </Grid>

                        <Grid item md={12} >
                            <Button variant="contained" color="primary" type="submit">
                                Inciar sesión
                            </Button>
                        </Grid>
                   
                </Grid> */}

             </Container>

        </div>
    )
}

export default Form_registro
<file_sep><?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePersonalInformationUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('personal_information_users', function (Blueprint $table) {
            $table->id();
            $table->foreignId('users_id')->constrained('users');
            $table->string('name');
            $table->string('lastname');
            $table->date('day_of_birth')->nullable();
            $table->integer('document_number');
            $table->enum('document_type_id',['DNI','PASAPORTE','LIBRETA CIVICA']);
            $table->string('profile_picture')->nullable();
            $table->string('phone_number');
            $table->string('address');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('personal_information_users');
    }
}
<file_sep><?php

namespace App\Http\Controllers;

use App\Http\Requests\RegisterRequest;
use App\Models\User;
use Illuminate\Http\Request;

class UsersController extends Controller
{
    public function register(RegisterRequest $request): \Illuminate\Http\JsonResponse
    {
        // dd($request->all());
        $request->merge(['password' => <PASSWORD>($request->input('password'))]);

        $User = User::create($request->only(['email','password']));

        return response()->json(['response'=>$User]);
    }

    public function login()
    {
        
    }
}
<file_sep>import './App.scss';
import NavBar from './components/navBar/NavBar';
// import Button from '@material-ui/core/Button';
// import Box from '@material-ui/core/Box';
// import Publication from './components/Publication/Publication';
import Grid_publication from './components/Grid_publication/Grid_publication';

// import Button_donar from './components/Button_donar/Button_donar';
import Button_donar from './components/Button_donar/Button_donar'

import {
  BrowserRouter as Router,
  Switch,
  Route,
  Link
} from "react-router-dom";
import Form_registro from './components/Formulario_registro/Form_registro';



function App() {
  // const name_button = "Publicar Donación"
  return (
    <Router>
      <Switch>
        
        <Route path="/registro">
          <Form_registro />
        </Route>

        <Route path="/">
          <div className="App">
            <NavBar />

            <Link to="/registro" style={{ textDecoration: 'none' }}>
              <Button_donar nameButton = {"Publicar Donación"} />
            </Link>

            <Link to="/registro" style={{ textDecoration: 'none' }}>
              <Button_donar nameButton = {"Publicar Pedido"} />
            </Link>

            <Grid_publication />
          </div>
        </Route>
      </Switch>

    </Router>
    
  );
}

export default App;
<file_sep>import React from 'react'
import Button from '@material-ui/core/Button';

import '../../App'
import './Button_donar.scss'

const Button_donar = ({nameButton}) => {
    return (
        <Button p={1} bgcolor="grey.300" variant="contained" color="secondary" className="Button_donar">
            {nameButton}
        </Button>
    )
}

export default Button_donar
