last master commit
This commit is contained in:
@ -1,37 +1,42 @@
|
||||
import { UserCtx, UserCtxT } from '../context/UserContext';
|
||||
import { useContext, ReactNode } from 'react'
|
||||
import { ResponseT, DogT} from '../context/UserContext';
|
||||
import { ReactNode, useState } from 'react'
|
||||
import { useParams } from "react-router-dom";
|
||||
import Img from './Img';
|
||||
import DogNameTxt from './DogNameTxt';
|
||||
import './Dog.css';
|
||||
import {getDog} from '../services/PhpApi'
|
||||
|
||||
const Dog = () =>
|
||||
{
|
||||
const {getDog, dog} = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
|
||||
const [success, setSuccess] = useState<number>(0);
|
||||
// m7MdMK
|
||||
const params = useParams();
|
||||
const qr_id = Object.values(params)[0];
|
||||
var needData = dog.success === undefined;
|
||||
if(needData)
|
||||
var dogRes : ResponseT = {};
|
||||
var dog: DogT = dogRes.data;
|
||||
|
||||
getDog(qr_id).then((resDog) =>
|
||||
{
|
||||
getDog(qr_id); // await not allowed?! => workaraound
|
||||
}
|
||||
dogRes = Object.assign({},resDog);
|
||||
dog = Object.assign({},resDog.data);
|
||||
setSuccess(dogRes.success);
|
||||
});
|
||||
|
||||
var email = "nicht definiert;"
|
||||
var phone = "nicht definiert;"
|
||||
var picPath = "nicht definiert;"
|
||||
//var qrPath = "nicht definiert;"
|
||||
var name = "nicht definiert;"
|
||||
if(dog.success === 1)
|
||||
if(success === 1)
|
||||
{
|
||||
name = dog.data.name;
|
||||
name = dog.name;
|
||||
//qrPath = dog.data.qr_code;
|
||||
picPath = dog.data.picture;
|
||||
email = dog.data.email;
|
||||
phone = dog.data.phone;
|
||||
picPath = dog.picture;
|
||||
email = dog.email;
|
||||
phone = dog.phone;
|
||||
}
|
||||
|
||||
const content: ReactNode = dog.success === 1 ?
|
||||
const content: ReactNode = success === 1 ?
|
||||
<div className = 'Dog'>
|
||||
<h1>Hast Du mich gefunden?</h1>
|
||||
{/* <p>name: {name}</p>
|
||||
|
||||
@ -2,7 +2,7 @@ import React, { useContext } from 'react'
|
||||
import { UserCtx, UserCtxT } from '../context/UserContext';
|
||||
|
||||
export default function Home() {
|
||||
const {loginUser, wait, getUser, user} = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
const {user} = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
return (
|
||||
<div>
|
||||
<h1>Home</h1>
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import {useState,useContext} from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import {UserCtx, UserCtxT} from '../context/UserContext';
|
||||
import './Login.css'
|
||||
import './Login.css';
|
||||
import {loginUser} from '../services/PhpApi'
|
||||
|
||||
const Login = () =>
|
||||
{
|
||||
const {loginUser, wait, getUser, user} = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
const {wait, getUser, user} = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
const [redirect, setRedirect] = useState("false");
|
||||
const [errMsg, setErrMsg] = useState("false");
|
||||
const [formData, setFormData] = useState({
|
||||
@ -39,12 +40,12 @@ const Login = () =>
|
||||
if(data.success)
|
||||
{
|
||||
setRedirect('Redirecting...');
|
||||
setErrMsg(data.message);
|
||||
setErrMsg(data.message!);
|
||||
await getUser();
|
||||
navigate('/profil');
|
||||
return;
|
||||
}
|
||||
setErrMsg(data.message);
|
||||
setErrMsg(data.message!);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -2,10 +2,10 @@ import {useContext, useState} from 'react'
|
||||
import {Link} from 'react-router-dom'
|
||||
import {UserCtx, UserCtxT} from '../context/UserContext';
|
||||
import './Register.css';
|
||||
|
||||
import {registerUser} from '../services/PhpApi';
|
||||
|
||||
const Register = () => {
|
||||
const {registerUser, wait} = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
const {wait} = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
const [errMsg, setErrMsg] = useState("false");
|
||||
const [successMsg, setSuccessMsg] = useState("false");
|
||||
const [formData, setFormData] = useState({
|
||||
|
||||
Reference in New Issue
Block a user