From 1a7c5c5247a04dff7dbd4058861e2d68ff5d5ad7 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Wed, 9 Jul 2025 16:13:13 +0200 Subject: [PATCH] [yoga-12] add common section to home API and update related components for logo image --- api.http | 2 +- yoga-app/src/api/strapi/query/home.json | 14 +++++++++++++- yoga-app/src/app/page.tsx | 5 ++++- yoga-app/src/components/mainHeaderComponent.tsx | 15 +++++++++++---- .../types/generated-strapi-interfaces/api/home.ts | 6 ++++++ .../api/yoga-common.ts | 4 ++++ yoga-cms/generated-strapi-interfaces/api/home.ts | 6 ++++++ .../src/api/home/content-types/home/schema.json | 5 +++++ yoga-cms/types/generated/contentTypes.d.ts | 4 ++++ 9 files changed, 54 insertions(+), 7 deletions(-) diff --git a/api.http b/api.http index 99d28f6..4edd4b0 100644 --- a/api.http +++ b/api.http @@ -29,7 +29,7 @@ GET {{domain}}/api/yoga-single-services?filters[name][$eq]=service4 Accept: application/json ### GET service page -GET {{domain}}/api/contact-page?fields[0]=*&populate[contactUs][fields][0]=*&populate[google_maps][fields][0]=*&populate[subscribe][fields][0]=*&populate[footer][fields][0]=*&populate[footer][populate][links][fields][0]=*&populate[footer][populate][contactUsEmail][fields][0]=*&populate[footer][populate][contactUsLocation][fields][0]=*&populate[footer][populate][contactUsPhoneNumber][fields][0]=* +GET {{domain}}/api/home?populate[common][fields][0]=*&populate[common][populate][logoImage][fields][0]=name&populate[common][populate][logoImage][fields][1]=mime&populate[common][populate][logoImage][fields][2]=url&populate[header][fields][0]=*&populate[header][populate][button][fields][0]=*&populate[header][populate][button][image][fields][0]=name&populate[header][populate][button][image][fields][1]=mime&populate[header][populate][button][image][fields][2]=url&populate[footer][fields][0]=*&populate[footer][populate][links][fields][0]=*&populate[footer][populate][contactUsEmail][fields][0]=*&populate[footer][populate][contactUsLocation][fields][0]=*&populate[footer][populate][contactUsPhoneNumber][fields][0]=*&populate[subscribeNow][fields][0]=*&populate[blogs][fields][0]=*&populate[blogs][populate][button][fields][0]=*&populate[blogs][populate][posts][fields][0]=name&populate[blogs][populate][posts][fields][1]=id&populate[blogs][populate][posts][fields][2]=header&populate[blogs][populate][posts][fields][3]=documentId&populate[blogs][populate][posts][populate][tags][fields][0]=*&populate[blogs][populate][posts][populate][teaserImage][fields][0]=name&populate[blogs][populate][posts][populate][teaserImage][fields][1]=mime&populate[blogs][populate][posts][populate][teaserImage][fields][2]=url&populate[feedbacks][fields][0]=*&populate[feedbacks][populate][feedbacks][fields][0]=*&populate[feedbacks][populate][feedbacks][populate][customerImage][fields][0]=name&populate[feedbacks][populate][feedbacks][populate][customerImage][fields][1]=mime&populate[feedbacks][populate][feedbacks][populate][customerImage][fields][2]=url&populate[ourServices][fields][0]=*&populate[ourServices][populate][services][fields][0]=*&populate[ourServices][populate][services][populate][image][fields][0]=name&populate[ourServices][populate][services][populate][image][fields][1]=mime&populate[ourServices][populate][services][populate][image][fields][2]=url&populate[aboutUs][fields][0]=*&populate[aboutUs][populate][image][fields][0]=name&populate[aboutUs][populate][image][fields][1]=mime&populate[aboutUs][populate][image][fields][2]=url&populate[contactUs][fields][0]=*&populate[prices][fields][0]=*&populate[prices][populate][prices][fields][0]=*&populate[prices][populate][prices][populate][icon][fields][0]=name&populate[prices][populate][prices][populate][icon][fields][1]=mime&populate[prices][populate][prices][populate][icon][fields][2]=url&populate[prices][populate][prices][populate][image][fields][0]=name&populate[prices][populate][prices][populate][image][fields][1]=mime&populate[prices][populate][prices][populate][image][fields][2]=url&populate[ourSpecialities][fields][0]=*&populate[ourSpecialities][populate][left1][fields][0]=*&populate[ourSpecialities][populate][left2][fields][0]=*&populate[ourSpecialities][populate][left3][fields][0]=*&populate[ourSpecialities][populate][left4][fields][0]=*&populate[ourSpecialities][populate][right1][fields][0]=*&populate[ourSpecialities][populate][right2][fields][0]=*&populate[ourSpecialities][populate][right3][fields][0]=*&populate[ourSpecialities][populate][right4][fields][0]=* Accept: application/json diff --git a/yoga-app/src/api/strapi/query/home.json b/yoga-app/src/api/strapi/query/home.json index c359b36..bb5b9a7 100644 --- a/yoga-app/src/api/strapi/query/home.json +++ b/yoga-app/src/api/strapi/query/home.json @@ -1,5 +1,13 @@ { "populate": { + "common": { + "fields": ["*"], + "populate": { + "logoImage": { + "fields": ["name","mime","url"] + } + } + }, "header": { "fields": ["*"], "populate": { @@ -7,8 +15,12 @@ "fields": [ "*" ] - } + }, + "image": { + "fields": ["name","mime","url"] + } } + }, "footer": { "fields": ["*"], diff --git a/yoga-app/src/app/page.tsx b/yoga-app/src/app/page.tsx index 220df41..b464a98 100644 --- a/yoga-app/src/app/page.tsx +++ b/yoga-app/src/app/page.tsx @@ -17,6 +17,7 @@ export default async function Home() { const pageData = await webApi.getHomePage(); const { + common, header, ourServices, aboutUs, @@ -28,9 +29,11 @@ export default async function Home() { footer, feedbacks } = pageData; + + console.info("Home page data", pageData); return ( <> - { header && } + { header && } { aboutUs && } { ourServices && } { ourSpecialities && } diff --git a/yoga-app/src/components/mainHeaderComponent.tsx b/yoga-app/src/components/mainHeaderComponent.tsx index 4d1194f..1f0c5ba 100644 --- a/yoga-app/src/components/mainHeaderComponent.tsx +++ b/yoga-app/src/components/mainHeaderComponent.tsx @@ -4,8 +4,10 @@ import {MAIN_MENU} from "@/util/const"; import Nav from "@/components/nav.component"; import {StrapiFile} from "@/types/types"; import strapiApi from "@/api/strapi/strapi-api"; +import { YogaCommon_Plain } from "@/types/generated-strapi-interfaces/api/yoga-common"; export interface Props{ - config: YogaMainHeaderComponent_Plain + config: YogaMainHeaderComponent_Plain, + common?: YogaCommon_Plain } const MainHeaderComponent = ({ config: { title, @@ -15,15 +17,20 @@ const MainHeaderComponent = ({ config: { headerIType, image -}}: Props) => { +},common}: Props) => { const imageFile: StrapiFile = image as StrapiFile; const imageSrc = imageFile ? strapiApi.getImageUrl(imageFile?.url): undefined; + const logoImageFile: StrapiFile = (common?.logoImage) as StrapiFile; + const logoImageSrc = logoImageFile ? strapiApi.getImageUrl(logoImageFile.url) : undefined; + + console.info("MainHeaderComponent imageSrc",image, imageSrc); + // console.info("MainHeaderComponent logoImgSrc",image, logoImageSrc); return (
-
{/**/}
@@ -60,7 +67,7 @@ const MainHeaderComponent = ({ config: {
- +
diff --git a/yoga-app/src/types/generated-strapi-interfaces/api/home.ts b/yoga-app/src/types/generated-strapi-interfaces/api/home.ts index 9149783..7b03caa 100644 --- a/yoga-app/src/types/generated-strapi-interfaces/api/home.ts +++ b/yoga-app/src/types/generated-strapi-interfaces/api/home.ts @@ -10,6 +10,7 @@ import { YogaBlogPostsComponent } from './yoga-blog-posts-component'; import { YogaSubscribeNowComponent } from './yoga-subscribe-now-component'; import { YogaFooter } from './yoga-footer'; import { YogaMainHeaderComponent } from './yoga-main-header-component'; +import { YogaCommon } from './yoga-common'; import { YogaOurServicesComponent_Plain } from './yoga-our-services-component'; import { YogaAboutUsComponent_Plain } from './yoga-about-us-component'; import { YogaSpecialitiesComponent_Plain } from './yoga-specialities-component'; @@ -20,6 +21,7 @@ import { YogaBlogPostsComponent_Plain } from './yoga-blog-posts-component'; import { YogaSubscribeNowComponent_Plain } from './yoga-subscribe-now-component'; import { YogaFooter_Plain } from './yoga-footer'; import { YogaMainHeaderComponent_Plain } from './yoga-main-header-component'; +import { YogaCommon_Plain } from './yoga-common'; import { AdminPanelRelationPropertyModification } from '../common/AdminPanelRelationPropertyModification'; export interface Home { @@ -35,6 +37,7 @@ export interface Home { subscribeNow?: { data: YogaSubscribeNowComponent }; footer?: { data: YogaFooter }; header?: { data: YogaMainHeaderComponent }; + common?: { data: YogaCommon }; locale: string; localizations?: { data: Home[] }; }; @@ -51,6 +54,7 @@ export interface Home_Plain { subscribeNow?: YogaSubscribeNowComponent_Plain; footer?: YogaFooter_Plain; header?: YogaMainHeaderComponent_Plain; + common?: YogaCommon_Plain; locale: string; localizations?: Home_Plain[]; } @@ -67,6 +71,7 @@ export interface Home_NoRelations { subscribeNow?: number; footer?: number; header?: number; + common?: number; locale: string; localizations?: Home[]; } @@ -83,6 +88,7 @@ export interface Home_AdminPanelLifeCycle { subscribeNow?: AdminPanelRelationPropertyModification; footer?: AdminPanelRelationPropertyModification; header?: AdminPanelRelationPropertyModification; + common?: AdminPanelRelationPropertyModification; locale: string; localizations?: Home[]; } diff --git a/yoga-app/src/types/generated-strapi-interfaces/api/yoga-common.ts b/yoga-app/src/types/generated-strapi-interfaces/api/yoga-common.ts index 38e4113..71bf8a5 100644 --- a/yoga-app/src/types/generated-strapi-interfaces/api/yoga-common.ts +++ b/yoga-app/src/types/generated-strapi-interfaces/api/yoga-common.ts @@ -8,19 +8,23 @@ export interface YogaCommon { id: number; attributes: { createdAt: Date; updatedAt: Date; publishedAt?: Date; logoImage?: { data: Media }; + name: string; }; } export interface YogaCommon_Plain { id: number; createdAt: Date; updatedAt: Date; publishedAt?: Date; logoImage?: Media_Plain; + name: string; } export interface YogaCommon_NoRelations { id: number; createdAt: Date; updatedAt: Date; publishedAt?: Date; logoImage?: number; + name: string; } export interface YogaCommon_AdminPanelLifeCycle { id: number; createdAt: Date; updatedAt: Date; publishedAt?: Date; logoImage?: AdminPanelRelationPropertyModification; + name: string; } diff --git a/yoga-cms/generated-strapi-interfaces/api/home.ts b/yoga-cms/generated-strapi-interfaces/api/home.ts index 9149783..7b03caa 100644 --- a/yoga-cms/generated-strapi-interfaces/api/home.ts +++ b/yoga-cms/generated-strapi-interfaces/api/home.ts @@ -10,6 +10,7 @@ import { YogaBlogPostsComponent } from './yoga-blog-posts-component'; import { YogaSubscribeNowComponent } from './yoga-subscribe-now-component'; import { YogaFooter } from './yoga-footer'; import { YogaMainHeaderComponent } from './yoga-main-header-component'; +import { YogaCommon } from './yoga-common'; import { YogaOurServicesComponent_Plain } from './yoga-our-services-component'; import { YogaAboutUsComponent_Plain } from './yoga-about-us-component'; import { YogaSpecialitiesComponent_Plain } from './yoga-specialities-component'; @@ -20,6 +21,7 @@ import { YogaBlogPostsComponent_Plain } from './yoga-blog-posts-component'; import { YogaSubscribeNowComponent_Plain } from './yoga-subscribe-now-component'; import { YogaFooter_Plain } from './yoga-footer'; import { YogaMainHeaderComponent_Plain } from './yoga-main-header-component'; +import { YogaCommon_Plain } from './yoga-common'; import { AdminPanelRelationPropertyModification } from '../common/AdminPanelRelationPropertyModification'; export interface Home { @@ -35,6 +37,7 @@ export interface Home { subscribeNow?: { data: YogaSubscribeNowComponent }; footer?: { data: YogaFooter }; header?: { data: YogaMainHeaderComponent }; + common?: { data: YogaCommon }; locale: string; localizations?: { data: Home[] }; }; @@ -51,6 +54,7 @@ export interface Home_Plain { subscribeNow?: YogaSubscribeNowComponent_Plain; footer?: YogaFooter_Plain; header?: YogaMainHeaderComponent_Plain; + common?: YogaCommon_Plain; locale: string; localizations?: Home_Plain[]; } @@ -67,6 +71,7 @@ export interface Home_NoRelations { subscribeNow?: number; footer?: number; header?: number; + common?: number; locale: string; localizations?: Home[]; } @@ -83,6 +88,7 @@ export interface Home_AdminPanelLifeCycle { subscribeNow?: AdminPanelRelationPropertyModification; footer?: AdminPanelRelationPropertyModification; header?: AdminPanelRelationPropertyModification; + common?: AdminPanelRelationPropertyModification; locale: string; localizations?: Home[]; } diff --git a/yoga-cms/src/api/home/content-types/home/schema.json b/yoga-cms/src/api/home/content-types/home/schema.json index 8d586c4..9766bec 100644 --- a/yoga-cms/src/api/home/content-types/home/schema.json +++ b/yoga-cms/src/api/home/content-types/home/schema.json @@ -65,6 +65,11 @@ "type": "relation", "relation": "oneToOne", "target": "api::yoga-main-header-component.yoga-main-header-component" + }, + "common": { + "type": "relation", + "relation": "oneToOne", + "target": "api::yoga-common.yoga-common" } } } diff --git a/yoga-cms/types/generated/contentTypes.d.ts b/yoga-cms/types/generated/contentTypes.d.ts index e7a66f1..950d92b 100644 --- a/yoga-cms/types/generated/contentTypes.d.ts +++ b/yoga-cms/types/generated/contentTypes.d.ts @@ -710,6 +710,10 @@ export interface ApiHomeHome extends Struct.SingleTypeSchema { 'oneToOne', 'api::yoga-blog-posts-component.yoga-blog-posts-component' >; + common: Schema.Attribute.Relation< + 'oneToOne', + 'api::yoga-common.yoga-common' + >; contactUs: Schema.Attribute.Relation< 'oneToOne', 'api::yoga-contact-us.yoga-contact-us'