Add vendor services

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-08-18 18:26:17 +02:00
parent 0262bd1c3d
commit 54c14a1816
25 changed files with 4638 additions and 68 deletions

View File

@@ -153,6 +153,7 @@ export const vendorNodeQuery = graphql`
...useVendorFormFragment
...VendorComplianceTabFragment
...VendorContactsTabFragment
...VendorServicesTabFragment
...VendorRiskAssessmentTabFragment
...VendorOverviewTabBusinessAssociateAgreementFragment
...VendorOverviewTabDataPrivacyAgreementFragment

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<b7911bef9124adb41e7337c903b4910f>>
* @generated SignedSource<<46bd8a339fe6fd05256df0b1f806e0bd>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -19,7 +19,7 @@ export type VendorGraphNodeQuery$data = {
readonly id?: string;
readonly name?: string;
readonly websiteUrl?: string | null | undefined;
readonly " $fragmentSpreads": FragmentRefs<"VendorComplianceTabFragment" | "VendorContactsTabFragment" | "VendorOverviewTabBusinessAssociateAgreementFragment" | "VendorOverviewTabDataPrivacyAgreementFragment" | "VendorRiskAssessmentTabFragment" | "useVendorFormFragment">;
readonly " $fragmentSpreads": FragmentRefs<"VendorComplianceTabFragment" | "VendorContactsTabFragment" | "VendorOverviewTabBusinessAssociateAgreementFragment" | "VendorOverviewTabDataPrivacyAgreementFragment" | "VendorRiskAssessmentTabFragment" | "VendorServicesTabFragment" | "useVendorFormFragment">;
};
readonly viewer: {
readonly user: {
@@ -99,63 +99,70 @@ v8 = {
"name": "__typename",
"storageKey": null
},
v9 = [
v9 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
v10 = [
{
"kind": "Literal",
"name": "first",
"value": 50
}
],
v10 = {
v11 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "validUntil",
"storageKey": null
},
v11 = {
v12 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fileUrl",
"storageKey": null
},
v12 = {
v13 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
},
v13 = {
v14 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
},
v14 = {
v15 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
},
v15 = {
v16 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasPreviousPage",
"storageKey": null
},
v16 = {
v17 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "startCursor",
"storageKey": null
},
v17 = {
v18 = {
"alias": null,
"args": null,
"concreteType": "PageInfo",
@@ -163,14 +170,14 @@ v17 = {
"name": "pageInfo",
"plural": false,
"selections": [
(v13/*: any*/),
(v14/*: any*/),
(v15/*: any*/),
(v16/*: any*/)
(v16/*: any*/),
(v17/*: any*/)
],
"storageKey": null
},
v18 = {
v19 = {
"kind": "ClientExtension",
"selections": [
{
@@ -182,24 +189,31 @@ v18 = {
}
]
},
v19 = [
v20 = [
"orderBy"
],
v20 = {
v21 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
v21 = {
v22 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
v22 = [
v23 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
},
v24 = [
(v3/*: any*/),
{
"alias": null,
@@ -208,7 +222,7 @@ v22 = [
"name": "fileName",
"storageKey": null
},
(v11/*: any*/),
(v12/*: any*/),
{
"alias": null,
"args": null,
@@ -216,8 +230,8 @@ v22 = [
"name": "validFrom",
"storageKey": null
},
(v10/*: any*/),
(v21/*: any*/)
(v11/*: any*/),
(v22/*: any*/)
];
return {
"fragment": {
@@ -258,6 +272,11 @@ return {
"kind": "FragmentSpread",
"name": "VendorContactsTabFragment"
},
{
"args": null,
"kind": "FragmentSpread",
"name": "VendorServicesTabFragment"
},
{
"args": null,
"kind": "FragmentSpread",
@@ -331,13 +350,7 @@ return {
"selections": [
(v4/*: any*/),
(v5/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
(v9/*: any*/),
{
"alias": null,
"args": null,
@@ -430,7 +443,7 @@ return {
},
{
"alias": null,
"args": (v9/*: any*/),
"args": (v10/*: any*/),
"concreteType": "VendorComplianceReportConnection",
"kind": "LinkedField",
"name": "complianceReports",
@@ -460,7 +473,7 @@ return {
"name": "reportDate",
"storageKey": null
},
(v10/*: any*/),
(v11/*: any*/),
{
"alias": null,
"args": null,
@@ -468,7 +481,7 @@ return {
"name": "reportName",
"storageKey": null
},
(v11/*: any*/),
(v12/*: any*/),
{
"alias": null,
"args": null,
@@ -480,19 +493,19 @@ return {
],
"storageKey": null
},
(v12/*: any*/)
(v13/*: any*/)
],
"storageKey": null
},
(v17/*: any*/),
(v18/*: any*/)
(v18/*: any*/),
(v19/*: any*/)
],
"storageKey": "complianceReports(first:50)"
},
{
"alias": null,
"args": (v9/*: any*/),
"filters": (v19/*: any*/),
"args": (v10/*: any*/),
"filters": (v20/*: any*/),
"handle": "connection",
"key": "VendorComplianceTabFragment_complianceReports",
"kind": "LinkedHandle",
@@ -500,7 +513,7 @@ return {
},
{
"alias": null,
"args": (v9/*: any*/),
"args": (v10/*: any*/),
"concreteType": "VendorContactConnection",
"kind": "LinkedField",
"name": "contacts",
@@ -523,7 +536,7 @@ return {
"plural": false,
"selections": [
(v3/*: any*/),
(v20/*: any*/),
(v21/*: any*/),
{
"alias": null,
"args": null,
@@ -545,31 +558,25 @@ return {
"name": "role",
"storageKey": null
},
(v21/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
},
(v22/*: any*/),
(v23/*: any*/),
(v8/*: any*/)
],
"storageKey": null
},
(v12/*: any*/)
(v13/*: any*/)
],
"storageKey": null
},
(v17/*: any*/),
(v18/*: any*/)
(v18/*: any*/),
(v19/*: any*/)
],
"storageKey": "contacts(first:50)"
},
{
"alias": null,
"args": (v9/*: any*/),
"filters": (v19/*: any*/),
"args": (v10/*: any*/),
"filters": (v20/*: any*/),
"handle": "connection",
"key": "VendorContactsTabFragment_contacts",
"kind": "LinkedHandle",
@@ -577,7 +584,58 @@ return {
},
{
"alias": null,
"args": (v9/*: any*/),
"args": (v10/*: any*/),
"concreteType": "VendorServiceConnection",
"kind": "LinkedField",
"name": "services",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorServiceEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorService",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v3/*: any*/),
(v4/*: any*/),
(v9/*: any*/),
(v22/*: any*/),
(v23/*: any*/),
(v8/*: any*/)
],
"storageKey": null
},
(v13/*: any*/)
],
"storageKey": null
},
(v18/*: any*/),
(v19/*: any*/)
],
"storageKey": "services(first:50)"
},
{
"alias": null,
"args": (v10/*: any*/),
"filters": (v20/*: any*/),
"handle": "connection",
"key": "VendorServicesTabFragment_services",
"kind": "LinkedHandle",
"name": "services"
},
{
"alias": null,
"args": (v10/*: any*/),
"concreteType": "VendorRiskAssessmentConnection",
"kind": "LinkedField",
"name": "riskAssessments",
@@ -616,7 +674,7 @@ return {
"plural": false,
"selections": [
(v3/*: any*/),
(v20/*: any*/)
(v21/*: any*/)
],
"storageKey": null
},
@@ -652,7 +710,7 @@ return {
],
"storageKey": null
},
(v12/*: any*/)
(v13/*: any*/)
],
"storageKey": null
},
@@ -664,21 +722,21 @@ return {
"name": "pageInfo",
"plural": false,
"selections": [
(v14/*: any*/),
(v13/*: any*/),
(v15/*: any*/),
(v16/*: any*/)
(v14/*: any*/),
(v16/*: any*/),
(v17/*: any*/)
],
"storageKey": null
},
(v18/*: any*/)
(v19/*: any*/)
],
"storageKey": "riskAssessments(first:50)"
},
{
"alias": null,
"args": (v9/*: any*/),
"filters": (v19/*: any*/),
"args": (v10/*: any*/),
"filters": (v20/*: any*/),
"handle": "connection",
"key": "VendorRiskAssessmentTabFragment_riskAssessments",
"kind": "LinkedHandle",
@@ -691,7 +749,7 @@ return {
"kind": "LinkedField",
"name": "businessAssociateAgreement",
"plural": false,
"selections": (v22/*: any*/),
"selections": (v24/*: any*/),
"storageKey": null
},
{
@@ -701,7 +759,7 @@ return {
"kind": "LinkedField",
"name": "dataPrivacyAgreement",
"plural": false,
"selections": (v22/*: any*/),
"selections": (v24/*: any*/),
"storageKey": null
}
],
@@ -739,16 +797,16 @@ return {
]
},
"params": {
"cacheID": "5e87c78ed85f28f7390e2aada6c241e8",
"cacheID": "7e1a7455861aea37eee2d799d8385586",
"id": null,
"metadata": {},
"name": "VendorGraphNodeQuery",
"operationKind": "query",
"text": "query VendorGraphNodeQuery(\n $vendorId: ID!\n $organizationId: ID!\n) {\n node(id: $vendorId) {\n __typename\n ... on Vendor {\n id\n name\n websiteUrl\n ...useVendorFormFragment\n ...VendorComplianceTabFragment\n ...VendorContactsTabFragment\n ...VendorRiskAssessmentTabFragment\n ...VendorOverviewTabBusinessAssociateAgreementFragment\n ...VendorOverviewTabDataPrivacyAgreementFragment\n }\n id\n }\n viewer {\n user {\n people(organizationId: $organizationId) {\n id\n }\n id\n }\n id\n }\n}\n\nfragment VendorComplianceTabFragment on Vendor {\n complianceReports(first: 50) {\n edges {\n node {\n id\n ...VendorComplianceTabFragment_report\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment VendorComplianceTabFragment_report on VendorComplianceReport {\n id\n reportDate\n validUntil\n reportName\n fileUrl\n fileSize\n}\n\nfragment VendorContactsTabFragment on Vendor {\n contacts(first: 50) {\n edges {\n node {\n id\n ...VendorContactsTabFragment_contact\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment VendorContactsTabFragment_contact on VendorContact {\n id\n fullName\n email\n phone\n role\n createdAt\n updatedAt\n}\n\nfragment VendorOverviewTabBusinessAssociateAgreementFragment on Vendor {\n businessAssociateAgreement {\n id\n fileName\n fileUrl\n validFrom\n validUntil\n createdAt\n }\n}\n\nfragment VendorOverviewTabDataPrivacyAgreementFragment on Vendor {\n dataPrivacyAgreement {\n id\n fileName\n fileUrl\n validFrom\n validUntil\n createdAt\n }\n}\n\nfragment VendorRiskAssessmentTabFragment on Vendor {\n id\n riskAssessments(first: 50) {\n edges {\n node {\n id\n ...VendorRiskAssessmentTabFragment_assessment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment VendorRiskAssessmentTabFragment_assessment on VendorRiskAssessment {\n id\n assessedAt\n assessedBy {\n id\n fullName\n }\n expiresAt\n dataSensitivity\n businessImpact\n notes\n}\n\nfragment useVendorFormFragment on Vendor {\n id\n name\n description\n statusPageUrl\n termsOfServiceUrl\n privacyPolicyUrl\n serviceLevelAgreementUrl\n dataProcessingAgreementUrl\n websiteUrl\n legalName\n headquarterAddress\n certifications\n securityPageUrl\n trustPageUrl\n businessOwner {\n id\n }\n securityOwner {\n id\n }\n}\n"
"text": "query VendorGraphNodeQuery(\n $vendorId: ID!\n $organizationId: ID!\n) {\n node(id: $vendorId) {\n __typename\n ... on Vendor {\n id\n name\n websiteUrl\n ...useVendorFormFragment\n ...VendorComplianceTabFragment\n ...VendorContactsTabFragment\n ...VendorServicesTabFragment\n ...VendorRiskAssessmentTabFragment\n ...VendorOverviewTabBusinessAssociateAgreementFragment\n ...VendorOverviewTabDataPrivacyAgreementFragment\n }\n id\n }\n viewer {\n user {\n people(organizationId: $organizationId) {\n id\n }\n id\n }\n id\n }\n}\n\nfragment VendorComplianceTabFragment on Vendor {\n complianceReports(first: 50) {\n edges {\n node {\n id\n ...VendorComplianceTabFragment_report\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment VendorComplianceTabFragment_report on VendorComplianceReport {\n id\n reportDate\n validUntil\n reportName\n fileUrl\n fileSize\n}\n\nfragment VendorContactsTabFragment on Vendor {\n contacts(first: 50) {\n edges {\n node {\n id\n ...VendorContactsTabFragment_contact\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment VendorContactsTabFragment_contact on VendorContact {\n id\n fullName\n email\n phone\n role\n createdAt\n updatedAt\n}\n\nfragment VendorOverviewTabBusinessAssociateAgreementFragment on Vendor {\n businessAssociateAgreement {\n id\n fileName\n fileUrl\n validFrom\n validUntil\n createdAt\n }\n}\n\nfragment VendorOverviewTabDataPrivacyAgreementFragment on Vendor {\n dataPrivacyAgreement {\n id\n fileName\n fileUrl\n validFrom\n validUntil\n createdAt\n }\n}\n\nfragment VendorRiskAssessmentTabFragment on Vendor {\n id\n riskAssessments(first: 50) {\n edges {\n node {\n id\n ...VendorRiskAssessmentTabFragment_assessment\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment VendorRiskAssessmentTabFragment_assessment on VendorRiskAssessment {\n id\n assessedAt\n assessedBy {\n id\n fullName\n }\n expiresAt\n dataSensitivity\n businessImpact\n notes\n}\n\nfragment VendorServicesTabFragment on Vendor {\n services(first: 50) {\n edges {\n node {\n id\n ...VendorServicesTabFragment_service\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment VendorServicesTabFragment_service on VendorService {\n id\n name\n description\n createdAt\n updatedAt\n}\n\nfragment useVendorFormFragment on Vendor {\n id\n name\n description\n statusPageUrl\n termsOfServiceUrl\n privacyPolicyUrl\n serviceLevelAgreementUrl\n dataProcessingAgreementUrl\n websiteUrl\n legalName\n headquarterAddress\n certifications\n securityPageUrl\n trustPageUrl\n businessOwner {\n id\n }\n securityOwner {\n id\n }\n}\n"
}
};
})();
(node as any).hash = "82f82a56df0ea5b755937ebcc55c1382";
(node as any).hash = "1eac0bd4bc5eccf51ea024d27f348e14";
export default node;

View File

@@ -117,6 +117,11 @@ export default function VendorDetailPage(props: Props) {
>
{__("Contacts")}
</TabLink>
<TabLink
to={`/organizations/${organizationId}/vendors/${vendor.id}/services`}
>
{__("Services")}
</TabLink>
</Tabs>
<Outlet context={{ vendor, peopleId: data.viewer.user.people!.id }} />

View File

@@ -0,0 +1,123 @@
import { useTranslate } from "@probo/i18n";
import {
Breadcrumb,
Button,
Dialog,
DialogContent,
DialogFooter,
Field,
useDialogRef,
} from "@probo/ui";
import { cleanFormData } from "@probo/helpers";
import { type ReactNode } from "react";
import { graphql } from "relay-runtime";
import { useMutationWithToasts } from "/hooks/useMutationWithToasts";
import { z } from "zod";
import { useFormWithSchema } from "/hooks/useFormWithSchema";
type Props = {
children: ReactNode;
connectionId: string;
vendorId: string;
};
const createServiceMutation = graphql`
mutation CreateServiceDialogMutation(
$input: CreateVendorServiceInput!
$connections: [ID!]!
) {
createVendorService(input: $input) {
vendorServiceEdge @prependEdge(connections: $connections) {
node {
...VendorServicesTabFragment_service
}
}
}
}
`;
export function CreateServiceDialog({
children,
connectionId,
vendorId,
}: Props) {
const { __ } = useTranslate();
const schema = z.object({
name: z.string().min(1, __("Service name is required")),
description: z.string().optional(),
});
const { register, handleSubmit, formState, reset } = useFormWithSchema(
schema,
{
defaultValues: {
name: "",
description: "",
},
}
);
const [createService, isLoading] = useMutationWithToasts(
createServiceMutation,
{
successMessage: __("Service created successfully."),
errorMessage: __("Failed to create service. Please try again."),
}
);
const onSubmit = handleSubmit((data) => {
const cleanData = cleanFormData(data);
createService({
variables: {
input: {
vendorId,
...cleanData,
},
connections: [connectionId],
},
onSuccess: () => {
dialogRef.current?.close();
reset();
},
});
});
const dialogRef = useDialogRef();
return (
<Dialog
className="max-w-lg"
ref={dialogRef}
trigger={children}
title={
<Breadcrumb items={[__("Services"), __("New Service")]} />
}
>
<form onSubmit={onSubmit}>
<DialogContent padded className="space-y-4">
<Field
label={__("Name")}
{...register("name")}
type="text"
error={formState.errors.name?.message}
placeholder={__("Service name")}
required
/>
<Field
label={__("Description")}
{...register("description")}
type="textarea"
error={formState.errors.description?.message}
placeholder={__("Brief description of the service")}
/>
</DialogContent>
<DialogFooter>
<Button type="submit" disabled={isLoading}>
{__("Create")}
</Button>
</DialogFooter>
</form>
</Dialog>
);
}

View File

@@ -0,0 +1,120 @@
import { useTranslate } from "@probo/i18n";
import {
Breadcrumb,
Button,
Dialog,
DialogContent,
DialogFooter,
Field,
useDialogRef,
} from "@probo/ui";
import { cleanFormData } from "@probo/helpers";
import { useEffect } from "react";
import { graphql } from "relay-runtime";
import { useMutationWithToasts } from "/hooks/useMutationWithToasts";
import { z } from "zod";
import { useFormWithSchema } from "/hooks/useFormWithSchema";
type Props = {
serviceId: string;
service: {
name: string;
description?: string | null;
};
onClose: () => void;
};
const updateServiceMutation = graphql`
mutation EditServiceDialogUpdateMutation($input: UpdateVendorServiceInput!) {
updateVendorService(input: $input) {
vendorService {
...VendorServicesTabFragment_service
}
}
}
`;
export function EditServiceDialog({ serviceId, service, onClose }: Props) {
const { __ } = useTranslate();
const schema = z.object({
name: z.string().min(1, __("Service name is required")),
description: z.string().optional(),
});
const { register, handleSubmit, formState } = useFormWithSchema(
schema,
{
defaultValues: {
name: service.name || "",
description: service.description || "",
},
}
);
const [updateService, isLoading] = useMutationWithToasts(
updateServiceMutation,
{
successMessage: __("Service updated successfully."),
errorMessage: __("Failed to update service. Please try again."),
}
);
const onSubmit = handleSubmit((data) => {
const cleanData = cleanFormData(data);
updateService({
variables: {
input: {
id: serviceId,
...cleanData,
},
},
onSuccess: () => {
onClose();
},
});
});
const dialogRef = useDialogRef();
useEffect(() => {
dialogRef.current?.open();
}, []);
return (
<Dialog
className="max-w-lg"
ref={dialogRef}
onClose={onClose}
title={
<Breadcrumb items={[__("Services"), __("Edit Service")]} />
}
>
<form onSubmit={onSubmit}>
<DialogContent padded className="space-y-4">
<Field
label={__("Name")}
{...register("name")}
type="text"
error={formState.errors.name?.message}
placeholder={__("Service name")}
required
/>
<Field
label={__("Description")}
{...register("description")}
type="textarea"
error={formState.errors.description?.message}
placeholder={__("Brief description of the service")}
/>
</DialogContent>
<DialogFooter>
<Button type="submit" disabled={isLoading}>
{__("Save")}
</Button>
</DialogFooter>
</form>
</Dialog>
);
}

View File

@@ -0,0 +1,216 @@
/**
* @generated SignedSource<<57cf7bb390b9d8d00ce0368cf782205c>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type CreateVendorServiceInput = {
description?: string | null | undefined;
name: string;
type?: string | null | undefined;
url?: string | null | undefined;
vendorId: string;
};
export type CreateServiceDialogMutation$variables = {
connections: ReadonlyArray<string>;
input: CreateVendorServiceInput;
};
export type CreateServiceDialogMutation$data = {
readonly createVendorService: {
readonly vendorServiceEdge: {
readonly node: {
readonly " $fragmentSpreads": FragmentRefs<"VendorServicesTabFragment_service">;
};
};
};
};
export type CreateServiceDialogMutation = {
response: CreateServiceDialogMutation$data;
variables: CreateServiceDialogMutation$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "connections"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
},
v2 = [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
];
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "CreateServiceDialogMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "CreateVendorServicePayload",
"kind": "LinkedField",
"name": "createVendorService",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorServiceEdge",
"kind": "LinkedField",
"name": "vendorServiceEdge",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorService",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"args": null,
"kind": "FragmentSpread",
"name": "VendorServicesTabFragment_service"
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"kind": "Operation",
"name": "CreateServiceDialogMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "CreateVendorServicePayload",
"kind": "LinkedField",
"name": "createVendorService",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorServiceEdge",
"kind": "LinkedField",
"name": "vendorServiceEdge",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorService",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"filters": null,
"handle": "prependEdge",
"key": "",
"kind": "LinkedHandle",
"name": "vendorServiceEdge",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "c4c687377eb1a18eb15abbfa1bf86bfa",
"id": null,
"metadata": {},
"name": "CreateServiceDialogMutation",
"operationKind": "mutation",
"text": "mutation CreateServiceDialogMutation(\n $input: CreateVendorServiceInput!\n) {\n createVendorService(input: $input) {\n vendorServiceEdge {\n node {\n ...VendorServicesTabFragment_service\n id\n }\n }\n }\n}\n\nfragment VendorServicesTabFragment_service on VendorService {\n id\n name\n description\n createdAt\n updatedAt\n}\n"
}
};
})();
(node as any).hash = "8dd0e535bfa15e8ac78b630139b57177";
export default node;

View File

@@ -0,0 +1,166 @@
/**
* @generated SignedSource<<97f0c6ed319e3fba440079ef085a55eb>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type UpdateVendorServiceInput = {
description?: string | null | undefined;
id: string;
name?: string | null | undefined;
type?: string | null | undefined;
url?: string | null | undefined;
};
export type EditServiceDialogUpdateMutation$variables = {
input: UpdateVendorServiceInput;
};
export type EditServiceDialogUpdateMutation$data = {
readonly updateVendorService: {
readonly vendorService: {
readonly " $fragmentSpreads": FragmentRefs<"VendorServicesTabFragment_service">;
};
};
};
export type EditServiceDialogUpdateMutation = {
response: EditServiceDialogUpdateMutation$data;
variables: EditServiceDialogUpdateMutation$variables;
};
const node: ConcreteRequest = (function(){
var v0 = [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
}
],
v1 = [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
];
return {
"fragment": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Fragment",
"metadata": null,
"name": "EditServiceDialogUpdateMutation",
"selections": [
{
"alias": null,
"args": (v1/*: any*/),
"concreteType": "UpdateVendorServicePayload",
"kind": "LinkedField",
"name": "updateVendorService",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorService",
"kind": "LinkedField",
"name": "vendorService",
"plural": false,
"selections": [
{
"args": null,
"kind": "FragmentSpread",
"name": "VendorServicesTabFragment_service"
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Operation",
"name": "EditServiceDialogUpdateMutation",
"selections": [
{
"alias": null,
"args": (v1/*: any*/),
"concreteType": "UpdateVendorServicePayload",
"kind": "LinkedField",
"name": "updateVendorService",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorService",
"kind": "LinkedField",
"name": "vendorService",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "f2c37fa9a0b7f0ed043a4529d1f50c65",
"id": null,
"metadata": {},
"name": "EditServiceDialogUpdateMutation",
"operationKind": "mutation",
"text": "mutation EditServiceDialogUpdateMutation(\n $input: UpdateVendorServiceInput!\n) {\n updateVendorService(input: $input) {\n vendorService {\n ...VendorServicesTabFragment_service\n id\n }\n }\n}\n\nfragment VendorServicesTabFragment_service on VendorService {\n id\n name\n description\n createdAt\n updatedAt\n}\n"
}
};
})();
(node as any).hash = "8a34720f5ae7e1f5c619518d4e0db460";
export default node;

View File

@@ -120,7 +120,6 @@ export default function VendorContactsTab() {
<SortableTh field="EMAIL">{__("Email")}</SortableTh>
<Th>{__("Phone")}</Th>
<Th>{__("Role")}</Th>
<SortableTh field="CREATED_AT">{__("Created")}</SortableTh>
<Th>{__("Actions")}</Th>
</Tr>
</Thead>
@@ -165,7 +164,6 @@ function ContactRow(props: ContactRowProps) {
contactFragment,
props.contactKey
);
const { dateFormat } = useTranslate();
const confirm = useConfirm();
const [deleteContact] = useMutationWithToasts(deleteContactMutation, {
successMessage: __("Contact deleted successfully"),
@@ -222,7 +220,6 @@ function ContactRow(props: ContactRowProps) {
)}
</Td>
<Td>{contact.role || __("—")}</Td>
<Td>{dateFormat(contact.createdAt)}</Td>
<Td width={50} className="text-end">
<ActionDropdown>
<DropdownItem

View File

@@ -0,0 +1,214 @@
import { useOutletContext } from "react-router";
import { graphql } from "relay-runtime";
import type { VendorServicesTabFragment$key } from "./__generated__/VendorServicesTabFragment.graphql";
import { useTranslate } from "@probo/i18n";
import { usePageTitle } from "@probo/hooks";
import {
ActionDropdown,
Button,
DropdownItem,
IconPlusLarge,
IconTrashCan,
IconPencil,
PageHeader,
Tbody,
Td,
Th,
Thead,
Tr,
useConfirm,
} from "@probo/ui";
import { useFragment, useRefetchableFragment } from "react-relay";
import type { VendorServicesTabFragment_service$key } from "./__generated__/VendorServicesTabFragment_service.graphql";
import { useMutationWithToasts } from "/hooks/useMutationWithToasts";
import { sprintf } from "@probo/helpers";
import { SortableTable, SortableTh } from "/components/SortableTable";
import { CreateServiceDialog } from "../dialogs/CreateServiceDialog";
import { EditServiceDialog } from "../dialogs/EditServiceDialog";
import { useState } from "react";
export const vendorServicesFragment = graphql`
fragment VendorServicesTabFragment on Vendor
@refetchable(queryName: "VendorServicesListQuery")
@argumentDefinitions(
first: { type: "Int", defaultValue: 50 }
order: { type: "VendorServiceOrder", defaultValue: null }
after: { type: "CursorKey", defaultValue: null }
before: { type: "CursorKey", defaultValue: null }
last: { type: "Int", defaultValue: null }
) {
services(
first: $first
after: $after
last: $last
before: $before
orderBy: $order
) @connection(key: "VendorServicesTabFragment_services") {
__id
edges {
node {
id
...VendorServicesTabFragment_service
}
}
}
}
`;
const serviceFragment = graphql`
fragment VendorServicesTabFragment_service on VendorService {
id
name
description
createdAt
updatedAt
}
`;
const deleteServiceMutation = graphql`
mutation VendorServicesTabDeleteServiceMutation(
$input: DeleteVendorServiceInput!
$connections: [ID!]!
) {
deleteVendorService(input: $input) {
deletedVendorServiceId @deleteEdge(connections: $connections)
}
}
`;
export default function VendorServicesTab() {
const { vendor } = useOutletContext<{
vendor: VendorServicesTabFragment$key & { name: string; id: string };
}>();
const [data, refetch] = useRefetchableFragment(
vendorServicesFragment,
vendor
);
const connectionId = data.services.__id;
const services = data.services.edges.map((edge) => edge.node);
const { __ } = useTranslate();
const [editingService, setEditingService] = useState<{
id: string;
name: string;
description?: string | null;
} | null>(null);
usePageTitle(vendor.name + " - " + __("Services"));
return (
<div className="space-y-6">
<PageHeader
title={__("Services")}
description={__("Manage services provided by this vendor.")}
>
<CreateServiceDialog
vendorId={vendor.id}
connectionId={connectionId}
>
<Button icon={IconPlusLarge}>{__("Add service")}</Button>
</CreateServiceDialog>
</PageHeader>
<SortableTable refetch={refetch}>
<Thead>
<Tr>
<SortableTh field="NAME">{__("Name")}</SortableTh>
<Th>{__("Description")}</Th>
<Th>{__("Actions")}</Th>
</Tr>
</Thead>
<Tbody>
{services.map((service) => (
<ServiceRow
key={service.id}
serviceKey={service}
connectionId={connectionId}
onEdit={setEditingService}
/>
))}
</Tbody>
</SortableTable>
{editingService && (
<EditServiceDialog
serviceId={editingService.id}
service={editingService}
onClose={() => setEditingService(null)}
/>
)}
</div>
);
}
type ServiceRowProps = {
serviceKey: VendorServicesTabFragment_service$key;
connectionId: string;
onEdit: (service: {
id: string;
name: string;
description?: string | null;
}) => void;
};
function ServiceRow(props: ServiceRowProps) {
const { __ } = useTranslate();
const service = useFragment<VendorServicesTabFragment_service$key>(
serviceFragment,
props.serviceKey
);
const confirm = useConfirm();
const [deleteService] = useMutationWithToasts(deleteServiceMutation, {
successMessage: __("Service deleted successfully"),
errorMessage: __("Failed to delete service"),
});
const handleDelete = () => {
confirm(
() =>
deleteService({
variables: {
connections: [props.connectionId],
input: {
vendorServiceId: service.id,
},
},
}),
{
message: sprintf(
__(
'This will permanently delete the service "%s". This action cannot be undone.'
),
service.name
),
}
);
};
return (
<Tr>
<Td>{service.name}</Td>
<Td>{service.description || __("—")}</Td>
<Td width={50} className="text-end">
<ActionDropdown>
<DropdownItem
icon={IconPencil}
onClick={() => props.onEdit({
id: service.id,
name: service.name,
description: service.description,
})}
>
{__("Edit")}
</DropdownItem>
<DropdownItem
icon={IconTrashCan}
onClick={handleDelete}
variant="danger"
>
{__("Delete")}
</DropdownItem>
</ActionDropdown>
</Td>
</Tr>
);
}

View File

@@ -0,0 +1,344 @@
/**
* @generated SignedSource<<e3bc26d270857dd70a2fb548de99d86f>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type OrderDirection = "ASC" | "DESC";
export type VendorServiceOrderField = "CREATED_AT" | "NAME";
export type VendorServiceOrder = {
direction: OrderDirection;
field: VendorServiceOrderField;
};
export type VendorServicesListQuery$variables = {
after?: any | null | undefined;
before?: any | null | undefined;
first?: number | null | undefined;
id: string;
last?: number | null | undefined;
order?: VendorServiceOrder | null | undefined;
};
export type VendorServicesListQuery$data = {
readonly node: {
readonly " $fragmentSpreads": FragmentRefs<"VendorServicesTabFragment">;
};
};
export type VendorServicesListQuery = {
response: VendorServicesListQuery$data;
variables: VendorServicesListQuery$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "after"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "before"
},
v2 = {
"defaultValue": 50,
"kind": "LocalArgument",
"name": "first"
},
v3 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "id"
},
v4 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "last"
},
v5 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "order"
},
v6 = [
{
"kind": "Variable",
"name": "id",
"variableName": "id"
}
],
v7 = {
"kind": "Variable",
"name": "after",
"variableName": "after"
},
v8 = {
"kind": "Variable",
"name": "before",
"variableName": "before"
},
v9 = {
"kind": "Variable",
"name": "first",
"variableName": "first"
},
v10 = {
"kind": "Variable",
"name": "last",
"variableName": "last"
},
v11 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
v12 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
v13 = [
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/),
{
"kind": "Variable",
"name": "orderBy",
"variableName": "order"
}
];
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/),
(v2/*: any*/),
(v3/*: any*/),
(v4/*: any*/),
(v5/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "VendorServicesListQuery",
"selections": [
{
"alias": null,
"args": (v6/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"args": [
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/),
{
"kind": "Variable",
"name": "order",
"variableName": "order"
}
],
"kind": "FragmentSpread",
"name": "VendorServicesTabFragment"
}
],
"storageKey": null
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/),
(v2/*: any*/),
(v4/*: any*/),
(v5/*: any*/),
(v3/*: any*/)
],
"kind": "Operation",
"name": "VendorServicesListQuery",
"selections": [
{
"alias": null,
"args": (v6/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v11/*: any*/),
(v12/*: any*/),
{
"kind": "InlineFragment",
"selections": [
{
"alias": null,
"args": (v13/*: any*/),
"concreteType": "VendorServiceConnection",
"kind": "LinkedField",
"name": "services",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorServiceEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorService",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v12/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
},
(v11/*: any*/)
],
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "PageInfo",
"kind": "LinkedField",
"name": "pageInfo",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasPreviousPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "startCursor",
"storageKey": null
}
],
"storageKey": null
},
{
"kind": "ClientExtension",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__id",
"storageKey": null
}
]
}
],
"storageKey": null
},
{
"alias": null,
"args": (v13/*: any*/),
"filters": [
"orderBy"
],
"handle": "connection",
"key": "VendorServicesTabFragment_services",
"kind": "LinkedHandle",
"name": "services"
}
],
"type": "Vendor",
"abstractKey": null
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "102f3aac3e2c7ef5115d73246f1bb241",
"id": null,
"metadata": {},
"name": "VendorServicesListQuery",
"operationKind": "query",
"text": "query VendorServicesListQuery(\n $after: CursorKey = null\n $before: CursorKey = null\n $first: Int = 50\n $last: Int = null\n $order: VendorServiceOrder = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...VendorServicesTabFragment_16fISc\n id\n }\n}\n\nfragment VendorServicesTabFragment_16fISc on Vendor {\n services(first: $first, after: $after, last: $last, before: $before, orderBy: $order) {\n edges {\n node {\n id\n ...VendorServicesTabFragment_service\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n\nfragment VendorServicesTabFragment_service on VendorService {\n id\n name\n description\n createdAt\n updatedAt\n}\n"
}
};
})();
(node as any).hash = "fd0c58f2929f925fb47e5df22f6a84f7";
export default node;

View File

@@ -0,0 +1,132 @@
/**
* @generated SignedSource<<deb85307c2d7da7ec52f99a67ad56d9f>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type DeleteVendorServiceInput = {
vendorServiceId: string;
};
export type VendorServicesTabDeleteServiceMutation$variables = {
connections: ReadonlyArray<string>;
input: DeleteVendorServiceInput;
};
export type VendorServicesTabDeleteServiceMutation$data = {
readonly deleteVendorService: {
readonly deletedVendorServiceId: string;
};
};
export type VendorServicesTabDeleteServiceMutation = {
response: VendorServicesTabDeleteServiceMutation$data;
variables: VendorServicesTabDeleteServiceMutation$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "connections"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
},
v2 = [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
],
v3 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "deletedVendorServiceId",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "VendorServicesTabDeleteServiceMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "DeleteVendorServicePayload",
"kind": "LinkedField",
"name": "deleteVendorService",
"plural": false,
"selections": [
(v3/*: any*/)
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"kind": "Operation",
"name": "VendorServicesTabDeleteServiceMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "DeleteVendorServicePayload",
"kind": "LinkedField",
"name": "deleteVendorService",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"filters": null,
"handle": "deleteEdge",
"key": "",
"kind": "ScalarHandle",
"name": "deletedVendorServiceId",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "fef00196f74b15a5528a0974541f1ec4",
"id": null,
"metadata": {},
"name": "VendorServicesTabDeleteServiceMutation",
"operationKind": "mutation",
"text": "mutation VendorServicesTabDeleteServiceMutation(\n $input: DeleteVendorServiceInput!\n) {\n deleteVendorService(input: $input) {\n deletedVendorServiceId\n }\n}\n"
}
};
})();
(node as any).hash = "73d14c22b95d031b2c07b18dbbeb64d4";
export default node;

View File

@@ -0,0 +1,225 @@
/**
* @generated SignedSource<<4dfc017ac50d12a09ddac0cf37061c06>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type VendorServicesTabFragment$data = {
readonly id: string;
readonly services: {
readonly __id: string;
readonly edges: ReadonlyArray<{
readonly node: {
readonly id: string;
readonly " $fragmentSpreads": FragmentRefs<"VendorServicesTabFragment_service">;
};
}>;
};
readonly " $fragmentType": "VendorServicesTabFragment";
};
export type VendorServicesTabFragment$key = {
readonly " $data"?: VendorServicesTabFragment$data;
readonly " $fragmentSpreads": FragmentRefs<"VendorServicesTabFragment">;
};
import VendorServicesListQuery_graphql from './VendorServicesListQuery.graphql';
const node: ReaderFragment = (function(){
var v0 = [
"services"
],
v1 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
};
return {
"argumentDefinitions": [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "after"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "before"
},
{
"defaultValue": 50,
"kind": "LocalArgument",
"name": "first"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "last"
},
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "order"
}
],
"kind": "Fragment",
"metadata": {
"connection": [
{
"count": null,
"cursor": null,
"direction": "bidirectional",
"path": (v0/*: any*/)
}
],
"refetch": {
"connection": {
"forward": {
"count": "first",
"cursor": "after"
},
"backward": {
"count": "last",
"cursor": "before"
},
"path": (v0/*: any*/)
},
"fragmentPathInResult": [
"node"
],
"operation": VendorServicesListQuery_graphql,
"identifierInfo": {
"identifierField": "id",
"identifierQueryVariableName": "id"
}
}
},
"name": "VendorServicesTabFragment",
"selections": [
{
"alias": "services",
"args": [
{
"kind": "Variable",
"name": "orderBy",
"variableName": "order"
}
],
"concreteType": "VendorServiceConnection",
"kind": "LinkedField",
"name": "__VendorServicesTabFragment_services_connection",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorServiceEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "VendorService",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v1/*: any*/),
{
"args": null,
"kind": "FragmentSpread",
"name": "VendorServicesTabFragment_service"
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "PageInfo",
"kind": "LinkedField",
"name": "pageInfo",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "endCursor",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasNextPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasPreviousPage",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "startCursor",
"storageKey": null
}
],
"storageKey": null
},
{
"kind": "ClientExtension",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__id",
"storageKey": null
}
]
}
],
"storageKey": null
},
(v1/*: any*/)
],
"type": "Vendor",
"abstractKey": null
};
})();
(node as any).hash = "fd0c58f2929f925fb47e5df22f6a84f7";
export default node;

View File

@@ -0,0 +1,74 @@
/**
* @generated SignedSource<<2f6dc5bf85b9ad81fe6c9af7955e4217>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type VendorServicesTabFragment_service$data = {
readonly createdAt: any;
readonly description: string | null | undefined;
readonly id: string;
readonly name: string;
readonly updatedAt: any;
readonly " $fragmentType": "VendorServicesTabFragment_service";
};
export type VendorServicesTabFragment_service$key = {
readonly " $data"?: VendorServicesTabFragment_service$data;
readonly " $fragmentSpreads": FragmentRefs<"VendorServicesTabFragment_service">;
};
const node: ReaderFragment = {
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": null,
"name": "VendorServicesTabFragment_service",
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "description",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
}
],
"type": "VendorService",
"abstractKey": null
};
(node as any).hash = "276b5545b9e5eb7f9d9f56c4ea2ed352";
export default node;

View File

@@ -69,6 +69,14 @@ export const vendorRoutes = [
import("../pages/organizations/vendors/tabs/VendorContactsTab")
),
},
{
path: "services",
fallback: LinkCardSkeleton,
Component: lazy(
() =>
import("../pages/organizations/vendors/tabs/VendorServicesTab")
),
},
],
},
] satisfies AppRoute[];

View File

@@ -45,4 +45,5 @@ const (
VendorDataPrivacyAgreementEntityType
NonconformityRegistryEntityType
ComplianceRegistryEntityType
VendorServiceEntityType
)

View File

@@ -0,0 +1,15 @@
CREATE TABLE vendor_services (
id TEXT PRIMARY KEY,
tenant_id TEXT NOT NULL,
vendor_id TEXT NOT NULL,
name TEXT NOT NULL,
description TEXT,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
CONSTRAINT vendor_services_vendor_id_fkey
FOREIGN KEY (vendor_id)
REFERENCES vendors(id)
ON UPDATE CASCADE
ON DELETE CASCADE
);

View File

@@ -0,0 +1,259 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package coredata
import (
"context"
"errors"
"fmt"
"maps"
"time"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"github.com/jackc/pgx/v5"
"go.gearno.de/kit/pg"
)
type (
VendorService struct {
ID gid.GID `db:"id"`
VendorID gid.GID `db:"vendor_id"`
Name string `db:"name"`
Description *string `db:"description"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
VendorServices []*VendorService
ErrVendorServiceNotFound struct {
Identifier string
}
)
func (e ErrVendorServiceNotFound) Error() string {
return fmt.Sprintf("vendor service not found: %s", e.Identifier)
}
func (vs VendorService) CursorKey(orderBy VendorServiceOrderField) page.CursorKey {
switch orderBy {
case VendorServiceOrderFieldCreatedAt:
return page.CursorKey{ID: vs.ID, Value: vs.CreatedAt}
case VendorServiceOrderFieldName:
return page.CursorKey{ID: vs.ID, Value: vs.Name}
}
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
}
func (vs *VendorService) LoadByID(
ctx context.Context,
conn pg.Conn,
scope Scoper,
vendorServiceID gid.GID,
) error {
q := `
SELECT
id,
vendor_id,
name,
description,
created_at,
updated_at
FROM
vendor_services
WHERE
%s
AND id = @vendor_service_id
LIMIT 1;
`
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"vendor_service_id": vendorServiceID}
maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query vendor service: %w", err)
}
defer rows.Close()
vendorService, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[VendorService])
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return &ErrVendorServiceNotFound{Identifier: vendorServiceID.String()}
}
return fmt.Errorf("cannot collect vendor service: %w", err)
}
*vs = vendorService
return nil
}
func (vs *VendorServices) LoadByVendorID(
ctx context.Context,
conn pg.Conn,
scope Scoper,
vendorID gid.GID,
cursor *page.Cursor[VendorServiceOrderField],
) error {
q := `
SELECT
id,
vendor_id,
name,
description,
created_at,
updated_at
FROM
vendor_services
WHERE
%s
AND vendor_id = @vendor_id
AND %s
`
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
args := pgx.StrictNamedArgs{
"vendor_id": vendorID,
}
maps.Copy(args, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments())
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query vendor services: %w", err)
}
defer rows.Close()
vendorServices, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[VendorService])
if err != nil {
return fmt.Errorf("cannot collect vendor services: %w", err)
}
*vs = vendorServices
return nil
}
func (vs VendorService) Insert(
ctx context.Context,
conn pg.Conn,
scope Scoper,
) error {
q := `
INSERT INTO
vendor_services (
tenant_id,
id,
vendor_id,
name,
description,
created_at,
updated_at
)
VALUES (
@tenant_id,
@vendor_service_id,
@vendor_id,
@name,
@description,
@created_at,
@updated_at
)
`
args := pgx.StrictNamedArgs{
"tenant_id": scope.GetTenantID(),
"vendor_service_id": vs.ID,
"vendor_id": vs.VendorID,
"name": vs.Name,
"description": vs.Description,
"created_at": vs.CreatedAt,
"updated_at": vs.UpdatedAt,
}
_, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot insert vendor service: %w", err)
}
return nil
}
func (vs VendorService) Update(
ctx context.Context,
conn pg.Conn,
scope Scoper,
) error {
q := `
UPDATE
vendor_services
SET
name = @name,
description = @description,
updated_at = @updated_at
WHERE
%s
AND id = @vendor_service_id
`
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{
"vendor_service_id": vs.ID,
"name": vs.Name,
"description": vs.Description,
"updated_at": vs.UpdatedAt,
}
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot update vendor service: %w", err)
}
return nil
}
func (vs VendorService) Delete(
ctx context.Context,
conn pg.Conn,
scope Scoper,
) error {
q := `
DELETE FROM
vendor_services
WHERE
%s
AND id = @vendor_service_id
`
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"vendor_service_id": vs.ID}
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot delete vendor service: %w", err)
}
return nil
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package coredata
import (
"fmt"
)
type (
VendorServiceOrderField string
)
const (
VendorServiceOrderFieldCreatedAt VendorServiceOrderField = "CREATED_AT"
VendorServiceOrderFieldName VendorServiceOrderField = "NAME"
)
func (p VendorServiceOrderField) Column() string {
return string(p)
}
func (p VendorServiceOrderField) String() string {
return string(p)
}
func (p VendorServiceOrderField) MarshalText() ([]byte, error) {
return []byte(p.String()), nil
}
func (p *VendorServiceOrderField) UnmarshalText(text []byte) error {
val := string(text)
switch val {
case string(VendorServiceOrderFieldCreatedAt),
string(VendorServiceOrderFieldName):
*p = VendorServiceOrderField(val)
return nil
}
return fmt.Errorf("invalid VendorServiceOrderField value: %q", val)
}

