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

feat: Vendor verification #1208

Merged
merged 23 commits into from
Sep 25, 2024
Merged

feat: Vendor verification #1208

merged 23 commits into from
Sep 25, 2024

Conversation

stalgiag
Copy link
Contributor

@stalgiag stalgiag commented Sep 4, 2024

see #1201

This PR adds the Vendor table to the DB in order to store information about User -> Vendor and Vendor -> AT associations. With this PR, the User table has a "company" column that holds Vendors. For now, this is only used to prevent review of Candidate Test Plans unless the reviewer is either an admin or a representative of the vendor of the specified AT.

These changes could potentially enable other vendor-specific features in the future.

@stalgiag stalgiag marked this pull request as draft September 4, 2024 22:50
@stalgiag stalgiag marked this pull request as ready for review September 4, 2024 23:03
@stalgiag stalgiag requested a review from howard-e September 5, 2024 21:04
@stalgiag stalgiag changed the title Vendor verification feat: Vendor verification Sep 5, 2024
Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

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

Looks good! A lot of involved changes here but from my checks, seems very well handled. As you mention as well, this should certainly open a lot of intentional vendor related functionlity. Happy to see this get in!

I left only a minor comment inline but nothing blocking here, good stuff!

if (vendorEntry) {
const [, companyName] = vendorEntry.split('|');
const vendor = await findVendorByName({
name: companyName,
Copy link
Contributor

Choose a reason for hiding this comment

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

May want to trim this just in case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I added a trim()

* @param {*} options.transaction - Sequelize transaction
* @returns {Promise<*>}
*/
const addUserVendor = async (userId, vendorId, { transaction }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good handling of this (although the name puzzled me for a second, ha)! I immediately thought of the case where a vendor's company was incorrectly assigned and how it may be to have to resolve that. With this change, just updating the .txt and having them sign in again easily handles that!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I am not in love with the name but wasn't sure where best to move the term from "vendor" to "company" since a "vendor" attached to a person is their "company".

Comment on lines +26 to +33
// Check if the user's company is the vendor for the associated At
if (requireVendorForAt && !isAdmin) {
const isVendorForAt = company && company.ats.some(at => at.id === atId);
if (!isVendorForAt) {
return <Navigate to="/404" replace />;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏽 👍🏽

Comment on lines 831 to 835
company: {
id: '1',
name: 'Company',
ats: []
}
Copy link
Contributor

Choose a reason for hiding this comment

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

in the mock, would these need a company since the roles assigned here doesn't include 'VENDOR'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point! Addressed.

@stalgiag stalgiag merged commit b8b13d4 into development Sep 25, 2024
2 checks passed
@stalgiag stalgiag deleted the vendor-verification branch September 25, 2024 22:09
howard-e added a commit that referenced this pull request Oct 9, 2024
Create October 9, 2024 Release

Includes the following changes:
* #1214
* #1208, which addresses #1201
* #1225
* #1227, which addresses #1226
* #1224, which addresses #759
* #1229, which addresses #1228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants