Fix vendor creation bug
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -408,6 +408,13 @@ function ListVendorContent({
|
|||||||
"The vendor has been added successfully",
|
"The vendor has been added successfully",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
toast({
|
||||||
|
title: "Error",
|
||||||
|
description: error.message || "Failed to create vendor",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -270,30 +270,28 @@ func (s VendorService) Create(
|
|||||||
req CreateVendorRequest,
|
req CreateVendorRequest,
|
||||||
) (*coredata.Vendor, error) {
|
) (*coredata.Vendor, error) {
|
||||||
now := time.Now()
|
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(
|
err := s.svc.pg.WithTx(
|
||||||
ctx,
|
ctx,
|
||||||
func(conn pg.Conn) error {
|
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{}
|
organization := &coredata.Organization{}
|
||||||
if err := organization.LoadByID(ctx, conn, s.svc.scope, req.OrganizationID); err != nil {
|
if err := organization.LoadByID(ctx, conn, s.svc.scope, req.OrganizationID); err != nil {
|
||||||
return fmt.Errorf("cannot load organization %q: %w", req.OrganizationID, err)
|
return fmt.Errorf("cannot load organization %q: %w", req.OrganizationID, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user