fixing typescript config issue
This commit is contained in:
parent
64fd4b23c9
commit
851e756dc3
9 changed files with 29 additions and 24 deletions
|
@ -1,7 +1 @@
|
||||||
{
|
{"holidays":["2023-05-01","2023-06-12","2023-09-25"]}
|
||||||
"holidays": [
|
|
||||||
"2023-05-01",
|
|
||||||
"2023-06-12",
|
|
||||||
"2023-09-25"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,10 +1 @@
|
||||||
{
|
{"timeSlots":["08:00 - 10:00","10:00 - 12:00","12:00 - 14:00","14:00 - 16:00","16:00 - 18:00","18:00 - 20:00"]}
|
||||||
"timeSlots": [
|
|
||||||
"08:00 - 10:00",
|
|
||||||
"10:00 - 12:00",
|
|
||||||
"12:00 - 14:00",
|
|
||||||
"14:00 - 16:00",
|
|
||||||
"16:00 - 18:00",
|
|
||||||
"18:00 - 20:00"
|
|
||||||
]
|
|
||||||
}
|
|
7
src/data/holidays.json
Normal file
7
src/data/holidays.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"holidays": [
|
||||||
|
"2023-05-01",
|
||||||
|
"2023-06-12",
|
||||||
|
"2023-09-25"
|
||||||
|
]
|
||||||
|
}
|
10
src/data/timeSlots.json
Normal file
10
src/data/timeSlots.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"timeSlots": [
|
||||||
|
"08:00 - 10:00",
|
||||||
|
"10:00 - 12:00",
|
||||||
|
"12:00 - 14:00",
|
||||||
|
"14:00 - 16:00",
|
||||||
|
"16:00 - 18:00",
|
||||||
|
"18:00 - 20:00"
|
||||||
|
]
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ const GEOCODING_API_KEY = process.env.GEOCODING_API_KEY;
|
||||||
|
|
||||||
|
|
||||||
// will return at least - street, line1, line2, country, postcode
|
// will return at least - street, line1, line2, country, postcode
|
||||||
export const resolveAddress = async (searchTerm: string): Promise<void | Address> => {
|
export const resolveAddress = async (searchTerm: string): Promise<Address> => {
|
||||||
const response = await axios.get(`https://api.geoapify.com/v1/geocode/search?text=${searchTerm}&format=json&apiKey=${GEOCODING_API_KEY}`);
|
const response = await axios.get(`https://api.geoapify.com/v1/geocode/search?text=${searchTerm}&format=json&apiKey=${GEOCODING_API_KEY}`);
|
||||||
if (response.data.results.length > 0) {
|
if (response.data.results.length > 0) {
|
||||||
const result = response.data.results[0];
|
const result = response.data.results[0];
|
||||||
|
|
|
@ -3,16 +3,17 @@ import { resolveAddress } from './geocoding';
|
||||||
import { Address } from './types';
|
import { Address } from './types';
|
||||||
|
|
||||||
export const resolveAddressHandler = (req: Request, res: Response) => {
|
export const resolveAddressHandler = (req: Request, res: Response) => {
|
||||||
|
console.log("resolveAddressHandler called");
|
||||||
const address = resolveAddress(req.body.searchTerm);
|
const address: Promise<Address> = resolveAddress(req.body.searchTerm);
|
||||||
|
|
||||||
address.then((result) => {
|
address.then((result) => {
|
||||||
|
console.log("resolveAddressHandler result: ", result);
|
||||||
res.status(200).json(result);
|
res.status(200).json(result);
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
export const timeslotsHandler = (req: Request, res: Response) => {
|
export const timeslotsHandler = (req: Request, res: Response) => {
|
||||||
// TODO: Implement timeslots functionality
|
// TODO: Implement timeslots functionality
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deliveriesHandler = (req: Request, res: Response) => {
|
export const deliveriesHandler = (req: Request, res: Response) => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import holidays from '../../data/holidays.json';
|
import holidays from '../data/holidays.json';
|
||||||
|
|
||||||
export function getHolidays() {
|
export function getHolidays() {
|
||||||
// for demo resolving the promise immediately with mock data
|
// for demo resolving the promise immediately with mock data
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import timeSlots from '../../data/timeslots.json';
|
import timeSlots from '../data/timeslots.json';
|
||||||
|
|
||||||
export function getAvailableTimeSlots() {
|
export function getAvailableTimeSlots() {
|
||||||
// for demo resolving the promise immediately with mock data
|
// for demo resolving the promise immediately with mock data
|
||||||
|
|
2
src/types/index.js
Normal file
2
src/types/index.js
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
Loading…
Reference in a new issue