View File

@@ -74,6 +74,7 @@ type (
VendorBusinessAssociateAgreements *VendorBusinessAssociateAgreementService
VendorContacts *VendorContactService
VendorDataPrivacyAgreements *VendorDataPrivacyAgreementService
VendorServices *VendorServiceService
Connectors *ConnectorService
Assets *AssetService
Data *DatumService
@@ -165,6 +166,7 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
tenantService.VendorBusinessAssociateAgreements = &VendorBusinessAssociateAgreementService{svc: tenantService}
tenantService.VendorContacts = &VendorContactService{svc: tenantService}
tenantService.VendorDataPrivacyAgreements = &VendorDataPrivacyAgreementService{svc: tenantService}
tenantService.VendorServices = &VendorServiceService{svc: tenantService}
tenantService.Connectors = &ConnectorService{svc: tenantService}
tenantService.Assets = &AssetService{svc: tenantService}
tenantService.Data = &DatumService{svc: tenantService}

View File

@@ -0,0 +1,185 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package probo
import (
"context"
"fmt"
"time"
"github.com/getprobo/probo/pkg/coredata"
"github.com/getprobo/probo/pkg/gid"
"github.com/getprobo/probo/pkg/page"
"go.gearno.de/kit/pg"
)
type (
VendorServiceService struct {
svc *TenantService
}
CreateVendorServiceRequest struct {
VendorID gid.GID
Name string
Description *string
}
UpdateVendorServiceRequest struct {
ID gid.GID
Name *string
Description **string
}
)
func (s VendorServiceService) Get(
ctx context.Context,
vendorServiceID gid.GID,
) (*coredata.VendorService, error) {
vendorService := &coredata.VendorService{}
err := s.svc.pg.WithConn(
ctx,
func(conn pg.Conn) error {
err := vendorService.LoadByID(ctx, conn, s.svc.scope, vendorServiceID)
if err != nil {
return fmt.Errorf("cannot load vendor service: %w", err)
}
return nil
},
)
if err != nil {
return nil, err
}
return vendorService, nil
}
func (s VendorServiceService) List(
ctx context.Context,
vendorID gid.GID,
cursor *page.Cursor[coredata.VendorServiceOrderField],
) (*page.Page[*coredata.VendorService, coredata.VendorServiceOrderField], error) {
var vendorServices coredata.VendorServices
err := s.svc.pg.WithConn(
ctx,
func(conn pg.Conn) error {
err := vendorServices.LoadByVendorID(ctx, conn, s.svc.scope, vendorID, cursor)
if err != nil {
return fmt.Errorf("cannot load vendor services: %w", err)
}
return nil
},
)
if err != nil {
return nil, err
}
return page.NewPage(vendorServices, cursor), nil
}
func (s VendorServiceService) Create(
ctx context.Context,
req CreateVendorServiceRequest,
) (*coredata.VendorService, error) {
now := time.Now()
vendorService := &coredata.VendorService{
ID: gid.New(s.svc.scope.GetTenantID(), coredata.VendorServiceEntityType),
VendorID: req.VendorID,
Name: req.Name,
Description: req.Description,
CreatedAt: now,
UpdatedAt: now,
}
err := s.svc.pg.WithConn(
ctx,
func(conn pg.Conn) error {
if err := vendorService.Insert(ctx, conn, s.svc.scope); err != nil {
return fmt.Errorf("cannot insert vendor service: %w", err)
}
return nil
},
)
if err != nil {
return nil, err
}
return vendorService, nil
}
func (s VendorServiceService) Update(
ctx context.Context,
req UpdateVendorServiceRequest,
) (*coredata.VendorService, error) {
vendorService := &coredata.VendorService{}
err := s.svc.pg.WithTx(
ctx,
func(conn pg.Conn) error {
err := vendorService.LoadByID(ctx, conn, s.svc.scope, req.ID)
if err != nil {
return fmt.Errorf("cannot load vendor service: %w", err)
}
if req.Name != nil {
vendorService.Name = *req.Name
}
if req.Description != nil {
vendorService.Description = *req.Description
}
vendorService.UpdatedAt = time.Now()
if err := vendorService.Update(ctx, conn, s.svc.scope); err != nil {
return fmt.Errorf("cannot update vendor service: %w", err)
}
return nil
},
)
if err != nil {
return nil, err
}
return vendorService, nil
}
func (s VendorServiceService) Delete(
ctx context.Context,
vendorServiceID gid.GID,
) error {
vendorService := coredata.VendorService{ID: vendorServiceID}
return s.svc.pg.WithTx(
ctx,
func(conn pg.Conn) error {
if err := vendorService.LoadByID(ctx, conn, s.svc.scope, vendorServiceID); err != nil {
return fmt.Errorf("cannot load vendor service: %w", err)
}
if err := vendorService.Delete(ctx, conn, s.svc.scope); err != nil {
return fmt.Errorf("cannot delete vendor service: %w", err)
}
return nil
},
)
}

View File

@@ -342,6 +342,20 @@ enum VendorContactOrderField
)
}
enum VendorServiceOrderField
@goModel(
model: "github.com/getprobo/probo/pkg/coredata.VendorServiceOrderField"
) {
CREATED_AT
@goEnum(
value: "github.com/getprobo/probo/pkg/coredata.VendorServiceOrderFieldCreatedAt"
)
NAME
@goEnum(
value: "github.com/getprobo/probo/pkg/coredata.VendorServiceOrderFieldName"
)
}
enum OrganizationOrderField
@goModel(
model: "github.com/getprobo/probo/pkg/coredata.OrganizationOrderField"
@@ -801,6 +815,14 @@ input VendorContactOrder
field: VendorContactOrderField!
}
input VendorServiceOrder
@goModel(
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.VendorServiceOrderBy"
) {
direction: OrderDirection!
field: VendorServiceOrderField!
}
input OrganizationOrder {
direction: OrderDirection!
field: OrganizationOrderField!
@@ -1064,6 +1086,14 @@ type Vendor implements Node {
orderBy: VendorContactOrder
): VendorContactConnection! @goField(forceResolver: true)
services(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: VendorServiceOrder
): VendorServiceConnection! @goField(forceResolver: true)
riskAssessments(
first: Int
after: CursorKey
@@ -1128,6 +1158,15 @@ type VendorContact implements Node {
updatedAt: Datetime!
}
type VendorService implements Node {
id: ID!
vendor: Vendor! @goField(forceResolver: true)
name: String!
description: String
createdAt: Datetime!
updatedAt: Datetime!
}
type VendorDataPrivacyAgreement implements Node {
id: ID!
vendor: Vendor! @goField(forceResolver: true)
@@ -1652,6 +1691,16 @@ type VendorContactEdge {
node: VendorContact!
}
type VendorServiceConnection {
edges: [VendorServiceEdge!]!
pageInfo: PageInfo!
}
type VendorServiceEdge {
cursor: CursorKey!
node: VendorService!
}
type ConnectorConnection {
edges: [ConnectorEdge!]!
pageInfo: PageInfo!
@@ -1796,6 +1845,11 @@ type Mutation {
updateVendorContact(input: UpdateVendorContactInput!): UpdateVendorContactPayload!
deleteVendorContact(input: DeleteVendorContactInput!): DeleteVendorContactPayload!
# Vendor Service mutations
createVendorService(input: CreateVendorServiceInput!): CreateVendorServicePayload!
updateVendorService(input: UpdateVendorServiceInput!): UpdateVendorServicePayload!
deleteVendorService(input: DeleteVendorServiceInput!): DeleteVendorServicePayload!
# Framework mutations
createFramework(input: CreateFrameworkInput!): CreateFrameworkPayload!
updateFramework(input: UpdateFrameworkInput!): UpdateFrameworkPayload!
@@ -2089,6 +2143,26 @@ input DeleteVendorContactInput {
vendorContactId: ID!
}
input CreateVendorServiceInput {
vendorId: ID!
name: String!
description: String
url: String
type: String
}
input UpdateVendorServiceInput {
id: ID!
name: String
description: String
url: String
type: String
}
input DeleteVendorServiceInput {
vendorServiceId: ID!
}
input CreatePeopleInput {
organizationId: ID!
fullName: String!
@@ -2570,6 +2644,18 @@ type DeleteVendorContactPayload {
deletedVendorContactId: ID!
}
type CreateVendorServicePayload {
vendorServiceEdge: VendorServiceEdge!
}
type UpdateVendorServicePayload {
vendorService: VendorService!
}
type DeleteVendorServicePayload {
deletedVendorServiceId: ID!
}
type CreatePeoplePayload {
peopleEdge: PeopleEdge!
}

File diff suppressed because it is too large Load Diff

View File

@@ -505,6 +505,18 @@ type CreateVendorRiskAssessmentPayload struct {
VendorRiskAssessmentEdge *VendorRiskAssessmentEdge `json:"vendorRiskAssessmentEdge"`
}
type CreateVendorServiceInput struct {
VendorID gid.GID `json:"vendorId"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
URL *string `json:"url,omitempty"`
Type *string `json:"type,omitempty"`
}
type CreateVendorServicePayload struct {
VendorServiceEdge *VendorServiceEdge `json:"vendorServiceEdge"`
}
type Datum struct {
ID gid.GID `json:"id"`
Name string `json:"name"`
@@ -750,6 +762,14 @@ type DeleteVendorPayload struct {
DeletedVendorID gid.GID `json:"deletedVendorId"`
}
type DeleteVendorServiceInput struct {
VendorServiceID gid.GID `json:"vendorServiceId"`
}
type DeleteVendorServicePayload struct {
DeletedVendorServiceID gid.GID `json:"deletedVendorServiceId"`
}
type Document struct {
ID gid.GID `json:"id"`
Title string `json:"title"`
@@ -1519,6 +1539,18 @@ type UpdateVendorPayload struct {
Vendor *Vendor `json:"vendor"`
}
type UpdateVendorServiceInput struct {
ID gid.GID `json:"id"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
URL *string `json:"url,omitempty"`
Type *string `json:"type,omitempty"`
}
type UpdateVendorServicePayload struct {
VendorService *VendorService `json:"vendorService"`
}
type UploadAuditReportInput struct {
AuditID gid.GID `json:"auditId"`
File graphql.Upload `json:"file"`
@@ -1614,6 +1646,7 @@ type Vendor struct {
BusinessAssociateAgreement *VendorBusinessAssociateAgreement `json:"businessAssociateAgreement,omitempty"`
DataPrivacyAgreement *VendorDataPrivacyAgreement `json:"dataPrivacyAgreement,omitempty"`
Contacts *VendorContactConnection `json:"contacts"`
Services *VendorServiceConnection `json:"services"`
RiskAssessments *VendorRiskAssessmentConnection `json:"riskAssessments"`
BusinessOwner *People `json:"businessOwner,omitempty"`
SecurityOwner *People `json:"securityOwner,omitempty"`
@@ -1753,6 +1786,28 @@ type VendorRiskAssessmentOrder struct {
Direction page.OrderDirection `json:"direction"`
}
type VendorService struct {
ID gid.GID `json:"id"`
Vendor *Vendor `json:"vendor"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (VendorService) IsNode() {}
func (this VendorService) GetID() gid.GID { return this.ID }
type VendorServiceConnection struct {
Edges []*VendorServiceEdge `json:"edges"`
PageInfo *PageInfo `json:"pageInfo"`
}
type VendorServiceEdge struct {
Cursor page.CursorKey `json:"cursor"`
Node *VendorService `json:"node"`
}
type Viewer struct {
ID gid.GID `json:"id"`
User *User `json:"user"`

View File

@@ -0,0 +1,54 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package types
import (
"github.com/getprobo/probo/pkg/coredata"
"github.com/getprobo/probo/pkg/page"
)
type (
VendorServiceOrderBy OrderBy[coredata.VendorServiceOrderField]
)
func NewVendorServiceConnection(p *page.Page[*coredata.VendorService, coredata.VendorServiceOrderField]) *VendorServiceConnection {
var edges = make([]*VendorServiceEdge, len(p.Data))
for i := range edges {
edges[i] = NewVendorServiceEdge(p.Data[i], p.Cursor.OrderBy.Field)
}
return &VendorServiceConnection{
Edges: edges,
PageInfo: NewPageInfo(p),
}
}
func NewVendorServiceEdge(s *coredata.VendorService, orderBy coredata.VendorServiceOrderField) *VendorServiceEdge {
return &VendorServiceEdge{
Cursor: s.CursorKey(orderBy),
Node: NewVendorService(s),
}
}
func NewVendorService(s *coredata.VendorService) *VendorService {
return &VendorService{
ID: s.ID,
Name: s.Name,
Description: s.Description,
CreatedAt: s.CreatedAt,
UpdatedAt: s.UpdatedAt,
}
}

View File

@@ -1430,6 +1430,60 @@ func (r *mutationResolver) DeleteVendorContact(ctx context.Context, input types.
}, nil
}
// CreateVendorService is the resolver for the createVendorService field.
func (r *mutationResolver) CreateVendorService(ctx context.Context, input types.CreateVendorServiceInput) (*types.CreateVendorServicePayload, error) {
prb := r.ProboService(ctx, input.VendorID.TenantID())
req := probo.CreateVendorServiceRequest{
VendorID: input.VendorID,
Name: input.Name,
Description: input.Description,
}
vendorService, err := prb.VendorServices.Create(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to create vendor service: %w", err)
}
return &types.CreateVendorServicePayload{
VendorServiceEdge: types.NewVendorServiceEdge(vendorService, coredata.VendorServiceOrderFieldCreatedAt),
}, nil
}
// UpdateVendorService is the resolver for the updateVendorService field.
func (r *mutationResolver) UpdateVendorService(ctx context.Context, input types.UpdateVendorServiceInput) (*types.UpdateVendorServicePayload, error) {
prb := r.ProboService(ctx, input.ID.TenantID())
req := probo.UpdateVendorServiceRequest{
ID: input.ID,
Name: input.Name,
Description: &input.Description,
}
vendorService, err := prb.VendorServices.Update(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to update vendor service: %w", err)
}
return &types.UpdateVendorServicePayload{
VendorService: types.NewVendorService(vendorService),
}, nil
}
// DeleteVendorService is the resolver for the deleteVendorService field.
func (r *mutationResolver) DeleteVendorService(ctx context.Context, input types.DeleteVendorServiceInput) (*types.DeleteVendorServicePayload, error) {
prb := r.ProboService(ctx, input.VendorServiceID.TenantID())
err := prb.VendorServices.Delete(ctx, input.VendorServiceID)
if err != nil {
return nil, fmt.Errorf("failed to delete vendor service: %w", err)
}
return &types.DeleteVendorServicePayload{
DeletedVendorServiceID: input.VendorServiceID,
}, nil
}
// CreateFramework is the resolver for the createFramework field.
func (r *mutationResolver) CreateFramework(ctx context.Context, input types.CreateFrameworkInput) (*types.CreateFrameworkPayload, error) {
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
@@ -3507,6 +3561,12 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
panic(fmt.Errorf("cannot get vendor contact: %w", err))
}
return types.NewVendorContact(vendorContact), nil
case coredata.VendorServiceEntityType:
vendorService, err := prb.VendorServices.Get(ctx, id)
if err != nil {
panic(fmt.Errorf("cannot get vendor service: %w", err))
}
return types.NewVendorService(vendorService), nil
case coredata.DocumentVersionEntityType:
documentVersion, err := prb.Documents.GetVersion(ctx, id)
if err != nil {
@@ -3993,6 +4053,31 @@ func (r *vendorResolver) Contacts(ctx context.Context, obj *types.Vendor, first
return types.NewVendorContactConnection(page), nil
}
// Services is the resolver for the services field.
func (r *vendorResolver) Services(ctx context.Context, obj *types.Vendor, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorServiceOrderBy) (*types.VendorServiceConnection, error) {
prb := r.ProboService(ctx, obj.ID.TenantID())
pageOrderBy := page.OrderBy[coredata.VendorServiceOrderField]{
Field: coredata.VendorServiceOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
}
if orderBy != nil {
pageOrderBy = page.OrderBy[coredata.VendorServiceOrderField]{
Field: orderBy.Field,
Direction: orderBy.Direction,
}
}
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := prb.VendorServices.List(ctx, obj.ID, cursor)
if err != nil {
panic(fmt.Errorf("failed to list vendor services: %w", err))
}
return types.NewVendorServiceConnection(page), nil
}
// RiskAssessments is the resolver for the riskAssessments field.
func (r *vendorResolver) RiskAssessments(ctx context.Context, obj *types.Vendor, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorRiskAssessmentOrder) (*types.VendorRiskAssessmentConnection, error) {
prb := r.ProboService(ctx, obj.ID.TenantID())
@@ -4206,6 +4291,24 @@ func (r *vendorRiskAssessmentResolver) AssessedBy(ctx context.Context, obj *type
return types.NewPeople(people), nil
}
// Vendor is the resolver for the vendor field.
func (r *vendorServiceResolver) Vendor(ctx context.Context, obj *types.VendorService) (*types.Vendor, error) {
prb := r.ProboService(ctx, obj.ID.TenantID())
// Get the vendor service to access the VendorID
vendorService, err := prb.VendorServices.Get(ctx, obj.ID)
if err != nil {
panic(fmt.Errorf("failed to get vendor service: %w", err))
}
vendor, err := prb.Vendors.Get(ctx, vendorService.VendorID)
if err != nil {
panic(fmt.Errorf("failed to get vendor: %w", err))
}
return types.NewVendor(vendor), nil
}
// Organizations is the resolver for the organizations field.
func (r *viewerResolver) Organizations(ctx context.Context, obj *types.Viewer, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrganizationOrder, filter *types.OrganizationFilter) (*types.OrganizationConnection, error) {
user := UserFromContext(ctx)
@@ -4391,6 +4494,9 @@ func (r *Resolver) VendorRiskAssessment() schema.VendorRiskAssessmentResolver {
return &vendorRiskAssessmentResolver{r}
}
// VendorService returns schema.VendorServiceResolver implementation.
func (r *Resolver) VendorService() schema.VendorServiceResolver { return &vendorServiceResolver{r} }
// Viewer returns schema.ViewerResolver implementation.
func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
@@ -4434,4 +4540,5 @@ type vendorConnectionResolver struct{ *Resolver }
type vendorContactResolver struct{ *Resolver }
type vendorDataPrivacyAgreementResolver struct{ *Resolver }
type vendorRiskAssessmentResolver struct{ *Resolver }
type vendorServiceResolver struct{ *Resolver }
type viewerResolver struct{ *Resolver }