-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
253db74
commit 3b239f3
Showing
8 changed files
with
14,315 additions
and
66 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,25 @@ | ||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
height: 40vmin; | ||
pointer-events: none; | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
min-height: 100px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
padding-left: 40px; | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
#customerForm { | ||
width: 300px; | ||
background-color: whitesmoke; | ||
margin: auto; | ||
padding: 20px; | ||
text-align: center; | ||
margin-top: 20px; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
#viewCustomers { | ||
background-color: rgb(240, 240, 240); | ||
margin: 30px 80px; | ||
padding: 10px; | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import React from "react"; | ||
import gql from "graphql-tag"; | ||
import Button from "@material-ui/core/Button"; | ||
import { Formik, Field, Form } from "formik"; | ||
import { TextField } from "formik-material-ui"; | ||
import * as Yup from "yup"; | ||
import { useMutation } from "@apollo/react-hooks"; | ||
import { GET_CUSTOMERS } from "./customers"; | ||
|
||
const ADD_CUSTOMER = gql` | ||
mutation CreateCustomer( | ||
$FullName: String | ||
$FirstName: String | ||
$SecondName: String | ||
$LastName: String | ||
) { | ||
CreateCustomer( | ||
FullName: $FullName | ||
FirstName: $FirstName | ||
SecondName: $SecondName | ||
LastName: $LastName | ||
) | ||
} | ||
`; | ||
|
||
export function CustomersForm() { | ||
const [addCustomer, { data }] = useMutation(ADD_CUSTOMER, { | ||
refetchQueries: [{ query: GET_CUSTOMERS }] | ||
}); | ||
console.log(data); | ||
|
||
return ( | ||
<div id="customerForm"> | ||
<h3>ADD HUMAN</h3> | ||
<Formik | ||
initialValues={{ | ||
FirstName: "", | ||
SecondName: "", | ||
LastName: "", | ||
Email: "" | ||
}} | ||
validationSchema={Yup.object().shape({ | ||
FirstName: Yup.string().required("First Name is required"), | ||
SecondName: Yup.string().required("Second Name is required"), | ||
LastName: Yup.string().required("Last Name is required"), | ||
Email: Yup.string() | ||
.email("Email is invalidd") | ||
.required("Email is required") | ||
})} | ||
onSubmit={(fields, { resetForm }) => { | ||
addCustomer({ | ||
variables: { | ||
...fields, | ||
FullName: `${fields.FirstName} ${fields.SecondName} ${fields.LastName}` | ||
} | ||
}); | ||
resetForm(); | ||
}} | ||
render={({ errors, status, touched }) => ( | ||
<Form> | ||
<Field | ||
label="First Name" | ||
name="FirstName" | ||
type="text" | ||
component={TextField} | ||
margin="none" | ||
variant="outlined" | ||
fullWidth | ||
/> | ||
<Field | ||
label="Second Name" | ||
name="SecondName" | ||
type="text" | ||
component={TextField} | ||
margin="normal" | ||
variant="outlined" | ||
fullWidth | ||
/> | ||
<Field | ||
label="Last Name" | ||
name="LastName" | ||
type="text" | ||
component={TextField} | ||
margin="normal" | ||
variant="outlined" | ||
fullWidth | ||
/> | ||
<Field | ||
label="Email" | ||
name="Email" | ||
type="text" | ||
component={TextField} | ||
margin="normal" | ||
variant="outlined" | ||
fullWidth | ||
/> | ||
<Button type="submit" variant="outlined" color="primary"> | ||
Register | ||
</Button>{" "} | ||
<Button type="reset" variant="outlined" color="secondary"> | ||
Reset | ||
</Button> | ||
</Form> | ||
)} | ||
></Formik> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from "react"; | ||
import gql from "graphql-tag"; | ||
import { useQuery } from "@apollo/react-hooks"; | ||
import { Card } from "@material-ui/core"; | ||
|
||
export const GET_CUSTOMERS = gql` | ||
{ | ||
Customers { | ||
ID | ||
FullName | ||
SecondName | ||
LastName | ||
FirstName | ||
} | ||
} | ||
`; | ||
|
||
export function Customers() { | ||
const { loading, error, data } = useQuery(GET_CUSTOMERS, { | ||
// pollInterval: 5000, //Call Function eache 5 seconds | ||
}); | ||
|
||
if (loading) return <p>Loading...</p>; | ||
if (error) return <p style={{ color: "red" }}> Error! ${error.message}`</p>; | ||
return ( | ||
<div id="viewCustomers"> | ||
<h5>LIST OF HUMANS</h5> | ||
{data.Customers.map((p, i) => ( | ||
<Card | ||
key={i} | ||
style={{ padding: "10px", margin: "5px" }} | ||
>{`${p.FirstName} ${p.SecondName} ${p.LastName}`}</Card> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.