aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/database/main.go7
-rw-r--r--server/database/people.go19
-rw-r--r--server/main.go7
-rw-r--r--src/components/Form/Document/DocumentInfoForm.js22
-rw-r--r--src/components/Form/Items/AddNewItemForm.js3
-rw-r--r--src/components/Form/People/SelectClientForm.js20
6 files changed, 30 insertions, 48 deletions
diff --git a/server/database/main.go b/server/database/main.go
index de2365c..811a8eb 100644
--- a/server/database/main.go
+++ b/server/database/main.go
@@ -33,9 +33,10 @@ func StartDB() {
init_people, _ := myDatabase.Prepare(
`CREATE TABLE IF NOT EXISTS People
(id INTEGER PRIMARY KEY AUTOINCREMENT,
- Name TEXT,
- Phone TEXT,
- Email TEXT)`,
+ Name TEXT,
+ Address TEXT,
+ Phone TEXT,
+ Email TEXT)`,
)
init_people.Exec()
}
diff --git a/server/database/people.go b/server/database/people.go
index 01cbba8..e0930b0 100644
--- a/server/database/people.go
+++ b/server/database/people.go
@@ -14,10 +14,10 @@ import (
_ "github.com/mattn/go-sqlite3"
)
type Person struct {
- ID int
- Name string
- Phone string
- Email string
+ Name string
+ Address string
+ Phone string
+ Email string
}
func GetAllPeople() []Person {
@@ -27,13 +27,12 @@ func GetAllPeople() []Person {
)
var (
- name, phone, email string
- id int
+ name, address, phone, email string
)
for rows.Next() {
- rows.Scan(&id, &name, &phone, &email)
- allPeople = append(allPeople, Person{id, name, phone, email})
+ rows.Scan(&name, &address, &phone, &email)
+ allPeople = append(allPeople, Person{name, address, phone, email})
}
return allPeople
@@ -43,12 +42,12 @@ func RegisterPerson(person Person) bool {
register_person, _ := myDatabase.Prepare(
`INSERT INTO People
- (Name, Phone, Email)
+ (Name, Address, Phone, Email)
VALUES (?, ?, ?)`,
)
register_person.Exec(
- person.Name, person.Phone, person.Email,
+ person.Name, person.Address, person.Phone, person.Email,
)
return true
diff --git a/server/main.go b/server/main.go
index 8b400fe..e6c70e6 100644
--- a/server/main.go
+++ b/server/main.go
@@ -81,9 +81,10 @@ func getAllPeople(ctx *gin.Context) {
func registerPerson(ctx *gin.Context) {
person := db.Person {
- Name: ctx.Query("name"),
- Phone: ctx.Query("phone"),
- Email: ctx.Query("email"),
+ Name: ctx.Query("name"),
+ Address: ctx.Query("address"),
+ Phone: ctx.Query("phone"),
+ Email: ctx.Query("email"),
}
db.RegisterPerson(person)
diff --git a/src/components/Form/Document/DocumentInfoForm.js b/src/components/Form/Document/DocumentInfoForm.js
index 367d4f2..09bb9c6 100644
--- a/src/components/Form/Document/DocumentInfoForm.js
+++ b/src/components/Form/Document/DocumentInfoForm.js
@@ -12,29 +12,11 @@ import "./../Form.scss";
import SelectClientForm from "./../People/SelectClientForm";
-const DocumentInfoForm = (/*props*/) => {
- const savedPeople = [
- {
- ID: 1,
- Name: "one",
- Address: "Address Line 1"
- },
- {
- ID: 2,
- Name: "two",
- Address: "Address Line 1 Line2 Lelfjdlfj"
- },
- {
- ID: 3,
- Name: "three",
- Address: "ALinldfjlasjfe 1asdjflajdslfjsalkdjfdslkfjslkdfjlksjdflkjsdlkfjdlfjslkjfdlkadsflj"
- },
- ]
-
+const DocumentInfoForm = (props) => {
return (
<div className={"DocumentInfoForm"}>
<SelectClientForm
- savedPeople={savedPeople}
+ savedPeople={props.savedPeople}
/>
</div>
);
diff --git a/src/components/Form/Items/AddNewItemForm.js b/src/components/Form/Items/AddNewItemForm.js
index a4710f9..37167fd 100644
--- a/src/components/Form/Items/AddNewItemForm.js
+++ b/src/components/Form/Items/AddNewItemForm.js
@@ -39,7 +39,8 @@ const AddNewItemForm = (props) => {
const setItemInfo = (itemName) =>
(props.savedItems === null || itemName === registerItemPrompt)
? props.registerItemFormVisibility(true)
- : props.savedItems.some((i) => itemName === i.Model.toLowerCase() && applyItemInfo(i))
+ : props.savedItems.some((i) =>
+ itemName === i.Model.toLowerCase() && applyItemInfo(i))
const resetAllValues = () => {
setItemNameValue("");
diff --git a/src/components/Form/People/SelectClientForm.js b/src/components/Form/People/SelectClientForm.js
index 06704d7..4c1e056 100644
--- a/src/components/Form/People/SelectClientForm.js
+++ b/src/components/Form/People/SelectClientForm.js
@@ -18,18 +18,16 @@ const SelectClientForm = (props) => {
const enterValuePrompt = "start typing here";
const registerPrompt = "add new";
- const formatter = (i) => `${i.Name} - ${i.Address.slice(0, 20).concat(i.Address.len < 20 ? "" : "...")}`;
+ const formatter = (i) => {
+ return `${i.Name} - ${i.Address.slice(0, 20).concat(i.Address.length < 20 ? "" : "")}`;
+ }
// check the client name value and do stuff accordingly
- const setItemInfo = (clientName) =>
- props.savedPeople.some(
- (i) => clientName === formatter(i)
- ? setSelectedClient(i)
- : clientName === registerPrompt
- && alert("coming soon")
- )
-
- console.log(selectedClient)
+ const setClientInfo = (clientName) =>
+ (props.savedPeople === null || clientName === registerPrompt)
+ ? alert("coming soon") // toggle registerPersonPrompt visibility
+ : props.savedPeople.some((i) =>
+ clientName === formatter(i) && setSelectedClient(i))
return (
<div className={"DocumentInfoChild"}>
@@ -41,7 +39,7 @@ const SelectClientForm = (props) => {
onChange={
(event) => {
setClientName(event.target.value);
- setItemInfo(event.target.value);
+ setClientInfo(event.target.value);
}
}>
<option key={enterValuePrompt}>{enterValuePrompt}</option>