// app/services/userProfile.service.js const db = require("../../models"); const User = db.User; const Customer = db.Customer; const BusinessCustomer = db.BusinessCustomer; const getUserProfile = async (userId) => { const user = await User.findByPk(userId, { attributes: { exclude: ["password"], }, }); if (!user) { return null; } let accountDetails = null; if (user.accountType === "customer") { accountDetails = await Customer.findOne({ where: { user_id: user.id, }, }); } else if (user.accountType === "business_customer") { accountDetails = await BusinessCustomer.findOne({ where: { user_id: user.id, }, }); } return { user, accountDetails, }; }; module.exports = { getUserProfile, };