From 79896b4a525f4696281c00b5f7d676381e1e483f Mon Sep 17 00:00:00 2001 From: Zotov Ivan Yuryevich Date: Sat, 11 Apr 2026 18:56:39 +0300 Subject: [PATCH] add contacts to icon hepler --- schema.graphql | 18 ++++++ .../site-config.gql.generated.ts | 13 ++++ src/graphql-documents/site-config.gql.ts | 16 +++++ src/graphql/graphql.ts | 59 ++++++++++++++++--- src/lib/cms/contact/toIcon.ts | 21 +++++++ 5 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 src/graphql-documents/site-config.gql.generated.ts create mode 100644 src/graphql-documents/site-config.gql.ts create mode 100644 src/lib/cms/contact/toIcon.ts diff --git a/schema.graphql b/schema.graphql index 2a43ab8..8a20c94 100644 --- a/schema.graphql +++ b/schema.graphql @@ -227,6 +227,22 @@ type ComponentSharedContact { value: String! } +input ComponentSharedContactFiltersInput { + and: [ComponentSharedContactFiltersInput] + displayValue: StringFilterInput + not: ComponentSharedContactFiltersInput + or: [ComponentSharedContactFiltersInput] + type: StringFilterInput + value: StringFilterInput +} + +input ComponentSharedContactInput { + displayValue: String + id: ID + type: ENUM_COMPONENTSHAREDCONTACT_TYPE + value: String +} + type ComponentSharedIcon { id: ID! value: ENUM_COMPONENTSHAREDICON_VALUE @@ -678,6 +694,7 @@ type ReviewWorkflowsWorkflowStageRelationResponseCollection { } type SiteConfig { + contacts(filters: ComponentSharedContactFiltersInput, pagination: PaginationArg = {}, sort: [String] = []): [ComponentSharedContact] createdAt: DateTime description: String documentId: ID! @@ -687,6 +704,7 @@ type SiteConfig { } input SiteConfigInput { + contacts: [ComponentSharedContactInput] description: String publishedAt: DateTime title: String diff --git a/src/graphql-documents/site-config.gql.generated.ts b/src/graphql-documents/site-config.gql.generated.ts new file mode 100644 index 0000000..eeedc23 --- /dev/null +++ b/src/graphql-documents/site-config.gql.generated.ts @@ -0,0 +1,13 @@ +/* eslint-disable */ +/* Generated by scripts/endpoint-generate.mjs — do not edit by hand */ +import type { ExecutionResult } from "graphql"; + +import { execute } from "../graphql/execute"; +import type { SiteConfigQueryQuery, SiteConfigQueryQueryVariables } from "../graphql/graphql"; +import { siteConfigDocument } from "./site-config.gql"; + +export const siteConfigQueryQuery = { + async execute(variables?: SiteConfigQueryQueryVariables): Promise> { + return execute(siteConfigDocument, variables); + }, +}; diff --git a/src/graphql-documents/site-config.gql.ts b/src/graphql-documents/site-config.gql.ts new file mode 100644 index 0000000..e7f25e1 --- /dev/null +++ b/src/graphql-documents/site-config.gql.ts @@ -0,0 +1,16 @@ +import gql from 'graphql-tag' + +export const siteConfigDocument = gql` + query SiteConfigQuery { + siteConfig { + title + description + contacts { + id + type + value + displayValue + } + } + } +` diff --git a/src/graphql/graphql.ts b/src/graphql/graphql.ts index effd158..2941b88 100644 --- a/src/graphql/graphql.ts +++ b/src/graphql/graphql.ts @@ -321,6 +321,22 @@ export type ComponentSharedContact = { value: Scalars['String']['output']; }; +export type ComponentSharedContactFiltersInput = { + and?: InputMaybe>>; + displayValue?: InputMaybe; + not?: InputMaybe; + or?: InputMaybe>>; + type?: InputMaybe; + value?: InputMaybe; +}; + +export type ComponentSharedContactInput = { + displayValue?: InputMaybe; + id?: InputMaybe; + type?: InputMaybe; + value?: InputMaybe; +}; + export type ComponentSharedIcon = { __typename?: 'ComponentSharedIcon'; id: Scalars['ID']['output']; @@ -1151,6 +1167,7 @@ export type ReviewWorkflowsWorkflowStageRelationResponseCollection = { export type SiteConfig = { __typename?: 'SiteConfig'; + contacts?: Maybe>>; createdAt?: Maybe; description?: Maybe; documentId: Scalars['ID']['output']; @@ -1159,7 +1176,15 @@ export type SiteConfig = { updatedAt?: Maybe; }; + +export type SiteConfigContactsArgs = { + filters?: InputMaybe; + pagination?: InputMaybe; + sort?: InputMaybe>>; +}; + export type SiteConfigInput = { + contacts?: InputMaybe>>; description?: InputMaybe; publishedAt?: InputMaybe; title?: InputMaybe; @@ -1538,14 +1563,19 @@ export type HomePageQueryQueryVariables = Exact<{ [key: string]: never; }>; export type HomePageQueryQuery = { __typename?: 'Query', homePage?: { __typename?: 'HomePage', sections?: Array< - | { __typename?: 'ComponentSectionsAbout', id: string, title?: string | null, description?: string | null, partners?: Array<{ __typename?: 'ComponentSharedString', id: string, value: string } | null> | null, cards?: Array<{ __typename?: 'ComponentCardsAdvantage', id: string, title?: string | null, description?: string | null, color?: { __typename?: 'ComponentSharedColor', value?: Enum_Componentsharedcolor_Value | null } | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null } | null> | null } - | { __typename?: 'ComponentSectionsCases', id: string, title?: string | null, description?: string | null, cards?: Array<{ __typename?: 'ComponentCardsCase', id: string, title?: string | null, description?: string | null, pretitle?: string | null, badge?: string | null, footnote?: string | null, color?: { __typename?: 'ComponentSharedColor', value?: Enum_Componentsharedcolor_Value | null } | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null } | null> | null } - | { __typename?: 'ComponentSectionsHomeHero', id: string, title?: string | null, description?: string | null, badge?: string | null, stats?: Array<{ __typename?: 'ComponentSharedAttribute', id: string, key?: string | null, value?: string | null } | null> | null } - | { __typename?: 'ComponentSectionsServices', id: string, title?: string | null, description?: string | null, cards?: Array<{ __typename?: 'ComponentCardsService', id: string, title?: string | null, description?: string | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null, color?: { __typename?: 'ComponentSharedColor', value?: Enum_Componentsharedcolor_Value | null } | null, category?: { __typename?: 'Category', slug: string } | null } | null> | null } - | { __typename?: 'ComponentSectionsSolutions', id: string, title?: string | null, description?: string | null, cards?: Array<{ __typename?: 'ComponentCardsSolution', id: string, title?: string | null, description?: string | null, footnote?: string | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null, category?: { __typename?: 'Category', slug: string } | null } | null> | null } - | { __typename?: 'Error' } + | { __typename: 'ComponentSectionsAbout', id: string, title?: string | null, description?: string | null, partners?: Array<{ __typename?: 'ComponentSharedString', id: string, value: string } | null> | null, cards?: Array<{ __typename?: 'ComponentCardsAdvantage', id: string, title?: string | null, description?: string | null, color?: { __typename?: 'ComponentSharedColor', value?: Enum_Componentsharedcolor_Value | null } | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null } | null> | null } + | { __typename: 'ComponentSectionsCases', id: string, title?: string | null, description?: string | null, cards?: Array<{ __typename?: 'ComponentCardsCase', id: string, title?: string | null, description?: string | null, pretitle?: string | null, badge?: string | null, footnote?: string | null, color?: { __typename?: 'ComponentSharedColor', value?: Enum_Componentsharedcolor_Value | null } | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null } | null> | null } + | { __typename: 'ComponentSectionsHomeHero', id: string, title?: string | null, description?: string | null, badge?: string | null, stats?: Array<{ __typename?: 'ComponentSharedAttribute', id: string, key?: string | null, value?: string | null } | null> | null } + | { __typename: 'ComponentSectionsServices', id: string, title?: string | null, description?: string | null, cards?: Array<{ __typename?: 'ComponentCardsService', id: string, title?: string | null, description?: string | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null, color?: { __typename?: 'ComponentSharedColor', value?: Enum_Componentsharedcolor_Value | null } | null, category?: { __typename?: 'Category', slug: string } | null } | null> | null } + | { __typename: 'ComponentSectionsSolutions', id: string, title?: string | null, description?: string | null, cards?: Array<{ __typename?: 'ComponentCardsSolution', id: string, title?: string | null, description?: string | null, footnote?: string | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null, category?: { __typename?: 'Category', slug: string } | null } | null> | null } + | { __typename: 'Error' } | null> | null } | null }; +export type SiteConfigQueryQueryVariables = Exact<{ [key: string]: never; }>; + + +export type SiteConfigQueryQuery = { __typename?: 'Query', siteConfig?: { __typename?: 'SiteConfig', title: string, description?: string | null, contacts?: Array<{ __typename?: 'ComponentSharedContact', id: string, type: Enum_Componentsharedcontact_Type, value: string, displayValue?: string | null } | null> | null } | null }; + export class TypedDocumentString extends String implements DocumentTypeDecoration @@ -1581,6 +1611,7 @@ export const HomePageQueryDocument = new TypedDocumentString(` query HomePageQuery { homePage { sections { + __typename ... on ComponentSectionsHomeHero { id title @@ -1670,4 +1701,18 @@ export const HomePageQueryDocument = new TypedDocumentString(` } } } - `) as unknown as TypedDocumentString; \ No newline at end of file + `) as unknown as TypedDocumentString; +export const SiteConfigQueryDocument = new TypedDocumentString(` + query SiteConfigQuery { + siteConfig { + title + description + contacts { + id + type + value + displayValue + } + } +} + `) as unknown as TypedDocumentString; \ No newline at end of file diff --git a/src/lib/cms/contact/toIcon.ts b/src/lib/cms/contact/toIcon.ts new file mode 100644 index 0000000..eb39598 --- /dev/null +++ b/src/lib/cms/contact/toIcon.ts @@ -0,0 +1,21 @@ +import type { LucideIcon } from 'lucide-react' +import { Clock, Mail, MapPin, Phone } from 'lucide-react' + +import { Enum_Componentsharedcontact_Type } from '../../../graphql/graphql' +import type { Maybe } from '../../types' + +const DEFAULT_ICON = Mail + +const CONTACT_ICON_MAP: Record = { + [Enum_Componentsharedcontact_Type.Address]: MapPin, + [Enum_Componentsharedcontact_Type.Email]: Mail, + [Enum_Componentsharedcontact_Type.Phone]: Phone, + [Enum_Componentsharedcontact_Type.WorkingHours]: Clock, +} + +export function toIcon(type?: Maybe): LucideIcon { + if (type != null && type in CONTACT_ICON_MAP) { + return CONTACT_ICON_MAP[type] + } + return DEFAULT_ICON +}