From 17da3934b1fc7b4a7cf49d7e07bf26966e124f1a Mon Sep 17 00:00:00 2001 From: Sacha Al Himdani Date: Mon, 26 May 2025 09:25:32 -0700 Subject: [PATCH] Fix vendor creation bug Signed-off-by: Sacha Al Himdani --- .../organizations/vendors/ListVendorView.tsx | 7 ++++ pkg/probo/vendor_service.go | 38 +++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/apps/console/src/pages/organizations/vendors/ListVendorView.tsx b/apps/console/src/pages/organizations/vendors/ListVendorView.tsx index f3bfc33bd..5cffa461b 100644 --- a/apps/console/src/pages/organizations/vendors/ListVendorView.tsx +++ b/apps/console/src/pages/organizations/vendors/ListVendorView.tsx @@ -408,6 +408,13 @@ function ListVendorContent({ "The vendor has been added successfully", }); }, + onError: (error) => { + toast({ + title: "Error", + description: error.message || "Failed to create vendor", + variant: "destructive", + }); + } }); }} > diff --git a/pkg/probo/vendor_service.go b/pkg/probo/vendor_service.go index d4e3c1fe3..e4b518ce4 100644 --- a/pkg/probo/vendor_service.go +++ b/pkg/probo/vendor_service.go @@ -270,30 +270,28 @@ func (s VendorService) Create( req CreateVendorRequest, ) (*coredata.Vendor, error) { now := time.Now() - var vendor *coredata.Vendor + vendor := &coredata.Vendor{ + ID: gid.New(s.svc.scope.GetTenantID(), coredata.VendorEntityType), + Name: req.Name, + CreatedAt: now, + UpdatedAt: now, + Description: req.Description, + HeadquarterAddress: req.HeadquarterAddress, + LegalName: req.LegalName, + WebsiteURL: req.WebsiteURL, + PrivacyPolicyURL: req.PrivacyPolicyURL, + ServiceLevelAgreementURL: req.ServiceLevelAgreementURL, + DataProcessingAgreementURL: req.DataProcessingAgreementURL, + Certifications: req.Certifications, + SecurityPageURL: req.SecurityPageURL, + TrustPageURL: req.TrustPageURL, + StatusPageURL: req.StatusPageURL, + TermsOfServiceURL: req.TermsOfServiceURL, + } err := s.svc.pg.WithTx( ctx, func(conn pg.Conn) error { - vendor := &coredata.Vendor{ - ID: gid.New(s.svc.scope.GetTenantID(), coredata.VendorEntityType), - Name: req.Name, - CreatedAt: now, - UpdatedAt: now, - Description: req.Description, - HeadquarterAddress: req.HeadquarterAddress, - LegalName: req.LegalName, - WebsiteURL: req.WebsiteURL, - PrivacyPolicyURL: req.PrivacyPolicyURL, - ServiceLevelAgreementURL: req.ServiceLevelAgreementURL, - DataProcessingAgreementURL: req.DataProcessingAgreementURL, - Certifications: req.Certifications, - SecurityPageURL: req.SecurityPageURL, - TrustPageURL: req.TrustPageURL, - StatusPageURL: req.StatusPageURL, - TermsOfServiceURL: req.TermsOfServiceURL, - } - organization := &coredata.Organization{} if err := organization.LoadByID(ctx, conn, s.svc.scope, req.OrganizationID); err != nil { return fmt.Errorf("cannot load organization %q: %w", req.OrganizationID, err)