Archived
Merge pull request #3 from JMR-dev/get_state
completed asinkrepair
This commit was merged in pull request #3.
This commit is contained in:
@@ -13,6 +13,34 @@
|
||||
"budget": "5000",
|
||||
"neededBy": "2021-12-05",
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"description": "test request",
|
||||
"address": "an address",
|
||||
"budget": "800",
|
||||
"neededBy": "2021-11-26",
|
||||
"id": 3
|
||||
},
|
||||
{
|
||||
"description": "testing123",
|
||||
"address": "488",
|
||||
"budget": "558",
|
||||
"neededBy": "2021-12-25",
|
||||
"id": 4
|
||||
},
|
||||
{
|
||||
"description": "testing123",
|
||||
"address": "488",
|
||||
"budget": "558",
|
||||
"neededBy": "2021-12-25",
|
||||
"id": 5
|
||||
},
|
||||
{
|
||||
"description": "another test",
|
||||
"address": "500",
|
||||
"budget": "30",
|
||||
"neededBy": "2021-11-30",
|
||||
"id": 6
|
||||
}
|
||||
],
|
||||
"employeeTable": [
|
||||
|
||||
+13
-15
@@ -5,6 +5,7 @@ const applicationState = {
|
||||
employeeTable:[],
|
||||
jobTable: []
|
||||
}
|
||||
const mainContainer = document.querySelector("#container")
|
||||
|
||||
export const fetchRequests = () => {
|
||||
return fetch(`${API}/serviceRequests`)
|
||||
@@ -49,24 +50,21 @@ export const sendRequest = (userServiceRequest) => {
|
||||
|
||||
|
||||
return fetch(`${API}/serviceRequests`, fetchOptions)
|
||||
.then(response => response.json())
|
||||
.then(() => {
|
||||
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(() => {
|
||||
mainContainer.dispatchEvent(new CustomEvent("stateChanged"))
|
||||
})
|
||||
}
|
||||
export const deleteRequest = (id) => {
|
||||
return fetch(`${API}/requests/${id}`, { method: "DELETE" })
|
||||
.then(
|
||||
() => {
|
||||
mainContainer.dispatchEvent(new CustomEvent("stateChanged"))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return fetch(`${API}/requests`, fetchOptions)
|
||||
.then(response => response.json())
|
||||
.then(() => {
|
||||
mainContainer.dispatchEvent(new CustomEvent("stateChanged"))
|
||||
})
|
||||
|
||||
mainContainer.addEventListener(
|
||||
"stateChanged",
|
||||
customEvent => {
|
||||
render()
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,5 +11,11 @@ const render = () => {
|
||||
}
|
||||
)
|
||||
}
|
||||
mainContainer.addEventListener(
|
||||
"stateChanged",
|
||||
customEvent => {
|
||||
render()
|
||||
}
|
||||
)
|
||||
|
||||
render()
|
||||
|
||||
Reference in New Issue
Block a user