Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FP-35 #37

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions api/client/clientModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,37 @@ const getEmailByClientId = async (id) => {
return db('email_addresses').where({ client_id: id }).first;
};

//FOR CLIENT PLACEHOLDER DOCUMENTS//
const getAllfinances = async () => {
return db('finances');
};
const getAllInsurance = async () => {
return db('insurance');
};
const getAllDocuments = async () => {
return db('documents');
};
const getAllContactPrefs = async () => {
return db('contact_preferences');
};
const getAllReferrals = async () => {
return db('referrals');
};
const getAllGoals = async () => {
return db('goals');
};
const getAllMostRecentEmploy = async () => {
return db('most_recent_employment');
};

module.exports = {
getAllReferrals,
getAllMostRecentEmploy,
getAllGoals,
getAllfinances,
getAllContactPrefs,
getAllDocuments,
getAllInsurance,
add,
findById,
findAll,
Expand Down
35 changes: 34 additions & 1 deletion api/client/clientRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Ethnicity = require('../ethnicities/ethnicitiesModel');
const EducationHistory = require('../education_histories/educationHistoriesModel');
const EmailAddress = require('../email_addresses/emailAddressesModel');
const PhoneNumber = require('../phone_numbers/phoneNumbersModel');

const PlaceHolder = require('./clientModel');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Smarsden007 : wondering why this is needed since you already have a 'Clients' var accessing the same model.

router.get('/', (req, res) => {
Clients.findAll(req.query)
.then((clients) => {
Expand All @@ -19,6 +19,39 @@ router.get('/', (req, res) => {
});
});

router.get('/placeholder', async (req, res) => {
try {
const [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering why some other tables related like 'phone_numbers', 'locations' , 'householders' , 'email_addresses' are missing here

finances,
insurance,
documents,
contact_preferences,
referrals,
goals,
most_recent_employment,
] = await Promise.all([
PlaceHolder.getAllfinances(req.query),
PlaceHolder.getAllInsurance(req.query),
PlaceHolder.getAllDocuments(req.query),
PlaceHolder.getAllContactPrefs(req.query),
PlaceHolder.getAllReferrals(req.query),
PlaceHolder.getAllGoals(req.query),
PlaceHolder.getAllMostRecentEmploy(req.query),
]);
res.status(200).json({
finances,
insurance,
documents,
contact_preferences,
referrals,
goals,
most_recent_employment,
});
} catch (error) {
res.status(500).json({ message: 'internal server error' });
}
});

router.get('/:id', (req, res) => {
Clients.findById(req.params.id)
.then((clients) => {
Expand Down
10 changes: 0 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.