Fix cannot create vendor who is already suggested
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix cannot create vendor when the name is too similar to suggested one
|
||||||
|
|
||||||
## [0.5.0] - 2025-04-10
|
## [0.5.0] - 2025-04-10
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -272,83 +272,73 @@ function VendorListContent({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{searchTerm.trim() !== "" && (
|
{searchTerm.trim() !== "" && (
|
||||||
<>
|
<div
|
||||||
{filteredVendors.length > 0 ? (
|
style={{ borderRadius: "0.3rem" }}
|
||||||
<div
|
className="absolute top-full left-0 mt-1 w-[calc(100%-100px)] max-h-48 overflow-y-auto border bg-invert-bg shadow-md z-10"
|
||||||
style={{ borderRadius: "0.3rem" }}
|
>
|
||||||
className="absolute top-full left-0 mt-1 w-[calc(100%-100px)] max-h-48 overflow-y-auto border bg-invert-bg shadow-md z-10"
|
{filteredVendors.map((vendor: VendorItem) => (
|
||||||
>
|
<button
|
||||||
{filteredVendors.map((vendor: VendorItem) => (
|
key={vendor.id}
|
||||||
<button
|
className="w-full px-3 py-2 text-left bg-invert-bg hover:bg-h-subtle-bg"
|
||||||
key={vendor.id}
|
onClick={() => {
|
||||||
className="w-full px-3 py-2 text-left bg-invert-bg hover:bg-h-subtle-bg"
|
createVendor({
|
||||||
onClick={() => {
|
variables: {
|
||||||
createVendor({
|
connections: [vendorsConnection.vendors.__id],
|
||||||
variables: {
|
input: {
|
||||||
connections: [vendorsConnection.vendors.__id],
|
organizationId: data.organization.id,
|
||||||
input: {
|
name: vendor.name,
|
||||||
organizationId: data.organization.id,
|
description: "",
|
||||||
name: vendor.name,
|
serviceStartAt: new Date().toISOString(),
|
||||||
description: "",
|
serviceCriticality: "LOW",
|
||||||
serviceStartAt: new Date().toISOString(),
|
riskTier: "GENERAL",
|
||||||
serviceCriticality: "LOW",
|
},
|
||||||
riskTier: "GENERAL",
|
},
|
||||||
},
|
onCompleted() {
|
||||||
},
|
setSearchTerm("");
|
||||||
onCompleted() {
|
setFilteredVendors([]);
|
||||||
setSearchTerm("");
|
toast({
|
||||||
setFilteredVendors([]);
|
title: "Vendor added",
|
||||||
toast({
|
description:
|
||||||
title: "Vendor added",
|
"The vendor has been added successfully",
|
||||||
description:
|
|
||||||
"The vendor has been added successfully",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}}
|
},
|
||||||
>
|
});
|
||||||
{vendor.name}
|
}}
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div
|
|
||||||
style={{ borderRadius: "0.3rem" }}
|
|
||||||
className="absolute top-full left-0 mt-1 w-[calc(100%-100px)] border bg-level-0 shadow-md z-10"
|
|
||||||
>
|
>
|
||||||
<button
|
{vendor.name}
|
||||||
className="w-full px-3 py-2 text-left hover:bg-accent-bg flex items-center gap-2"
|
</button>
|
||||||
onClick={() => {
|
))}
|
||||||
createVendor({
|
<button
|
||||||
variables: {
|
className="w-full px-3 py-2 text-left hover:bg-h-subtle-bg flex items-center gap-2 border-t"
|
||||||
connections: [vendorsConnection.vendors.__id],
|
onClick={() => {
|
||||||
input: {
|
createVendor({
|
||||||
organizationId: data.organization.id,
|
variables: {
|
||||||
name: searchTerm.trim(),
|
connections: [vendorsConnection.vendors.__id],
|
||||||
description: "",
|
input: {
|
||||||
serviceStartAt: new Date().toISOString(),
|
organizationId: data.organization.id,
|
||||||
serviceCriticality: "LOW",
|
name: searchTerm.trim(),
|
||||||
riskTier: "GENERAL",
|
description: "",
|
||||||
},
|
serviceStartAt: new Date().toISOString(),
|
||||||
},
|
serviceCriticality: "LOW",
|
||||||
onCompleted() {
|
riskTier: "GENERAL",
|
||||||
setSearchTerm("");
|
},
|
||||||
setFilteredVendors([]);
|
},
|
||||||
toast({
|
onCompleted() {
|
||||||
title: "Vendor created",
|
setSearchTerm("");
|
||||||
description:
|
setFilteredVendors([]);
|
||||||
"The new vendor has been created successfully",
|
toast({
|
||||||
});
|
title: "Vendor created",
|
||||||
},
|
description:
|
||||||
|
"The new vendor has been created successfully",
|
||||||
});
|
});
|
||||||
}}
|
},
|
||||||
>
|
});
|
||||||
<span className="font-medium">Create new vendor:</span>{" "}
|
}}
|
||||||
{searchTerm}
|
>
|
||||||
</button>
|
<span className="font-medium">Create new vendor:</span>{" "}
|
||||||
</div>
|
{searchTerm}
|
||||||
)}
|
</button>
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user