-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from 4bujak-4bujak/feature/meetingroomQA
[feat] 미팅룸 추가작업
- Loading branch information
Showing
6 changed files
with
83 additions
and
50 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,37 @@ | ||
import { BranchDistanceResponse } from "../types/branch"; | ||
|
||
export const getBranchesByDistance = async (latitude: number, longitude: number): Promise<BranchDistanceResponse[]> => { | ||
const backendUrl = process.env.NEXT_PUBLIC_BASE_URL; | ||
const url = new URL(`${backendUrl}branches/distance`); | ||
|
||
// Add latitude and longitude as query parameters | ||
url.searchParams.append('latitude', String(latitude)); | ||
url.searchParams.append('longitude', String(longitude)); | ||
|
||
const token = document.cookie.replace(/(?:(?:^|.*;\s*)token\s*=\s*([^;]*).*$)|^.*$/, "$1"); | ||
|
||
if (!token) { | ||
throw new Error('No access token found'); | ||
} | ||
|
||
const response = await fetch(url.toString(), { | ||
method: 'GET', | ||
headers: { | ||
'Authorization': `Bearer ${token}`, | ||
'Content-Type': 'application/json' | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
const errorText = await response.text(); | ||
throw new Error(`Error fetching branches by distance: ${response.status} ${response.statusText} - ${errorText}`); | ||
} | ||
|
||
const data: { status: string; errorCode: string | null; data: BranchDistanceResponse[] } = await response.json(); | ||
|
||
if (data.status !== 'SUCCESS') { | ||
throw new Error(`API Error: ${data.errorCode}`); | ||
} | ||
|
||
return data.data; | ||
}; |
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