Add vendor contacts
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -152,6 +152,7 @@ export const vendorNodeQuery = graphql`
|
||||
websiteUrl
|
||||
...useVendorFormFragment
|
||||
...VendorComplianceTabFragment
|
||||
...VendorContactsTabFragment
|
||||
...VendorRiskAssessmentTabFragment
|
||||
...VendorOverviewTabBusinessAssociateAgreementFragment
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<9174011c1abd05e499786607130d0c82>>
|
||||
* @generated SignedSource<<da74b0f7535be59a3442b643c71931d7>>
|
||||
* @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" | "VendorOverviewTabBusinessAssociateAgreementFragment" | "VendorRiskAssessmentTabFragment" | "useVendorFormFragment">;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"VendorComplianceTabFragment" | "VendorContactsTabFragment" | "VendorOverviewTabBusinessAssociateAgreementFragment" | "VendorRiskAssessmentTabFragment" | "useVendorFormFragment">;
|
||||
};
|
||||
readonly viewer: {
|
||||
readonly user: {
|
||||
@@ -156,6 +156,21 @@ v16 = {
|
||||
"storageKey": null
|
||||
},
|
||||
v17 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "PageInfo",
|
||||
"kind": "LinkedField",
|
||||
"name": "pageInfo",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v13/*: any*/),
|
||||
(v14/*: any*/),
|
||||
(v15/*: any*/),
|
||||
(v16/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
v18 = {
|
||||
"kind": "ClientExtension",
|
||||
"selections": [
|
||||
{
|
||||
@@ -167,9 +182,23 @@ v17 = {
|
||||
}
|
||||
]
|
||||
},
|
||||
v18 = [
|
||||
v19 = [
|
||||
"orderBy"
|
||||
];
|
||||
],
|
||||
v20 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
},
|
||||
v21 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
@@ -204,6 +233,11 @@ return {
|
||||
"kind": "FragmentSpread",
|
||||
"name": "VendorComplianceTabFragment"
|
||||
},
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "VendorContactsTabFragment"
|
||||
},
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
@@ -425,34 +459,97 @@ return {
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "PageInfo",
|
||||
"kind": "LinkedField",
|
||||
"name": "pageInfo",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v13/*: any*/),
|
||||
(v14/*: any*/),
|
||||
(v15/*: any*/),
|
||||
(v16/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v17/*: any*/)
|
||||
(v17/*: any*/),
|
||||
(v18/*: any*/)
|
||||
],
|
||||
"storageKey": "complianceReports(first:50)"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v9/*: any*/),
|
||||
"filters": (v18/*: any*/),
|
||||
"filters": (v19/*: any*/),
|
||||
"handle": "connection",
|
||||
"key": "VendorComplianceTabFragment_complianceReports",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "complianceReports"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v9/*: any*/),
|
||||
"concreteType": "VendorContactConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "contacts",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContactEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContact",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v20/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "email",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "phone",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "role",
|
||||
"storageKey": null
|
||||
},
|
||||
(v21/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
},
|
||||
(v8/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v12/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v17/*: any*/),
|
||||
(v18/*: any*/)
|
||||
],
|
||||
"storageKey": "contacts(first:50)"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v9/*: any*/),
|
||||
"filters": (v19/*: any*/),
|
||||
"handle": "connection",
|
||||
"key": "VendorContactsTabFragment_contacts",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "contacts"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v9/*: any*/),
|
||||
@@ -494,13 +591,7 @@ return {
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
}
|
||||
(v20/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
@@ -555,14 +646,14 @@ return {
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
(v17/*: any*/)
|
||||
(v18/*: any*/)
|
||||
],
|
||||
"storageKey": "riskAssessments(first:50)"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v9/*: any*/),
|
||||
"filters": (v18/*: any*/),
|
||||
"filters": (v19/*: any*/),
|
||||
"handle": "connection",
|
||||
"key": "VendorRiskAssessmentTabFragment_riskAssessments",
|
||||
"kind": "LinkedHandle",
|
||||
@@ -593,13 +684,7 @@ return {
|
||||
"storageKey": null
|
||||
},
|
||||
(v10/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
}
|
||||
(v21/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -638,16 +723,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "95f9f21af1253d08c97dfd7d2f65f2e3",
|
||||
"cacheID": "506d89b503073e18cbf657aec5d62c71",
|
||||
"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 ...VendorRiskAssessmentTabFragment\n ...VendorOverviewTabBusinessAssociateAgreementFragment\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 VendorOverviewTabBusinessAssociateAgreementFragment on Vendor {\n businessAssociateAgreement {\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 ...VendorRiskAssessmentTabFragment\n ...VendorOverviewTabBusinessAssociateAgreementFragment\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 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"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "c80a167ea096212995f1d3261bc2bf57";
|
||||
(node as any).hash = "b5ea2120ec2f0f09ed29e19bbf232622";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -112,6 +112,11 @@ export default function VendorDetailPage(props: Props) {
|
||||
>
|
||||
{__("Risk Assessment")}
|
||||
</TabLink>
|
||||
<TabLink
|
||||
to={`/organizations/${organizationId}/vendors/${vendor.id}/contacts`}
|
||||
>
|
||||
{__("Contacts")}
|
||||
</TabLink>
|
||||
</Tabs>
|
||||
|
||||
<Outlet context={{ vendor, peopleId: data.viewer.user.people!.id }} />
|
||||
|
||||
143
apps/console/src/pages/organizations/vendors/dialogs/CreateContactDialog.tsx
vendored
Normal file
143
apps/console/src/pages/organizations/vendors/dialogs/CreateContactDialog.tsx
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
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 createContactMutation = graphql`
|
||||
mutation CreateContactDialogMutation(
|
||||
$input: CreateVendorContactInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
createVendorContact(input: $input) {
|
||||
vendorContactEdge @prependEdge(connections: $connections) {
|
||||
node {
|
||||
...VendorContactsTabFragment_contact
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const phoneRegex = /^\+[0-9]{8,15}$/;
|
||||
|
||||
export function CreateContactDialog({
|
||||
children,
|
||||
connectionId,
|
||||
vendorId,
|
||||
}: Props) {
|
||||
const { __ } = useTranslate();
|
||||
|
||||
const schema = z.object({
|
||||
fullName: z.string().optional(),
|
||||
email: z.string().email(__("Please enter a valid email address")).optional().or(z.literal("")),
|
||||
phone: z.string().regex(phoneRegex, __("Phone number must be in international format (e.g., +1234567890)")).optional().or(z.literal("")),
|
||||
role: z.string().optional(),
|
||||
});
|
||||
|
||||
const { register, handleSubmit, formState, reset } = useFormWithSchema(
|
||||
schema,
|
||||
{
|
||||
defaultValues: {
|
||||
fullName: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
role: "",
|
||||
},
|
||||
}
|
||||
);
|
||||
const [createContact, isLoading] = useMutationWithToasts(
|
||||
createContactMutation,
|
||||
{
|
||||
successMessage: __("Contact created successfully."),
|
||||
errorMessage: __("Failed to create contact. Please try again."),
|
||||
}
|
||||
);
|
||||
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
const cleanData = cleanFormData(data);
|
||||
|
||||
createContact({
|
||||
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={[__("Contacts"), __("New Contact")]} />
|
||||
}
|
||||
>
|
||||
<form onSubmit={onSubmit}>
|
||||
<DialogContent padded className="space-y-4">
|
||||
<Field
|
||||
label={__("Name")}
|
||||
{...register("fullName")}
|
||||
type="text"
|
||||
error={formState.errors.fullName?.message}
|
||||
placeholder={__("Contact's full name")}
|
||||
/>
|
||||
<Field
|
||||
label={__("Email")}
|
||||
{...register("email")}
|
||||
type="email"
|
||||
error={formState.errors.email?.message}
|
||||
placeholder={__("contact@example.com")}
|
||||
/>
|
||||
<Field
|
||||
label={__("Phone")}
|
||||
{...register("phone")}
|
||||
type="text"
|
||||
error={formState.errors.phone?.message}
|
||||
placeholder={__("e.g., +1234567890")}
|
||||
help={__("Use international format starting with +")}
|
||||
/>
|
||||
<Field
|
||||
label={__("Role")}
|
||||
{...register("role")}
|
||||
type="text"
|
||||
error={formState.errors.role?.message}
|
||||
placeholder={__("e.g., Account Manager, Technical Support")}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button type="submit" disabled={isLoading}>
|
||||
{__("Create")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
142
apps/console/src/pages/organizations/vendors/dialogs/EditContactDialog.tsx
vendored
Normal file
142
apps/console/src/pages/organizations/vendors/dialogs/EditContactDialog.tsx
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
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 = {
|
||||
contactId: string;
|
||||
contact: {
|
||||
fullName?: string | null;
|
||||
email?: string | null;
|
||||
phone?: string | null;
|
||||
role?: string | null;
|
||||
};
|
||||
onClose: () => void;
|
||||
};
|
||||
|
||||
const updateContactMutation = graphql`
|
||||
mutation EditContactDialogUpdateMutation($input: UpdateVendorContactInput!) {
|
||||
updateVendorContact(input: $input) {
|
||||
vendorContact {
|
||||
...VendorContactsTabFragment_contact
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const phoneRegex = /^\+[0-9]{8,15}$/;
|
||||
|
||||
export function EditContactDialog({ contactId, contact, onClose }: Props) {
|
||||
const { __ } = useTranslate();
|
||||
|
||||
const schema = z.object({
|
||||
fullName: z.string().optional(),
|
||||
email: z.string().email(__("Please enter a valid email address")).optional().or(z.literal("")),
|
||||
phone: z.string().regex(phoneRegex, __("Phone number must be in international format (e.g., +1234567890)")).optional().or(z.literal("")),
|
||||
role: z.string().optional(),
|
||||
});
|
||||
|
||||
const { register, handleSubmit, formState } = useFormWithSchema(
|
||||
schema,
|
||||
{
|
||||
defaultValues: {
|
||||
fullName: contact.fullName || "",
|
||||
email: contact.email || "",
|
||||
phone: contact.phone || "",
|
||||
role: contact.role || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const [updateContact, isLoading] = useMutationWithToasts(
|
||||
updateContactMutation,
|
||||
{
|
||||
successMessage: __("Contact updated successfully."),
|
||||
errorMessage: __("Failed to update contact. Please try again."),
|
||||
}
|
||||
);
|
||||
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
const cleanData = cleanFormData(data);
|
||||
|
||||
updateContact({
|
||||
variables: {
|
||||
input: {
|
||||
id: contactId,
|
||||
...cleanData,
|
||||
},
|
||||
},
|
||||
onSuccess: () => {
|
||||
onClose();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const dialogRef = useDialogRef();
|
||||
|
||||
useEffect(() => {
|
||||
dialogRef.current?.open();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
className="max-w-lg"
|
||||
ref={dialogRef}
|
||||
onClose={onClose}
|
||||
title={
|
||||
<Breadcrumb items={[__("Contacts"), __("Edit Contact")]} />
|
||||
}
|
||||
>
|
||||
<form onSubmit={onSubmit}>
|
||||
<DialogContent padded className="space-y-4">
|
||||
<Field
|
||||
label={__("Name")}
|
||||
{...register("fullName")}
|
||||
type="text"
|
||||
error={formState.errors.fullName?.message}
|
||||
placeholder={__("Contact's full name")}
|
||||
/>
|
||||
<Field
|
||||
label={__("Email")}
|
||||
{...register("email")}
|
||||
type="email"
|
||||
error={formState.errors.email?.message}
|
||||
placeholder={__("contact@example.com")}
|
||||
/>
|
||||
<Field
|
||||
label={__("Phone")}
|
||||
{...register("phone")}
|
||||
type="text"
|
||||
error={formState.errors.phone?.message}
|
||||
placeholder={__("e.g., +1234567890")}
|
||||
help={__("Use international format starting with +")}
|
||||
/>
|
||||
<Field
|
||||
label={__("Role")}
|
||||
{...register("role")}
|
||||
type="text"
|
||||
error={formState.errors.role?.message}
|
||||
placeholder={__("e.g., Account Manager, Technical Support")}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogFooter>
|
||||
<Button type="submit" disabled={isLoading}>
|
||||
{__("Save")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
230
apps/console/src/pages/organizations/vendors/dialogs/__generated__/CreateContactDialogMutation.graphql.ts
generated
vendored
Normal file
230
apps/console/src/pages/organizations/vendors/dialogs/__generated__/CreateContactDialogMutation.graphql.ts
generated
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
/**
|
||||
* @generated SignedSource<<843a80b3503ff276081e69b558dcce81>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type CreateVendorContactInput = {
|
||||
email?: string | null | undefined;
|
||||
fullName?: string | null | undefined;
|
||||
phone?: string | null | undefined;
|
||||
role?: string | null | undefined;
|
||||
vendorId: string;
|
||||
};
|
||||
export type CreateContactDialogMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
input: CreateVendorContactInput;
|
||||
};
|
||||
export type CreateContactDialogMutation$data = {
|
||||
readonly createVendorContact: {
|
||||
readonly vendorContactEdge: {
|
||||
readonly node: {
|
||||
readonly " $fragmentSpreads": FragmentRefs<"VendorContactsTabFragment_contact">;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
export type CreateContactDialogMutation = {
|
||||
response: CreateContactDialogMutation$data;
|
||||
variables: CreateContactDialogMutation$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": "CreateContactDialogMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "CreateVendorContactPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "createVendorContact",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContactEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "vendorContactEdge",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContact",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "VendorContactsTabFragment_contact"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "CreateContactDialogMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "CreateVendorContactPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "createVendorContact",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContactEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "vendorContactEdge",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContact",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "email",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "phone",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "role",
|
||||
"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": "vendorContactEdge",
|
||||
"handleArgs": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "connections",
|
||||
"variableName": "connections"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "dac4774aa797162239a60596464811d8",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "CreateContactDialogMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation CreateContactDialogMutation(\n $input: CreateVendorContactInput!\n) {\n createVendorContact(input: $input) {\n vendorContactEdge {\n node {\n ...VendorContactsTabFragment_contact\n id\n }\n }\n }\n}\n\nfragment VendorContactsTabFragment_contact on VendorContact {\n id\n fullName\n email\n phone\n role\n createdAt\n updatedAt\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "f44f76bce42470683c55db50426d3f7b";
|
||||
|
||||
export default node;
|
||||
180
apps/console/src/pages/organizations/vendors/dialogs/__generated__/EditContactDialogUpdateMutation.graphql.ts
generated
vendored
Normal file
180
apps/console/src/pages/organizations/vendors/dialogs/__generated__/EditContactDialogUpdateMutation.graphql.ts
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* @generated SignedSource<<d22f20fafedcdddc50cd21917a8a5c28>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type UpdateVendorContactInput = {
|
||||
email?: string | null | undefined;
|
||||
fullName?: string | null | undefined;
|
||||
id: string;
|
||||
phone?: string | null | undefined;
|
||||
role?: string | null | undefined;
|
||||
};
|
||||
export type EditContactDialogUpdateMutation$variables = {
|
||||
input: UpdateVendorContactInput;
|
||||
};
|
||||
export type EditContactDialogUpdateMutation$data = {
|
||||
readonly updateVendorContact: {
|
||||
readonly vendorContact: {
|
||||
readonly " $fragmentSpreads": FragmentRefs<"VendorContactsTabFragment_contact">;
|
||||
};
|
||||
};
|
||||
};
|
||||
export type EditContactDialogUpdateMutation = {
|
||||
response: EditContactDialogUpdateMutation$data;
|
||||
variables: EditContactDialogUpdateMutation$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": "EditContactDialogUpdateMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": "UpdateVendorContactPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "updateVendorContact",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContact",
|
||||
"kind": "LinkedField",
|
||||
"name": "vendorContact",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "VendorContactsTabFragment_contact"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "EditContactDialogUpdateMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": "UpdateVendorContactPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "updateVendorContact",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContact",
|
||||
"kind": "LinkedField",
|
||||
"name": "vendorContact",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "email",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "phone",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "role",
|
||||
"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": "bacc163156572b5da49705a27084f5c9",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "EditContactDialogUpdateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation EditContactDialogUpdateMutation(\n $input: UpdateVendorContactInput!\n) {\n updateVendorContact(input: $input) {\n vendorContact {\n ...VendorContactsTabFragment_contact\n id\n }\n }\n}\n\nfragment VendorContactsTabFragment_contact on VendorContact {\n id\n fullName\n email\n phone\n role\n createdAt\n updatedAt\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "845750bb920bd01ed91bbae1531aaaf0";
|
||||
|
||||
export default node;
|
||||
251
apps/console/src/pages/organizations/vendors/tabs/VendorContactsTab.tsx
vendored
Normal file
251
apps/console/src/pages/organizations/vendors/tabs/VendorContactsTab.tsx
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
import { useOutletContext } from "react-router";
|
||||
import { graphql } from "relay-runtime";
|
||||
import type { VendorContactsTabFragment$key } from "./__generated__/VendorContactsTabFragment.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 { VendorContactsTabFragment_contact$key } from "./__generated__/VendorContactsTabFragment_contact.graphql";
|
||||
import { useMutationWithToasts } from "/hooks/useMutationWithToasts";
|
||||
import { sprintf } from "@probo/helpers";
|
||||
import { SortableTable, SortableTh } from "/components/SortableTable";
|
||||
import { CreateContactDialog } from "../dialogs/CreateContactDialog";
|
||||
import { EditContactDialog } from "../dialogs/EditContactDialog";
|
||||
import { useState } from "react";
|
||||
|
||||
export const vendorContactsFragment = graphql`
|
||||
fragment VendorContactsTabFragment on Vendor
|
||||
@refetchable(queryName: "VendorContactsListQuery")
|
||||
@argumentDefinitions(
|
||||
first: { type: "Int", defaultValue: 50 }
|
||||
order: { type: "VendorContactOrder", defaultValue: null }
|
||||
after: { type: "CursorKey", defaultValue: null }
|
||||
before: { type: "CursorKey", defaultValue: null }
|
||||
last: { type: "Int", defaultValue: null }
|
||||
) {
|
||||
contacts(
|
||||
first: $first
|
||||
after: $after
|
||||
last: $last
|
||||
before: $before
|
||||
orderBy: $order
|
||||
) @connection(key: "VendorContactsTabFragment_contacts") {
|
||||
__id
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
...VendorContactsTabFragment_contact
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const contactFragment = graphql`
|
||||
fragment VendorContactsTabFragment_contact on VendorContact {
|
||||
id
|
||||
fullName
|
||||
email
|
||||
phone
|
||||
role
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
`;
|
||||
|
||||
const deleteContactMutation = graphql`
|
||||
mutation VendorContactsTabDeleteContactMutation(
|
||||
$input: DeleteVendorContactInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
deleteVendorContact(input: $input) {
|
||||
deletedVendorContactId @deleteEdge(connections: $connections)
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default function VendorContactsTab() {
|
||||
const { vendor } = useOutletContext<{
|
||||
vendor: VendorContactsTabFragment$key & { name: string; id: string };
|
||||
}>();
|
||||
const [data, refetch] = useRefetchableFragment(
|
||||
vendorContactsFragment,
|
||||
vendor
|
||||
);
|
||||
const connectionId = data.contacts.__id;
|
||||
const contacts = data.contacts.edges.map((edge) => edge.node);
|
||||
const { __ } = useTranslate();
|
||||
const [editingContact, setEditingContact] = useState<{
|
||||
id: string;
|
||||
fullName?: string | null;
|
||||
email?: string | null;
|
||||
phone?: string | null;
|
||||
role?: string | null;
|
||||
} | null>(null);
|
||||
|
||||
usePageTitle(vendor.name + " - " + __("Contacts"));
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<PageHeader
|
||||
title={__("Contacts")}
|
||||
description={__("Manage vendor contacts and their information.")}
|
||||
>
|
||||
<CreateContactDialog
|
||||
vendorId={vendor.id}
|
||||
connectionId={connectionId}
|
||||
>
|
||||
<Button icon={IconPlusLarge}>{__("Add contact")}</Button>
|
||||
</CreateContactDialog>
|
||||
</PageHeader>
|
||||
|
||||
<SortableTable refetch={refetch}>
|
||||
<Thead>
|
||||
<Tr>
|
||||
<SortableTh field="FULL_NAME">{__("Name")}</SortableTh>
|
||||
<SortableTh field="EMAIL">{__("Email")}</SortableTh>
|
||||
<Th>{__("Phone")}</Th>
|
||||
<Th>{__("Role")}</Th>
|
||||
<SortableTh field="CREATED_AT">{__("Created")}</SortableTh>
|
||||
<Th>{__("Actions")}</Th>
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{contacts.map((contact) => (
|
||||
<ContactRow
|
||||
key={contact.id}
|
||||
contactKey={contact}
|
||||
connectionId={connectionId}
|
||||
onEdit={setEditingContact}
|
||||
/>
|
||||
))}
|
||||
</Tbody>
|
||||
</SortableTable>
|
||||
|
||||
{editingContact && (
|
||||
<EditContactDialog
|
||||
contactId={editingContact.id}
|
||||
contact={editingContact}
|
||||
onClose={() => setEditingContact(null)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
type ContactRowProps = {
|
||||
contactKey: VendorContactsTabFragment_contact$key;
|
||||
connectionId: string;
|
||||
onEdit: (contact: {
|
||||
id: string;
|
||||
fullName?: string | null;
|
||||
email?: string | null;
|
||||
phone?: string | null;
|
||||
role?: string | null;
|
||||
}) => void;
|
||||
};
|
||||
|
||||
function ContactRow(props: ContactRowProps) {
|
||||
const { __ } = useTranslate();
|
||||
const contact = useFragment<VendorContactsTabFragment_contact$key>(
|
||||
contactFragment,
|
||||
props.contactKey
|
||||
);
|
||||
const { dateFormat } = useTranslate();
|
||||
const confirm = useConfirm();
|
||||
const [deleteContact] = useMutationWithToasts(deleteContactMutation, {
|
||||
successMessage: __("Contact deleted successfully"),
|
||||
errorMessage: __("Failed to delete contact"),
|
||||
});
|
||||
|
||||
const handleDelete = () => {
|
||||
confirm(
|
||||
() =>
|
||||
deleteContact({
|
||||
variables: {
|
||||
connections: [props.connectionId],
|
||||
input: {
|
||||
vendorContactId: contact.id,
|
||||
},
|
||||
},
|
||||
}),
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
'This will permanently delete the contact "%s". This action cannot be undone.'
|
||||
),
|
||||
contact.fullName || contact.email || __("Unnamed contact")
|
||||
),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Tr>
|
||||
<Td>{contact.fullName || __("—")}</Td>
|
||||
<Td>
|
||||
{contact.email ? (
|
||||
<a
|
||||
href={`mailto:${contact.email}`}
|
||||
className="text-primary-600 hover:text-primary-800"
|
||||
>
|
||||
{contact.email}
|
||||
</a>
|
||||
) : (
|
||||
__("—")
|
||||
)}
|
||||
</Td>
|
||||
<Td>
|
||||
{contact.phone ? (
|
||||
<a
|
||||
href={`tel:${contact.phone}`}
|
||||
className="text-primary-600 hover:text-primary-800"
|
||||
>
|
||||
{contact.phone}
|
||||
</a>
|
||||
) : (
|
||||
__("—")
|
||||
)}
|
||||
</Td>
|
||||
<Td>{contact.role || __("—")}</Td>
|
||||
<Td>{dateFormat(contact.createdAt)}</Td>
|
||||
<Td width={50} className="text-end">
|
||||
<ActionDropdown>
|
||||
<DropdownItem
|
||||
icon={IconPencil}
|
||||
onClick={() => props.onEdit({
|
||||
id: contact.id,
|
||||
fullName: contact.fullName,
|
||||
email: contact.email,
|
||||
phone: contact.phone,
|
||||
role: contact.role,
|
||||
})}
|
||||
>
|
||||
{__("Edit")}
|
||||
</DropdownItem>
|
||||
<DropdownItem
|
||||
icon={IconTrashCan}
|
||||
onClick={handleDelete}
|
||||
variant="danger"
|
||||
>
|
||||
{__("Delete")}
|
||||
</DropdownItem>
|
||||
</ActionDropdown>
|
||||
</Td>
|
||||
</Tr>
|
||||
);
|
||||
}
|
||||
358
apps/console/src/pages/organizations/vendors/tabs/__generated__/VendorContactsListQuery.graphql.ts
generated
vendored
Normal file
358
apps/console/src/pages/organizations/vendors/tabs/__generated__/VendorContactsListQuery.graphql.ts
generated
vendored
Normal file
@@ -0,0 +1,358 @@
|
||||
/**
|
||||
* @generated SignedSource<<65134b167a4268ed8064021f2c608899>>
|
||||
* @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 VendorContactOrderField = "CREATED_AT" | "EMAIL" | "FULL_NAME";
|
||||
export type VendorContactOrder = {
|
||||
direction: OrderDirection;
|
||||
field: VendorContactOrderField;
|
||||
};
|
||||
export type VendorContactsListQuery$variables = {
|
||||
after?: any | null | undefined;
|
||||
before?: any | null | undefined;
|
||||
first?: number | null | undefined;
|
||||
id: string;
|
||||
last?: number | null | undefined;
|
||||
order?: VendorContactOrder | null | undefined;
|
||||
};
|
||||
export type VendorContactsListQuery$data = {
|
||||
readonly node: {
|
||||
readonly " $fragmentSpreads": FragmentRefs<"VendorContactsTabFragment">;
|
||||
};
|
||||
};
|
||||
export type VendorContactsListQuery = {
|
||||
response: VendorContactsListQuery$data;
|
||||
variables: VendorContactsListQuery$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": "VendorContactsListQuery",
|
||||
"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": "VendorContactsTabFragment"
|
||||
}
|
||||
],
|
||||
"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": "VendorContactsListQuery",
|
||||
"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": "VendorContactConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "contacts",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContactEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContact",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v12/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "email",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "phone",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "role",
|
||||
"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": "VendorContactsTabFragment_contacts",
|
||||
"kind": "LinkedHandle",
|
||||
"name": "contacts"
|
||||
}
|
||||
],
|
||||
"type": "Vendor",
|
||||
"abstractKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "bc07b88571f6a7fbb20595cbf442d3b8",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "VendorContactsListQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query VendorContactsListQuery(\n $after: CursorKey = null\n $before: CursorKey = null\n $first: Int = 50\n $last: Int = null\n $order: VendorContactOrder = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...VendorContactsTabFragment_16fISc\n id\n }\n}\n\nfragment VendorContactsTabFragment_16fISc on Vendor {\n contacts(first: $first, after: $after, last: $last, before: $before, orderBy: $order) {\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"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "aa8ba87386ba04dd624566661fe0a524";
|
||||
|
||||
export default node;
|
||||
132
apps/console/src/pages/organizations/vendors/tabs/__generated__/VendorContactsTabDeleteContactMutation.graphql.ts
generated
vendored
Normal file
132
apps/console/src/pages/organizations/vendors/tabs/__generated__/VendorContactsTabDeleteContactMutation.graphql.ts
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* @generated SignedSource<<3824bce11d22a60d1e50f53c699611c5>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type DeleteVendorContactInput = {
|
||||
vendorContactId: string;
|
||||
};
|
||||
export type VendorContactsTabDeleteContactMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
input: DeleteVendorContactInput;
|
||||
};
|
||||
export type VendorContactsTabDeleteContactMutation$data = {
|
||||
readonly deleteVendorContact: {
|
||||
readonly deletedVendorContactId: string;
|
||||
};
|
||||
};
|
||||
export type VendorContactsTabDeleteContactMutation = {
|
||||
response: VendorContactsTabDeleteContactMutation$data;
|
||||
variables: VendorContactsTabDeleteContactMutation$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": "deletedVendorContactId",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "VendorContactsTabDeleteContactMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "DeleteVendorContactPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "deleteVendorContact",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "VendorContactsTabDeleteContactMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "DeleteVendorContactPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "deleteVendorContact",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"filters": null,
|
||||
"handle": "deleteEdge",
|
||||
"key": "",
|
||||
"kind": "ScalarHandle",
|
||||
"name": "deletedVendorContactId",
|
||||
"handleArgs": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "connections",
|
||||
"variableName": "connections"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "806c0b076e6da2ac4841d172047c8655",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "VendorContactsTabDeleteContactMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation VendorContactsTabDeleteContactMutation(\n $input: DeleteVendorContactInput!\n) {\n deleteVendorContact(input: $input) {\n deletedVendorContactId\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "f0595bed2e2e7527eeac8737a0640a4d";
|
||||
|
||||
export default node;
|
||||
225
apps/console/src/pages/organizations/vendors/tabs/__generated__/VendorContactsTabFragment.graphql.ts
generated
vendored
Normal file
225
apps/console/src/pages/organizations/vendors/tabs/__generated__/VendorContactsTabFragment.graphql.ts
generated
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
* @generated SignedSource<<6aea0078adcf4d7180d89dbf964eaceb>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ReaderFragment } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type VendorContactsTabFragment$data = {
|
||||
readonly contacts: {
|
||||
readonly __id: string;
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly id: string;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"VendorContactsTabFragment_contact">;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
readonly id: string;
|
||||
readonly " $fragmentType": "VendorContactsTabFragment";
|
||||
};
|
||||
export type VendorContactsTabFragment$key = {
|
||||
readonly " $data"?: VendorContactsTabFragment$data;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"VendorContactsTabFragment">;
|
||||
};
|
||||
|
||||
import VendorContactsListQuery_graphql from './VendorContactsListQuery.graphql';
|
||||
|
||||
const node: ReaderFragment = (function(){
|
||||
var v0 = [
|
||||
"contacts"
|
||||
],
|
||||
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": VendorContactsListQuery_graphql,
|
||||
"identifierInfo": {
|
||||
"identifierField": "id",
|
||||
"identifierQueryVariableName": "id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "VendorContactsTabFragment",
|
||||
"selections": [
|
||||
{
|
||||
"alias": "contacts",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "orderBy",
|
||||
"variableName": "order"
|
||||
}
|
||||
],
|
||||
"concreteType": "VendorContactConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "__VendorContactsTabFragment_contacts_connection",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContactEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "VendorContact",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v1/*: any*/),
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "VendorContactsTabFragment_contact"
|
||||
},
|
||||
{
|
||||
"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 = "aa8ba87386ba04dd624566661fe0a524";
|
||||
|
||||
export default node;
|
||||
90
apps/console/src/pages/organizations/vendors/tabs/__generated__/VendorContactsTabFragment_contact.graphql.ts
generated
vendored
Normal file
90
apps/console/src/pages/organizations/vendors/tabs/__generated__/VendorContactsTabFragment_contact.graphql.ts
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @generated SignedSource<<28eef433ba6749a95468492e8ac9d1a6>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ReaderFragment } from 'relay-runtime';
|
||||
import { FragmentRefs } from "relay-runtime";
|
||||
export type VendorContactsTabFragment_contact$data = {
|
||||
readonly createdAt: any;
|
||||
readonly email: string | null | undefined;
|
||||
readonly fullName: string | null | undefined;
|
||||
readonly id: string;
|
||||
readonly phone: string | null | undefined;
|
||||
readonly role: string | null | undefined;
|
||||
readonly updatedAt: any;
|
||||
readonly " $fragmentType": "VendorContactsTabFragment_contact";
|
||||
};
|
||||
export type VendorContactsTabFragment_contact$key = {
|
||||
readonly " $data"?: VendorContactsTabFragment_contact$data;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"VendorContactsTabFragment_contact">;
|
||||
};
|
||||
|
||||
const node: ReaderFragment = {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "VendorContactsTabFragment_contact",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "fullName",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "email",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "phone",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "role",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "VendorContact",
|
||||
"abstractKey": null
|
||||
};
|
||||
|
||||
(node as any).hash = "9c3e5b8b262263249160f5fd3708162a";
|
||||
|
||||
export default node;
|
||||
@@ -61,6 +61,14 @@ export const vendorRoutes = [
|
||||
)
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "contacts",
|
||||
fallback: LinkCardSkeleton,
|
||||
Component: lazy(
|
||||
() =>
|
||||
import("../pages/organizations/vendors/tabs/VendorContactsTab")
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
] satisfies AppRoute[];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export { objectKeys, objectEntries } from "./object";
|
||||
export { objectKeys, objectEntries, cleanFormData } from "./object";
|
||||
export { sprintf, faviconUrl, slugify } from "./string";
|
||||
export {
|
||||
getTreatment,
|
||||
|
||||
@@ -8,3 +8,15 @@ export function objectKeys<T extends Record<string, unknown>>(object: T) {
|
||||
export function objectEntries<T extends Record<string, unknown>>(object: T) {
|
||||
return Object.entries(object) as [keyof T, T[keyof T]][];
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims string values and converts empty strings to null in form data objects
|
||||
*/
|
||||
export function cleanFormData<T extends Record<string, any>>(data: T): T {
|
||||
return Object.fromEntries(
|
||||
Object.entries(data).map(([k, v]) => {
|
||||
const trimmed = typeof v === 'string' ? v.trim() : v;
|
||||
return [k, trimmed === "" ? null : trimmed];
|
||||
})
|
||||
) as T;
|
||||
}
|
||||
|
||||
@@ -41,4 +41,5 @@ const (
|
||||
TrustCenterAccessEntityType
|
||||
VendorBusinessAssociateAgreementEntityType
|
||||
FileEntityType
|
||||
VendorContactEntityType
|
||||
)
|
||||
|
||||
17
pkg/coredata/migrations/20250813T160929Z.sql
Normal file
17
pkg/coredata/migrations/20250813T160929Z.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
CREATE TABLE vendor_contacts (
|
||||
id TEXT PRIMARY KEY,
|
||||
tenant_id TEXT NOT NULL,
|
||||
vendor_id TEXT NOT NULL,
|
||||
full_name TEXT,
|
||||
email CITEXT,
|
||||
phone TEXT,
|
||||
role TEXT,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
|
||||
CONSTRAINT vendor_contacts_vendor_id_fkey
|
||||
FOREIGN KEY (vendor_id)
|
||||
REFERENCES vendors(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
277
pkg/coredata/vendor_contact.go
Normal file
277
pkg/coredata/vendor_contact.go
Normal file
@@ -0,0 +1,277 @@
|
||||
// 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 (
|
||||
VendorContact struct {
|
||||
ID gid.GID `db:"id"`
|
||||
VendorID gid.GID `db:"vendor_id"`
|
||||
FullName *string `db:"full_name"`
|
||||
Email *string `db:"email"`
|
||||
Phone *string `db:"phone"`
|
||||
Role *string `db:"role"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
VendorContacts []*VendorContact
|
||||
|
||||
ErrVendorContactNotFound struct {
|
||||
Identifier string
|
||||
}
|
||||
)
|
||||
|
||||
func (e ErrVendorContactNotFound) Error() string {
|
||||
return fmt.Sprintf("vendor contact not found: %s", e.Identifier)
|
||||
}
|
||||
|
||||
func (vc VendorContact) CursorKey(orderBy VendorContactOrderField) page.CursorKey {
|
||||
switch orderBy {
|
||||
case VendorContactOrderFieldCreatedAt:
|
||||
return page.CursorKey{ID: vc.ID, Value: vc.CreatedAt}
|
||||
case VendorContactOrderFieldFullName:
|
||||
return page.CursorKey{ID: vc.ID, Value: vc.FullName}
|
||||
case VendorContactOrderFieldEmail:
|
||||
return page.CursorKey{ID: vc.ID, Value: vc.Email}
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||
}
|
||||
|
||||
func (vc *VendorContact) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
vendorContactID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
vendor_id,
|
||||
full_name,
|
||||
email,
|
||||
phone,
|
||||
role,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
vendor_contacts
|
||||
WHERE
|
||||
%s
|
||||
AND id = @vendor_contact_id
|
||||
LIMIT 1;
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"vendor_contact_id": vendorContactID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query vendor contact: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
vendorContact, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[VendorContact])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrVendorContactNotFound{Identifier: vendorContactID.String()}
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect vendor contact: %w", err)
|
||||
}
|
||||
|
||||
*vc = vendorContact
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vc *VendorContacts) LoadByVendorID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
vendorID gid.GID,
|
||||
cursor *page.Cursor[VendorContactOrderField],
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
vendor_id,
|
||||
full_name,
|
||||
email,
|
||||
phone,
|
||||
role,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
vendor_contacts
|
||||
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 contacts: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
vendorContacts, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[VendorContact])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect vendor contacts: %w", err)
|
||||
}
|
||||
|
||||
*vc = vendorContacts
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vc VendorContact) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
INSERT INTO
|
||||
vendor_contacts (
|
||||
tenant_id,
|
||||
id,
|
||||
vendor_id,
|
||||
full_name,
|
||||
email,
|
||||
phone,
|
||||
role,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
VALUES (
|
||||
@tenant_id,
|
||||
@vendor_contact_id,
|
||||
@vendor_id,
|
||||
@full_name,
|
||||
@email,
|
||||
@phone,
|
||||
@role,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"vendor_contact_id": vc.ID,
|
||||
"vendor_id": vc.VendorID,
|
||||
"full_name": vc.FullName,
|
||||
"email": vc.Email,
|
||||
"phone": vc.Phone,
|
||||
"role": vc.Role,
|
||||
"created_at": vc.CreatedAt,
|
||||
"updated_at": vc.UpdatedAt,
|
||||
}
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot insert vendor contact: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vc VendorContact) Update(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
UPDATE
|
||||
vendor_contacts
|
||||
SET
|
||||
full_name = @full_name,
|
||||
email = @email,
|
||||
phone = @phone,
|
||||
role = @role,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
AND id = @vendor_contact_id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"vendor_contact_id": vc.ID,
|
||||
"full_name": vc.FullName,
|
||||
"email": vc.Email,
|
||||
"phone": vc.Phone,
|
||||
"role": vc.Role,
|
||||
"updated_at": vc.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update vendor contact: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vc VendorContact) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
DELETE FROM
|
||||
vendor_contacts
|
||||
WHERE
|
||||
%s
|
||||
AND id = @vendor_contact_id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"vendor_contact_id": vc.ID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete vendor contact: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
42
pkg/coredata/vendor_contact_order_field.go
Normal file
42
pkg/coredata/vendor_contact_order_field.go
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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
|
||||
|
||||
type (
|
||||
VendorContactOrderField string
|
||||
)
|
||||
|
||||
const (
|
||||
VendorContactOrderFieldCreatedAt VendorContactOrderField = "CREATED_AT"
|
||||
VendorContactOrderFieldFullName VendorContactOrderField = "FULL_NAME"
|
||||
VendorContactOrderFieldEmail VendorContactOrderField = "EMAIL"
|
||||
)
|
||||
|
||||
func (p VendorContactOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p VendorContactOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p VendorContactOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *VendorContactOrderField) UnmarshalText(text []byte) error {
|
||||
*p = VendorContactOrderField(text)
|
||||
return nil
|
||||
}
|
||||
@@ -72,6 +72,7 @@ type (
|
||||
Risks *RiskService
|
||||
VendorComplianceReports *VendorComplianceReportService
|
||||
VendorBusinessAssociateAgreements *VendorBusinessAssociateAgreementService
|
||||
VendorContacts *VendorContactService
|
||||
Connectors *ConnectorService
|
||||
Assets *AssetService
|
||||
Data *DatumService
|
||||
@@ -159,6 +160,7 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
|
||||
tenantService.Risks = &RiskService{svc: tenantService}
|
||||
tenantService.VendorComplianceReports = &VendorComplianceReportService{svc: tenantService}
|
||||
tenantService.VendorBusinessAssociateAgreements = &VendorBusinessAssociateAgreementService{svc: tenantService}
|
||||
tenantService.VendorContacts = &VendorContactService{svc: tenantService}
|
||||
tenantService.Connectors = &ConnectorService{svc: tenantService}
|
||||
tenantService.Assets = &AssetService{svc: tenantService}
|
||||
tenantService.Data = &DatumService{svc: tenantService}
|
||||
|
||||
183
pkg/probo/vendor_contact_service.go
Normal file
183
pkg/probo/vendor_contact_service.go
Normal file
@@ -0,0 +1,183 @@
|
||||
// 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 (
|
||||
VendorContactService struct {
|
||||
svc *TenantService
|
||||
}
|
||||
|
||||
CreateVendorContactRequest struct {
|
||||
VendorID gid.GID
|
||||
FullName *string
|
||||
Email *string
|
||||
Phone *string
|
||||
Role *string
|
||||
}
|
||||
|
||||
UpdateVendorContactRequest struct {
|
||||
ID gid.GID
|
||||
FullName **string
|
||||
Email **string
|
||||
Phone **string
|
||||
Role **string
|
||||
}
|
||||
)
|
||||
|
||||
func (s VendorContactService) Get(
|
||||
ctx context.Context,
|
||||
vendorContactID gid.GID,
|
||||
) (*coredata.VendorContact, error) {
|
||||
vendorContact := &coredata.VendorContact{}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
return vendorContact.LoadByID(ctx, conn, s.svc.scope, vendorContactID)
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vendorContact, nil
|
||||
}
|
||||
|
||||
func (s VendorContactService) List(
|
||||
ctx context.Context,
|
||||
vendorID gid.GID,
|
||||
cursor *page.Cursor[coredata.VendorContactOrderField],
|
||||
) (*page.Page[*coredata.VendorContact, coredata.VendorContactOrderField], error) {
|
||||
var vendorContacts coredata.VendorContacts
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
return vendorContacts.LoadByVendorID(ctx, conn, s.svc.scope, vendorID, cursor)
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return page.NewPage(vendorContacts, cursor), nil
|
||||
}
|
||||
|
||||
func (s VendorContactService) Create(
|
||||
ctx context.Context,
|
||||
req CreateVendorContactRequest,
|
||||
) (*coredata.VendorContact, error) {
|
||||
now := time.Now()
|
||||
vendorContact := &coredata.VendorContact{
|
||||
ID: gid.New(s.svc.scope.GetTenantID(), coredata.VendorContactEntityType),
|
||||
VendorID: req.VendorID,
|
||||
FullName: req.FullName,
|
||||
Email: req.Email,
|
||||
Phone: req.Phone,
|
||||
Role: req.Role,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
if err := vendorContact.Insert(ctx, conn, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot insert vendor contact: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vendorContact, nil
|
||||
}
|
||||
|
||||
func (s VendorContactService) Update(
|
||||
ctx context.Context,
|
||||
req UpdateVendorContactRequest,
|
||||
) (*coredata.VendorContact, error) {
|
||||
vendorContact := &coredata.VendorContact{}
|
||||
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := vendorContact.LoadByID(ctx, conn, s.svc.scope, req.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load vendor contact: %w", err)
|
||||
}
|
||||
|
||||
if req.FullName != nil {
|
||||
vendorContact.FullName = *req.FullName
|
||||
}
|
||||
if req.Email != nil {
|
||||
vendorContact.Email = *req.Email
|
||||
}
|
||||
if req.Phone != nil {
|
||||
vendorContact.Phone = *req.Phone
|
||||
}
|
||||
if req.Role != nil {
|
||||
vendorContact.Role = *req.Role
|
||||
}
|
||||
vendorContact.UpdatedAt = time.Now()
|
||||
|
||||
return vendorContact.Update(ctx, conn, s.svc.scope)
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vendorContact, nil
|
||||
}
|
||||
|
||||
func (s VendorContactService) Delete(
|
||||
ctx context.Context,
|
||||
vendorContactID gid.GID,
|
||||
) error {
|
||||
vendorContact := coredata.VendorContact{ID: vendorContactID}
|
||||
return s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
if err := vendorContact.LoadByID(ctx, conn, s.svc.scope, vendorContactID); err != nil {
|
||||
return fmt.Errorf("cannot load vendor contact: %w", err)
|
||||
}
|
||||
|
||||
if err := vendorContact.Delete(ctx, conn, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot delete vendor contact: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -292,6 +292,24 @@ enum VendorComplianceReportOrderField
|
||||
)
|
||||
}
|
||||
|
||||
enum VendorContactOrderField
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/coredata.VendorContactOrderField"
|
||||
) {
|
||||
CREATED_AT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.VendorContactOrderFieldCreatedAt"
|
||||
)
|
||||
FULL_NAME
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.VendorContactOrderFieldFullName"
|
||||
)
|
||||
EMAIL
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.VendorContactOrderFieldEmail"
|
||||
)
|
||||
}
|
||||
|
||||
enum OrganizationOrderField
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/coredata.OrganizationOrderField"
|
||||
@@ -679,6 +697,14 @@ input VendorComplianceReportOrder
|
||||
field: VendorComplianceReportOrderField!
|
||||
}
|
||||
|
||||
input VendorContactOrder
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.VendorContactOrderBy"
|
||||
) {
|
||||
direction: OrderDirection!
|
||||
field: VendorContactOrderField!
|
||||
}
|
||||
|
||||
input OrganizationOrder {
|
||||
direction: OrderDirection!
|
||||
field: OrganizationOrderField!
|
||||
@@ -917,6 +943,14 @@ type Vendor implements Node {
|
||||
|
||||
businessAssociateAgreement: VendorBusinessAssociateAgreement @goField(forceResolver: true)
|
||||
|
||||
contacts(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: VendorContactOrder
|
||||
): VendorContactConnection! @goField(forceResolver: true)
|
||||
|
||||
riskAssessments(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
@@ -970,6 +1004,17 @@ type VendorBusinessAssociateAgreement implements Node {
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type VendorContact implements Node {
|
||||
id: ID!
|
||||
vendor: Vendor! @goField(forceResolver: true)
|
||||
fullName: String
|
||||
email: String
|
||||
phone: String
|
||||
role: String
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type Framework implements Node {
|
||||
id: ID!
|
||||
name: String!
|
||||
@@ -1418,6 +1463,16 @@ type VendorComplianceReportEdge {
|
||||
node: VendorComplianceReport!
|
||||
}
|
||||
|
||||
type VendorContactConnection {
|
||||
edges: [VendorContactEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
}
|
||||
|
||||
type VendorContactEdge {
|
||||
cursor: CursorKey!
|
||||
node: VendorContact!
|
||||
}
|
||||
|
||||
type ConnectorConnection {
|
||||
edges: [ConnectorEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
@@ -1529,6 +1584,11 @@ type Mutation {
|
||||
updateVendor(input: UpdateVendorInput!): UpdateVendorPayload!
|
||||
deleteVendor(input: DeleteVendorInput!): DeleteVendorPayload!
|
||||
|
||||
# Vendor Contact mutations
|
||||
createVendorContact(input: CreateVendorContactInput!): CreateVendorContactPayload!
|
||||
updateVendorContact(input: UpdateVendorContactInput!): UpdateVendorContactPayload!
|
||||
deleteVendorContact(input: DeleteVendorContactInput!): DeleteVendorContactPayload!
|
||||
|
||||
# Framework mutations
|
||||
createFramework(input: CreateFrameworkInput!): CreateFrameworkPayload!
|
||||
updateFramework(input: UpdateFrameworkInput!): UpdateFrameworkPayload!
|
||||
@@ -1763,6 +1823,26 @@ input DeleteVendorInput {
|
||||
vendorId: ID!
|
||||
}
|
||||
|
||||
input CreateVendorContactInput {
|
||||
vendorId: ID!
|
||||
fullName: String
|
||||
email: String
|
||||
phone: String
|
||||
role: String
|
||||
}
|
||||
|
||||
input UpdateVendorContactInput {
|
||||
id: ID!
|
||||
fullName: String
|
||||
email: String
|
||||
phone: String
|
||||
role: String
|
||||
}
|
||||
|
||||
input DeleteVendorContactInput {
|
||||
vendorContactId: ID!
|
||||
}
|
||||
|
||||
input CreatePeopleInput {
|
||||
organizationId: ID!
|
||||
fullName: String!
|
||||
@@ -2135,6 +2215,18 @@ type DeleteVendorPayload {
|
||||
deletedVendorId: ID!
|
||||
}
|
||||
|
||||
type CreateVendorContactPayload {
|
||||
vendorContactEdge: VendorContactEdge!
|
||||
}
|
||||
|
||||
type UpdateVendorContactPayload {
|
||||
vendorContact: VendorContact!
|
||||
}
|
||||
|
||||
type DeleteVendorContactPayload {
|
||||
deletedVendorContactId: ID!
|
||||
}
|
||||
|
||||
type CreatePeoplePayload {
|
||||
peopleEdge: PeopleEdge!
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -377,6 +377,18 @@ type CreateTrustCenterAccessPayload struct {
|
||||
TrustCenterAccessEdge *TrustCenterAccessEdge `json:"trustCenterAccessEdge"`
|
||||
}
|
||||
|
||||
type CreateVendorContactInput struct {
|
||||
VendorID gid.GID `json:"vendorId"`
|
||||
FullName *string `json:"fullName,omitempty"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
Phone *string `json:"phone,omitempty"`
|
||||
Role *string `json:"role,omitempty"`
|
||||
}
|
||||
|
||||
type CreateVendorContactPayload struct {
|
||||
VendorContactEdge *VendorContactEdge `json:"vendorContactEdge"`
|
||||
}
|
||||
|
||||
type CreateVendorInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Name string `json:"name"`
|
||||
@@ -611,6 +623,14 @@ type DeleteVendorComplianceReportPayload struct {
|
||||
DeletedVendorComplianceReportID gid.GID `json:"deletedVendorComplianceReportId"`
|
||||
}
|
||||
|
||||
type DeleteVendorContactInput struct {
|
||||
VendorContactID gid.GID `json:"vendorContactId"`
|
||||
}
|
||||
|
||||
type DeleteVendorContactPayload struct {
|
||||
DeletedVendorContactID gid.GID `json:"deletedVendorContactId"`
|
||||
}
|
||||
|
||||
type DeleteVendorInput struct {
|
||||
VendorID gid.GID `json:"vendorId"`
|
||||
}
|
||||
@@ -1274,6 +1294,18 @@ type UpdateVendorBusinessAssociateAgreementPayload struct {
|
||||
VendorBusinessAssociateAgreement *VendorBusinessAssociateAgreement `json:"vendorBusinessAssociateAgreement"`
|
||||
}
|
||||
|
||||
type UpdateVendorContactInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
FullName *string `json:"fullName,omitempty"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
Phone *string `json:"phone,omitempty"`
|
||||
Role *string `json:"role,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateVendorContactPayload struct {
|
||||
VendorContact *VendorContact `json:"vendorContact"`
|
||||
}
|
||||
|
||||
type UpdateVendorInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
@@ -1382,6 +1414,7 @@ type Vendor struct {
|
||||
Organization *Organization `json:"organization"`
|
||||
ComplianceReports *VendorComplianceReportConnection `json:"complianceReports"`
|
||||
BusinessAssociateAgreement *VendorBusinessAssociateAgreement `json:"businessAssociateAgreement,omitempty"`
|
||||
Contacts *VendorContactConnection `json:"contacts"`
|
||||
RiskAssessments *VendorRiskAssessmentConnection `json:"riskAssessments"`
|
||||
BusinessOwner *People `json:"businessOwner,omitempty"`
|
||||
SecurityOwner *People `json:"securityOwner,omitempty"`
|
||||
@@ -1446,6 +1479,30 @@ type VendorComplianceReportEdge struct {
|
||||
Node *VendorComplianceReport `json:"node"`
|
||||
}
|
||||
|
||||
type VendorContact struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Vendor *Vendor `json:"vendor"`
|
||||
FullName *string `json:"fullName,omitempty"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
Phone *string `json:"phone,omitempty"`
|
||||
Role *string `json:"role,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (VendorContact) IsNode() {}
|
||||
func (this VendorContact) GetID() gid.GID { return this.ID }
|
||||
|
||||
type VendorContactConnection struct {
|
||||
Edges []*VendorContactEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type VendorContactEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *VendorContact `json:"node"`
|
||||
}
|
||||
|
||||
type VendorEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *Vendor `json:"node"`
|
||||
|
||||
56
pkg/server/api/console/v1/types/vendor_contact.go
Normal file
56
pkg/server/api/console/v1/types/vendor_contact.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// 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 (
|
||||
VendorContactOrderBy OrderBy[coredata.VendorContactOrderField]
|
||||
)
|
||||
|
||||
func NewVendorContactConnection(p *page.Page[*coredata.VendorContact, coredata.VendorContactOrderField]) *VendorContactConnection {
|
||||
var edges = make([]*VendorContactEdge, len(p.Data))
|
||||
|
||||
for i := range edges {
|
||||
edges[i] = NewVendorContactEdge(p.Data[i], p.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &VendorContactConnection{
|
||||
Edges: edges,
|
||||
PageInfo: NewPageInfo(p),
|
||||
}
|
||||
}
|
||||
|
||||
func NewVendorContactEdge(c *coredata.VendorContact, orderBy coredata.VendorContactOrderField) *VendorContactEdge {
|
||||
return &VendorContactEdge{
|
||||
Cursor: c.CursorKey(orderBy),
|
||||
Node: NewVendorContact(c),
|
||||
}
|
||||
}
|
||||
|
||||
func NewVendorContact(c *coredata.VendorContact) *VendorContact {
|
||||
return &VendorContact{
|
||||
ID: c.ID,
|
||||
FullName: c.FullName,
|
||||
Email: c.Email,
|
||||
Phone: c.Phone,
|
||||
Role: c.Role,
|
||||
CreatedAt: c.CreatedAt,
|
||||
UpdatedAt: c.UpdatedAt,
|
||||
}
|
||||
}
|
||||
@@ -1250,6 +1250,64 @@ func (r *mutationResolver) DeleteVendor(ctx context.Context, input types.DeleteV
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateVendorContact is the resolver for the createVendorContact field.
|
||||
func (r *mutationResolver) CreateVendorContact(ctx context.Context, input types.CreateVendorContactInput) (*types.CreateVendorContactPayload, error) {
|
||||
prb := r.ProboService(ctx, input.VendorID.TenantID())
|
||||
|
||||
req := probo.CreateVendorContactRequest{
|
||||
VendorID: input.VendorID,
|
||||
FullName: input.FullName,
|
||||
Email: input.Email,
|
||||
Phone: input.Phone,
|
||||
Role: input.Role,
|
||||
}
|
||||
|
||||
vendorContact, err := prb.VendorContacts.Create(ctx, req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create vendor contact: %w", err)
|
||||
}
|
||||
|
||||
return &types.CreateVendorContactPayload{
|
||||
VendorContactEdge: types.NewVendorContactEdge(vendorContact, coredata.VendorContactOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateVendorContact is the resolver for the updateVendorContact field.
|
||||
func (r *mutationResolver) UpdateVendorContact(ctx context.Context, input types.UpdateVendorContactInput) (*types.UpdateVendorContactPayload, error) {
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
|
||||
req := probo.UpdateVendorContactRequest{
|
||||
ID: input.ID,
|
||||
FullName: &input.FullName,
|
||||
Email: &input.Email,
|
||||
Phone: &input.Phone,
|
||||
Role: &input.Role,
|
||||
}
|
||||
|
||||
vendorContact, err := prb.VendorContacts.Update(ctx, req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to update vendor contact: %w", err)
|
||||
}
|
||||
|
||||
return &types.UpdateVendorContactPayload{
|
||||
VendorContact: types.NewVendorContact(vendorContact),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteVendorContact is the resolver for the deleteVendorContact field.
|
||||
func (r *mutationResolver) DeleteVendorContact(ctx context.Context, input types.DeleteVendorContactInput) (*types.DeleteVendorContactPayload, error) {
|
||||
prb := r.ProboService(ctx, input.VendorContactID.TenantID())
|
||||
|
||||
err := prb.VendorContacts.Delete(ctx, input.VendorContactID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to delete vendor contact: %w", err)
|
||||
}
|
||||
|
||||
return &types.DeleteVendorContactPayload{
|
||||
DeletedVendorContactID: input.VendorContactID,
|
||||
}, 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())
|
||||
@@ -2972,6 +3030,12 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
panic(fmt.Errorf("cannot get vendor compliance report: %w", err))
|
||||
}
|
||||
return types.NewVendorComplianceReport(vendorComplianceReport), nil
|
||||
case coredata.VendorContactEntityType:
|
||||
vendorContact, err := prb.VendorContacts.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get vendor contact: %w", err))
|
||||
}
|
||||
return types.NewVendorContact(vendorContact), nil
|
||||
case coredata.DocumentVersionEntityType:
|
||||
documentVersion, err := prb.Documents.GetVersion(ctx, id)
|
||||
if err != nil {
|
||||
@@ -3405,6 +3469,31 @@ func (r *vendorResolver) BusinessAssociateAgreement(ctx context.Context, obj *ty
|
||||
return types.NewVendorBusinessAssociateAgreement(vendorBusinessAssociateAgreement, file), nil
|
||||
}
|
||||
|
||||
// Contacts is the resolver for the contacts field.
|
||||
func (r *vendorResolver) Contacts(ctx context.Context, obj *types.Vendor, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorContactOrderBy) (*types.VendorContactConnection, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.VendorContactOrderField]{
|
||||
Field: coredata.VendorContactOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.VendorContactOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.VendorContacts.List(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to list vendor contacts: %w", err))
|
||||
}
|
||||
|
||||
return types.NewVendorContactConnection(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())
|
||||
@@ -3547,6 +3636,24 @@ func (r *vendorConnectionResolver) TotalCount(ctx context.Context, obj *types.Ve
|
||||
panic(fmt.Errorf("unsupported resolver: %T", obj.Resolver))
|
||||
}
|
||||
|
||||
// Vendor is the resolver for the vendor field.
|
||||
func (r *vendorContactResolver) Vendor(ctx context.Context, obj *types.VendorContact) (*types.Vendor, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
// Get the vendor contact to access the VendorID
|
||||
vendorContact, err := prb.VendorContacts.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to get vendor contact: %w", err))
|
||||
}
|
||||
|
||||
vendor, err := prb.Vendors.Get(ctx, vendorContact.VendorID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to get vendor: %w", err))
|
||||
}
|
||||
|
||||
return types.NewVendor(vendor), nil
|
||||
}
|
||||
|
||||
// Vendor is the resolver for the vendor field.
|
||||
func (r *vendorRiskAssessmentResolver) Vendor(ctx context.Context, obj *types.VendorRiskAssessment) (*types.Vendor, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
@@ -3728,6 +3835,9 @@ func (r *Resolver) VendorConnection() schema.VendorConnectionResolver {
|
||||
return &vendorConnectionResolver{r}
|
||||
}
|
||||
|
||||
// VendorContact returns schema.VendorContactResolver implementation.
|
||||
func (r *Resolver) VendorContact() schema.VendorContactResolver { return &vendorContactResolver{r} }
|
||||
|
||||
// VendorRiskAssessment returns schema.VendorRiskAssessmentResolver implementation.
|
||||
func (r *Resolver) VendorRiskAssessment() schema.VendorRiskAssessmentResolver {
|
||||
return &vendorRiskAssessmentResolver{r}
|
||||
@@ -3769,5 +3879,6 @@ type vendorResolver struct{ *Resolver }
|
||||
type vendorBusinessAssociateAgreementResolver struct{ *Resolver }
|
||||
type vendorComplianceReportResolver struct{ *Resolver }
|
||||
type vendorConnectionResolver struct{ *Resolver }
|
||||
type vendorContactResolver struct{ *Resolver }
|
||||
type vendorRiskAssessmentResolver struct{ *Resolver }
|
||||
type viewerResolver struct{ *Resolver }
|
||||
|
||||
Reference in New Issue
Block a user