Update layout and localization for improved functionality
- Added AsyncStorage and utility functions for future enhancements. - Commented out ServicesGrid component in HomeScreen for potential redesign. - Updated English and Russian localization files with new phrases and translations for prayer times and services.
This commit is contained in:
3
utils/api.ts
Normal file
3
utils/api.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const BASE_URL = 'http://127.0.0.1:8000/';
|
||||
|
||||
export const CURRENCY_RATES_ENDPOINT = 'api/v1/currency-rates';
|
||||
35
utils/makeRequest.ts
Normal file
35
utils/makeRequest.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { BASE_URL } from './api';
|
||||
|
||||
export const makeRequest = async <T,>(
|
||||
endpoint: string,
|
||||
options?: RequestInit
|
||||
): Promise<T> => {
|
||||
const url = new URL(endpoint, BASE_URL).toString();
|
||||
|
||||
try {
|
||||
const response = await fetch(url, options);
|
||||
console.log(response);
|
||||
|
||||
if (!response.ok) {
|
||||
let errorData;
|
||||
try {
|
||||
errorData = await response.json();
|
||||
} catch (e) {
|
||||
// Ignore JSON parsing errors if the body is empty
|
||||
}
|
||||
const errorMessage =
|
||||
errorData?.message ||
|
||||
`Request failed with status ${response.status}`;
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
if (response.status === 204) {
|
||||
return null as T;
|
||||
}
|
||||
|
||||
return response.json();
|
||||
} catch (error) {
|
||||
console.error('API request error:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user