Added scheduling routes for smart scheduling BOD-4

This commit is contained in:
Patrick Fic
2020-06-03 10:55:13 -07:00
parent d99dd89d67
commit 47f858920b
5 changed files with 115 additions and 8 deletions

View File

@@ -0,0 +1,47 @@
const GraphQLClient = require("graphql-request").GraphQLClient;
const path = require("path");
const queries = require("../graphql-client/queries");
const Dinero = require("dinero.js");
require("dotenv").config({
path: path.resolve(
process.cwd(),
`.env.${process.env.NODE_ENV || "development"}`
),
});
exports.job = async (req, res) => {
try {
const BearerToken = req.headers.authorization;
const { jobId } = req.body;
console.log("exports.job -> jobId", jobId);
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
headers: {
Authorization: BearerToken,
},
});
const result = await client
.setHeaders({ Authorization: BearerToken })
.request(queries.QUERY_UPCOMING_APPOINTMENTS, {
now: new Date(),
});
const possibleDates = [];
//Temp
possibleDates.push(new Date());
possibleDates.push(new Date());
possibleDates.push(new Date());
possibleDates.push(new Date());
possibleDates.push(new Date());
//Get a list of upcoming appointments
//Get the config for each day
res.json(possibleDates);
} catch (error) {
console.log("error", error);
res.status(400).send(error);
}
};