Add term of service to vendor

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-02-18 11:33:43 +01:00
parent 88e6aae09a
commit 00c2206e57
8 changed files with 108 additions and 8 deletions

View File

@@ -28,6 +28,7 @@ const vendorOverviewPageQuery = graphql`
serviceCriticality serviceCriticality
riskTier riskTier
statusPageUrl statusPageUrl
termsOfServiceUrl
createdAt createdAt
updatedAt updatedAt
} }
@@ -210,6 +211,24 @@ function VendorOverviewPageContent({
</a> </a>
</div> </div>
)} )}
{data.node.termsOfServiceUrl && (
<div className="space-y-2">
<div className="flex items-center gap-2">
<HelpCircle className="h-4 w-4 text-gray-400" />
<Label className="text-sm">Terms of Service</Label>
</div>
<a
href={data.node.termsOfServiceUrl}
className="text-primary hover:underline inline-flex items-center gap-1"
target="_blank"
rel="noopener noreferrer"
>
View Terms of Service
<ArrowUpRight className="h-4 w-4" />
</a>
</div>
)}
</div> </div>
</div> </div>
</Card> </Card>

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<5e9e499f91b8d971375b191b9ce35f5d>> * @generated SignedSource<<ae97673f2cbf067aad64913403bca210>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -25,6 +25,7 @@ export type VendorOverviewPageQuery$data = {
readonly serviceStartDate?: any; readonly serviceStartDate?: any;
readonly serviceTerminationDate?: any | null | undefined; readonly serviceTerminationDate?: any | null | undefined;
readonly statusPageUrl?: string | null | undefined; readonly statusPageUrl?: string | null | undefined;
readonly termsOfServiceUrl?: string | null | undefined;
readonly updatedAt?: any; readonly updatedAt?: any;
}; };
}; };
@@ -108,10 +109,17 @@ v10 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "createdAt", "name": "termsOfServiceUrl",
"storageKey": null "storageKey": null
}, },
v11 = { v11 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
v12 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
@@ -145,7 +153,8 @@ return {
(v8/*: any*/), (v8/*: any*/),
(v9/*: any*/), (v9/*: any*/),
(v10/*: any*/), (v10/*: any*/),
(v11/*: any*/) (v11/*: any*/),
(v12/*: any*/)
], ],
"type": "Vendor", "type": "Vendor",
"abstractKey": null "abstractKey": null
@@ -190,7 +199,8 @@ return {
(v8/*: any*/), (v8/*: any*/),
(v9/*: any*/), (v9/*: any*/),
(v10/*: any*/), (v10/*: any*/),
(v11/*: any*/) (v11/*: any*/),
(v12/*: any*/)
], ],
"type": "Vendor", "type": "Vendor",
"abstractKey": null "abstractKey": null
@@ -201,16 +211,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "04e4ae3f0c7613bf50b59368d02ba937", "cacheID": "37f7dba24b43c13a4e5467dd58fdfcd6",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "VendorOverviewPageQuery", "name": "VendorOverviewPageQuery",
"operationKind": "query", "operationKind": "query",
"text": "query VendorOverviewPageQuery(\n $vendorId: ID!\n) {\n node(id: $vendorId) {\n __typename\n ... on Vendor {\n id\n name\n description\n serviceStartDate\n serviceTerminationDate\n serviceCriticality\n riskTier\n statusPageUrl\n createdAt\n updatedAt\n }\n id\n }\n}\n" "text": "query VendorOverviewPageQuery(\n $vendorId: ID!\n) {\n node(id: $vendorId) {\n __typename\n ... on Vendor {\n id\n name\n description\n serviceStartDate\n serviceTerminationDate\n serviceCriticality\n riskTier\n statusPageUrl\n termsOfServiceUrl\n createdAt\n updatedAt\n }\n id\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "474b8b7350d917a50c91a0b8239370ea"; (node as any).hash = "86f10af28dac38699127a302a42aca12";
export default node; export default node;

View File

@@ -123,6 +123,7 @@ type Vendor implements Node {
serviceCriticality: ServiceCriticality! serviceCriticality: ServiceCriticality!
riskTier: RiskTier! riskTier: RiskTier!
statusPageUrl: String statusPageUrl: String
termsOfServiceUrl: String
} }
type FrameworkConnection { type FrameworkConnection {
@@ -358,4 +359,5 @@ input UpdateVendorInput {
serviceCriticality: ServiceCriticality serviceCriticality: ServiceCriticality
riskTier: RiskTier riskTier: RiskTier
statusPageUrl: String statusPageUrl: String
termsOfServiceUrl: String
} }

View File

@@ -254,6 +254,7 @@ type ComplexityRoot struct {
ServiceStartDate func(childComplexity int) int ServiceStartDate func(childComplexity int) int
ServiceTerminationDate func(childComplexity int) int ServiceTerminationDate func(childComplexity int) int
StatusPageURL func(childComplexity int) int StatusPageURL func(childComplexity int) int
TermsOfServiceURL func(childComplexity int) int
UpdatedAt func(childComplexity int) int UpdatedAt func(childComplexity int) int
} }
@@ -1184,6 +1185,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Vendor.StatusPageURL(childComplexity), true return e.complexity.Vendor.StatusPageURL(childComplexity), true
case "Vendor.termsOfServiceUrl":
if e.complexity.Vendor.TermsOfServiceURL == nil {
break
}
return e.complexity.Vendor.TermsOfServiceURL(childComplexity), true
case "Vendor.updatedAt": case "Vendor.updatedAt":
if e.complexity.Vendor.UpdatedAt == nil { if e.complexity.Vendor.UpdatedAt == nil {
break break
@@ -1454,6 +1462,7 @@ type Vendor implements Node {
serviceCriticality: ServiceCriticality! serviceCriticality: ServiceCriticality!
riskTier: RiskTier! riskTier: RiskTier!
statusPageUrl: String statusPageUrl: String
termsOfServiceUrl: String
} }
type FrameworkConnection { type FrameworkConnection {
@@ -1689,6 +1698,7 @@ input UpdateVendorInput {
serviceCriticality: ServiceCriticality serviceCriticality: ServiceCriticality
riskTier: RiskTier riskTier: RiskTier
statusPageUrl: String statusPageUrl: String
termsOfServiceUrl: String
}`, BuiltIn: false}, }`, BuiltIn: false},
} }
var parsedSchema = gqlparser.MustLoadSchema(sources...) var parsedSchema = gqlparser.MustLoadSchema(sources...)
@@ -4917,6 +4927,8 @@ func (ec *executionContext) fieldContext_Mutation_createVendor(ctx context.Conte
return ec.fieldContext_Vendor_riskTier(ctx, field) return ec.fieldContext_Vendor_riskTier(ctx, field)
case "statusPageUrl": case "statusPageUrl":
return ec.fieldContext_Vendor_statusPageUrl(ctx, field) return ec.fieldContext_Vendor_statusPageUrl(ctx, field)
case "termsOfServiceUrl":
return ec.fieldContext_Vendor_termsOfServiceUrl(ctx, field)
} }
return nil, fmt.Errorf("no field named %q was found under type Vendor", field.Name) return nil, fmt.Errorf("no field named %q was found under type Vendor", field.Name)
}, },
@@ -7451,6 +7463,41 @@ func (ec *executionContext) fieldContext_Vendor_statusPageUrl(_ context.Context,
return fc, nil return fc, nil
} }
func (ec *executionContext) _Vendor_termsOfServiceUrl(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Vendor_termsOfServiceUrl(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.TermsOfServiceURL, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
fc.Result = res
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Vendor_termsOfServiceUrl(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Vendor",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _VendorConnection_edges(ctx context.Context, field graphql.CollectedField, obj *types.VendorConnection) (ret graphql.Marshaler) { func (ec *executionContext) _VendorConnection_edges(ctx context.Context, field graphql.CollectedField, obj *types.VendorConnection) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_VendorConnection_edges(ctx, field) fc, err := ec.fieldContext_VendorConnection_edges(ctx, field)
if err != nil { if err != nil {
@@ -7634,6 +7681,8 @@ func (ec *executionContext) fieldContext_VendorEdge_node(_ context.Context, fiel
return ec.fieldContext_Vendor_riskTier(ctx, field) return ec.fieldContext_Vendor_riskTier(ctx, field)
case "statusPageUrl": case "statusPageUrl":
return ec.fieldContext_Vendor_statusPageUrl(ctx, field) return ec.fieldContext_Vendor_statusPageUrl(ctx, field)
case "termsOfServiceUrl":
return ec.fieldContext_Vendor_termsOfServiceUrl(ctx, field)
} }
return nil, fmt.Errorf("no field named %q was found under type Vendor", field.Name) return nil, fmt.Errorf("no field named %q was found under type Vendor", field.Name)
}, },
@@ -9342,7 +9391,7 @@ func (ec *executionContext) unmarshalInputUpdateVendorInput(ctx context.Context,
asMap[k] = v asMap[k] = v
} }
fieldsInOrder := [...]string{"id", "name", "description", "serviceStartDate", "serviceTerminationDate", "serviceCriticality", "riskTier", "statusPageUrl"} fieldsInOrder := [...]string{"id", "name", "description", "serviceStartDate", "serviceTerminationDate", "serviceCriticality", "riskTier", "statusPageUrl", "termsOfServiceUrl"}
for _, k := range fieldsInOrder { for _, k := range fieldsInOrder {
v, ok := asMap[k] v, ok := asMap[k]
if !ok { if !ok {
@@ -9405,6 +9454,13 @@ func (ec *executionContext) unmarshalInputUpdateVendorInput(ctx context.Context,
return it, err return it, err
} }
it.StatusPageURL = data it.StatusPageURL = data
case "termsOfServiceUrl":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("termsOfServiceUrl"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
if err != nil {
return it, err
}
it.TermsOfServiceURL = data
} }
} }
@@ -11263,6 +11319,8 @@ func (ec *executionContext) _Vendor(ctx context.Context, sel ast.SelectionSet, o
} }
case "statusPageUrl": case "statusPageUrl":
out.Values[i] = ec._Vendor_statusPageUrl(ctx, field, obj) out.Values[i] = ec._Vendor_statusPageUrl(ctx, field, obj)
case "termsOfServiceUrl":
out.Values[i] = ec._Vendor_termsOfServiceUrl(ctx, field, obj)
default: default:
panic("unknown field " + strconv.Quote(field.Name)) panic("unknown field " + strconv.Quote(field.Name))
} }

View File

@@ -247,6 +247,7 @@ type UpdateVendorInput struct {
ServiceCriticality *coredata.ServiceCriticality `json:"serviceCriticality,omitempty"` ServiceCriticality *coredata.ServiceCriticality `json:"serviceCriticality,omitempty"`
RiskTier *coredata.RiskTier `json:"riskTier,omitempty"` RiskTier *coredata.RiskTier `json:"riskTier,omitempty"`
StatusPageURL *string `json:"statusPageUrl,omitempty"` StatusPageURL *string `json:"statusPageUrl,omitempty"`
TermsOfServiceURL *string `json:"termsOfServiceUrl,omitempty"`
} }
type Vendor struct { type Vendor struct {
@@ -260,6 +261,7 @@ type Vendor struct {
ServiceCriticality coredata.ServiceCriticality `json:"serviceCriticality"` ServiceCriticality coredata.ServiceCriticality `json:"serviceCriticality"`
RiskTier coredata.RiskTier `json:"riskTier"` RiskTier coredata.RiskTier `json:"riskTier"`
StatusPageURL *string `json:"statusPageUrl,omitempty"` StatusPageURL *string `json:"statusPageUrl,omitempty"`
TermsOfServiceURL *string `json:"termsOfServiceUrl,omitempty"`
} }
func (Vendor) IsNode() {} func (Vendor) IsNode() {}

View File

@@ -51,5 +51,6 @@ func NewVendor(v *coredata.Vendor) *Vendor {
ServiceCriticality: v.ServiceCriticality, ServiceCriticality: v.ServiceCriticality,
RiskTier: v.RiskTier, RiskTier: v.RiskTier,
StatusPageURL: v.StatusPageURL, StatusPageURL: v.StatusPageURL,
TermsOfServiceURL: v.TermsOfServiceURL,
} }
} }

View File

@@ -0,0 +1 @@
ALTER TABLE vendors ADD COLUMN terms_of_service_url TEXT;

View File

@@ -37,6 +37,7 @@ type (
ServiceCriticality ServiceCriticality ServiceCriticality ServiceCriticality
RiskTier RiskTier RiskTier RiskTier
StatusPageURL *string StatusPageURL *string
TermsOfServiceURL *string
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time UpdatedAt time.Time
} }
@@ -59,6 +60,7 @@ func (v *Vendor) scan(r pgx.Row) error {
&v.ServiceCriticality, &v.ServiceCriticality,
&v.RiskTier, &v.RiskTier,
&v.StatusPageURL, &v.StatusPageURL,
&v.TermsOfServiceURL,
&v.CreatedAt, &v.CreatedAt,
&v.UpdatedAt, &v.UpdatedAt,
) )
@@ -81,6 +83,7 @@ SELECT
service_criticality, service_criticality,
risk_tier, risk_tier,
status_page_url, status_page_url,
terms_of_service_url,
created_at, created_at,
updated_at updated_at
FROM FROM
@@ -124,6 +127,7 @@ INSERT INTO
service_criticality, service_criticality,
risk_tier, risk_tier,
status_page_url, status_page_url,
terms_of_service_url,
created_at, created_at,
updated_at updated_at
) )
@@ -137,6 +141,7 @@ VALUES (
@service_criticality, @service_criticality,
@risk_tier, @risk_tier,
@status_page_url, @status_page_url,
@terms_of_service_url,
@created_at, @created_at,
@updated_at @updated_at
) )
@@ -152,6 +157,7 @@ VALUES (
"service_criticality": v.ServiceCriticality, "service_criticality": v.ServiceCriticality,
"risk_tier": v.RiskTier, "risk_tier": v.RiskTier,
"status_page_url": v.StatusPageURL, "status_page_url": v.StatusPageURL,
"terms_of_service_url": v.TermsOfServiceURL,
"created_at": v.CreatedAt, "created_at": v.CreatedAt,
"updated_at": v.UpdatedAt, "updated_at": v.UpdatedAt,
} }
@@ -195,6 +201,7 @@ SELECT
service_criticality, service_criticality,
risk_tier, risk_tier,
status_page_url, status_page_url,
terms_of_service_url,
created_at, created_at,
updated_at updated_at
FROM FROM