-
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.
fix:moved requests to the server into a separate function
- Loading branch information
Runar
committed
Sep 2, 2022
1 parent
f3b5e5b
commit b1d3a43
Showing
11 changed files
with
72 additions
and
57 deletions.
There are no files selected for viewing
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,9 @@ | ||
export interface IContacts { | ||
address: string; | ||
tel: string; | ||
mail: string; | ||
href: string; | ||
workTime: string; | ||
employer: string; | ||
ip: string; | ||
} |
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
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
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 |
---|---|---|
|
@@ -31,4 +31,5 @@ | |
} | ||
.error { | ||
color: red; | ||
padding: 20px 0; | ||
} |
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
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,31 @@ | ||
import { useEffect, useState } from "react"; | ||
import { IListDropdown } from "../components/Dropdown/DropdownList/DropdownList"; | ||
import { IHeaderNavData } from "../components/Header/Header"; | ||
|
||
export const useRequest = (apiUrl: string) => { | ||
const [data, setData] = useState<IListDropdown[] & IHeaderNavData[]>([]); | ||
const [loading, setLoading] = useState(true); | ||
const [error, setError] = useState(false); | ||
|
||
useEffect(() => { | ||
const requestHandler = async () => { | ||
try { | ||
const request = await fetch(apiUrl); | ||
const response = await request.json(); | ||
setLoading(false); | ||
setData(response); | ||
} catch (error) { | ||
console.log(error); | ||
setError(true); | ||
setLoading(false); | ||
} | ||
}; | ||
requestHandler(); | ||
}, [apiUrl]); | ||
|
||
return { | ||
data, | ||
loading, | ||
error, | ||
}; | ||
}; |
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 |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
"mail": "[email protected]", | ||
"workTime": "Режим работы: 08:00-22:00", | ||
"employer": "ИП Шушкевич Андрей Викторович", | ||
"data": "УНП 192602485 Минским горисполкомом 10.02.2016" | ||
"ip": "УНП 192602485 Минским горисполкомом 10.02.2016" | ||
} |
b1d3a43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sdaem-by – ./
sdaem-by-one.vercel.app
sdaem-by-runarnazmutdinov-gmailcom.vercel.app
sdaem-by-git-master-runarnazmutdinov-gmailcom.vercel.app