diff --git a/api.http b/api.http index 2871776..b95686b 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/service-list-page?fields[0]=*&populate[services][fields][0]=*&populate[services][populate][image][fields][0]=name&populate[services][populate][image][fields][1]=mime&populate[services][populate][image][fields][2]=url&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[subscribeNow][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/service-list-page?fields[0]=*&populate[services][fields][0]=*&populate[services][populate][image][fields][0]=name&populate[services][populate][image][fields][1]=mime&populate[services][populate][image][fields][2]=url&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[subscribeNow][fields][0]=*&populate[subscribeNow][populate][image][fields][0]=name&populate[subscribeNow][populate][image][fields][1]=mime&populate[subscribeNow][populate][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[footer][populate][logo][fields][0]=name&populate[footer][populate][logo][fields][1]=mime&populate[footer][populate][logo][fields][2]=url Accept: application/json diff --git a/yoga-app/src/api/strapi/query/about.json b/yoga-app/src/api/strapi/query/about.json index 45a1686..2270120 100644 --- a/yoga-app/src/api/strapi/query/about.json +++ b/yoga-app/src/api/strapi/query/about.json @@ -72,7 +72,16 @@ } }, "subscribeNow": { - "fields": ["*"] + "fields": ["*"], + "populate": { + "image": { + "fields": [ + "name", + "mime", + "url" + ] + } + } }, "footer": { "fields": ["*"], diff --git a/yoga-app/src/api/strapi/query/contact.json b/yoga-app/src/api/strapi/query/contact.json index 0158853..bf0256e 100644 --- a/yoga-app/src/api/strapi/query/contact.json +++ b/yoga-app/src/api/strapi/query/contact.json @@ -16,8 +16,17 @@ "fields": ["*"] }, "subscribe": { - "fields": ["*"] - }, + "fields": ["*"], + "populate": { + "image": { + "fields": [ + "name", + "mime", + "url" + ] + } + } + }, "footer": { "fields": ["*"], "populate": { diff --git a/yoga-app/src/api/strapi/query/faq.json b/yoga-app/src/api/strapi/query/faq.json index d42d83e..8227830 100644 --- a/yoga-app/src/api/strapi/query/faq.json +++ b/yoga-app/src/api/strapi/query/faq.json @@ -51,8 +51,17 @@ } }, "subscribe": { - "fields": ["*"] - }, + "fields": ["*"], + "populate": { + "image": { + "fields": [ + "name", + "mime", + "url" + ] + } + } + }, "footer": { "fields": ["*"], "populate": { diff --git a/yoga-app/src/api/strapi/query/home.json b/yoga-app/src/api/strapi/query/home.json index 8820cd0..ad19159 100644 --- a/yoga-app/src/api/strapi/query/home.json +++ b/yoga-app/src/api/strapi/query/home.json @@ -43,8 +43,17 @@ } }, "subscribeNow": { - "fields": ["*"] - }, + "fields": ["*"], + "populate": { + "image": { + "fields": [ + "name", + "mime", + "url" + ] + } + } + }, "blogs": { "fields": ["*"], "populate": { diff --git a/yoga-app/src/api/strapi/query/prices.json b/yoga-app/src/api/strapi/query/prices.json index 2a84799..0071c18 100644 --- a/yoga-app/src/api/strapi/query/prices.json +++ b/yoga-app/src/api/strapi/query/prices.json @@ -48,7 +48,16 @@ } }, "subscribe": { - "fields": ["*"] + "fields": ["*"], + "populate": { + "image": { + "fields": [ + "name", + "mime", + "url" + ] + } + } }, "footer": { "fields": ["*"], diff --git a/yoga-app/src/api/strapi/query/service-list.json b/yoga-app/src/api/strapi/query/service-list.json index 998708a..8140d51 100644 --- a/yoga-app/src/api/strapi/query/service-list.json +++ b/yoga-app/src/api/strapi/query/service-list.json @@ -18,8 +18,17 @@ } }, "subscribeNow": { - "fields": ["*"] - }, + "fields": ["*"], + "populate": { + "image": { + "fields": [ + "name", + "mime", + "url" + ] + } + } + }, "footer": { "fields": ["*"], "populate": { diff --git a/yoga-app/src/api/strapi/query/service.json b/yoga-app/src/api/strapi/query/service.json index 3904856..5a0ac3e 100644 --- a/yoga-app/src/api/strapi/query/service.json +++ b/yoga-app/src/api/strapi/query/service.json @@ -10,8 +10,17 @@ } }, "subscribeNow": { - "fields": ["*"] - }, + "fields": ["*"], + "populate": { + "image": { + "fields": [ + "name", + "mime", + "url" + ] + } + } + }, "footer": { "fields": ["*"], "populate": { diff --git a/yoga-app/src/api/strapi/query/services.json b/yoga-app/src/api/strapi/query/services.json index c430fc4..cbb362b 100644 --- a/yoga-app/src/api/strapi/query/services.json +++ b/yoga-app/src/api/strapi/query/services.json @@ -90,8 +90,17 @@ } }, "subscribe": { - "fields": ["*"] - }, + "fields": ["*"], + "populate": { + "image": { + "fields": [ + "name", + "mime", + "url" + ] + } + } + }, "footer": { "fields": ["*"], "populate": { diff --git a/yoga-app/src/api/strapi/strapi-client.ts b/yoga-app/src/api/strapi/strapi-client.ts index 48fab18..2814ed2 100644 --- a/yoga-app/src/api/strapi/strapi-client.ts +++ b/yoga-app/src/api/strapi/strapi-client.ts @@ -1,44 +1,58 @@ import httpClient from "@/api/http-client"; import {Payload} from "@/types/generated-strapi-interfaces/common/Payload"; -const STRAPI_URL = process.env.STRAPI_URL; +const STRAPI_URL = process.env.STRAPI_URL; -class StrapiClient{ +class StrapiClient { constructor(private strapiUrl: string = "http://localhost:1337") { } - public getImageUrl(imagePath: string){ - if ( !imagePath ){ + + public getImageUrl(imagePath: string) { + if (!imagePath) { return "dummy.png" } - return '/image/'+ imagePath; + return '/image/' + imagePath; } - public async httpGet(path: string){ - console.info("httpGet", path); - return await httpClient.httpGet(this.strapiUrl + path); + + public async httpGet(path: string) { + let result = undefined; + try { + const absoluteUrl = this.strapiUrl + path; + console.info("httpGet", {path,absoluteUrl}); + result = await httpClient.httpGet(this.strapiUrl + path); + } catch (e) { + console.log("httpGet error", e); + throw e; + } + if (!result.ok) { + console.info("httpGet not ok", result); + throw new Error(result.statusText); + } + return result; } - public async httpGetJson(url: string): Promise>{ - const response = await this.httpGet(url); + + public async httpGetJson(url: string): Promise> { + const response = await this.httpGet(url); return await response.json(); } - public async findContentType(contentType: string,options?: FindContentOptions): Promise>{ + public async findContentType(contentType: string, options?: FindContentOptions): Promise> { const searchParams = new URLSearchParams(); - if ( options?.populateAll ){ - searchParams.append("populate","*"); + if (options?.populateAll) { + searchParams.append("populate", "*"); } - if (options?.localeAll){ - searchParams.append("_locale","all"); + if (options?.localeAll) { + searchParams.append("_locale", "all"); } - - const response = await this.httpGet("/api/"+contentType+"?"+searchParams.toString()); + const response = await this.httpGet("/api/" + contentType + "?" + searchParams.toString()); return await response.json(); } } -export interface FindContentOptions{ +export interface FindContentOptions { populateAll?: boolean; localeAll?: boolean; } diff --git a/yoga-app/src/app/page.tsx b/yoga-app/src/app/page.tsx index c24146b..faa446b 100644 --- a/yoga-app/src/app/page.tsx +++ b/yoga-app/src/app/page.tsx @@ -39,7 +39,7 @@ export default async function Home() { { contactUs && } { prices && } { feedbacks && } - { blogs && } + { blogs && blogs.posts?.length && } { subscribeNow && } { footer && } diff --git a/yoga-app/src/app/services/page.tsx b/yoga-app/src/app/services/page.tsx index 5529a02..a1c23eb 100644 --- a/yoga-app/src/app/services/page.tsx +++ b/yoga-app/src/app/services/page.tsx @@ -12,7 +12,7 @@ import SubHeaderComponent from "@/components/subHeader.component"; export default async function Services() { const { - header, + header = undefined, description, ourServices, contactUs, @@ -22,7 +22,7 @@ export default async function Services() { footer, subscribe, common - } = await strapiApi.getServicesPage(); + } = await strapiApi.getServicesPage() return ( <> diff --git a/yoga-app/src/components/subscribe.component.module.css b/yoga-app/src/components/subscribe.component.module.css new file mode 100644 index 0000000..ea25ba5 --- /dev/null +++ b/yoga-app/src/components/subscribe.component.module.css @@ -0,0 +1,4 @@ + +.roundedImage img{ + border-bottom-right-radius: 60px; +} \ No newline at end of file diff --git a/yoga-app/src/components/subscribe.component.tsx b/yoga-app/src/components/subscribe.component.tsx index c357b49..aeef24e 100644 --- a/yoga-app/src/components/subscribe.component.tsx +++ b/yoga-app/src/components/subscribe.component.tsx @@ -3,14 +3,22 @@ import { YogaSubscribeNowComponent_Plain } from "@/types/generated-strapi-interfaces/api/yoga-subscribe-now-component"; import clsx from "clsx"; +import {StrapiFile} from "@/types/types"; +import strapiApi from "@/api/strapi/strapi-api"; +import styles from './subscribe.component.module.css' + export interface Props{ config: YogaSubscribeNowComponent_Plain, - styleClass?: string + styleClass?: string, } const SubscribeComponent = ({ - config: {title,header,placeHolderEmail,buttonSubscribeLabel}, + config: {title,header,placeHolderEmail,buttonSubscribeLabel, image = undefined}, styleClass }: Props) => { + const imageFile: StrapiFile = image as StrapiFile; + if (!imageFile || !imageFile.url) { + return null + } return (
@@ -32,8 +40,8 @@ const SubscribeComponent = ({
-
- +
+
diff --git a/yoga-app/src/types/generated-strapi-interfaces/api/yoga-subscribe-now-component.ts b/yoga-app/src/types/generated-strapi-interfaces/api/yoga-subscribe-now-component.ts index e9b27d3..574f484 100644 --- a/yoga-app/src/types/generated-strapi-interfaces/api/yoga-subscribe-now-component.ts +++ b/yoga-app/src/types/generated-strapi-interfaces/api/yoga-subscribe-now-component.ts @@ -1,5 +1,9 @@ // Interface automatically generated by schemas-to-ts +import { Media } from '../components/shared/Media'; +import { Media_Plain } from '../components/shared/Media'; +import { AdminPanelRelationPropertyModification } from '../common/AdminPanelRelationPropertyModification'; + export interface YogaSubscribeNowComponent { id: number; attributes: { @@ -7,6 +11,7 @@ export interface YogaSubscribeNowComponent { header?: string; placeHolderEmail?: string; buttonSubscribeLabel?: string; + image?: { data: Media }; }; } export interface YogaSubscribeNowComponent_Plain { @@ -15,6 +20,7 @@ export interface YogaSubscribeNowComponent_Plain { header?: string; placeHolderEmail?: string; buttonSubscribeLabel?: string; + image?: Media_Plain; } export interface YogaSubscribeNowComponent_NoRelations { @@ -23,6 +29,7 @@ export interface YogaSubscribeNowComponent_NoRelations { header?: string; placeHolderEmail?: string; buttonSubscribeLabel?: string; + image?: number; } export interface YogaSubscribeNowComponent_AdminPanelLifeCycle { @@ -31,4 +38,5 @@ export interface YogaSubscribeNowComponent_AdminPanelLifeCycle { header?: string; placeHolderEmail?: string; buttonSubscribeLabel?: string; + image?: AdminPanelRelationPropertyModification; } diff --git a/yoga-cms/generated-strapi-interfaces/api/yoga-subscribe-now-component.ts b/yoga-cms/generated-strapi-interfaces/api/yoga-subscribe-now-component.ts index e9b27d3..574f484 100644 --- a/yoga-cms/generated-strapi-interfaces/api/yoga-subscribe-now-component.ts +++ b/yoga-cms/generated-strapi-interfaces/api/yoga-subscribe-now-component.ts @@ -1,5 +1,9 @@ // Interface automatically generated by schemas-to-ts +import { Media } from '../components/shared/Media'; +import { Media_Plain } from '../components/shared/Media'; +import { AdminPanelRelationPropertyModification } from '../common/AdminPanelRelationPropertyModification'; + export interface YogaSubscribeNowComponent { id: number; attributes: { @@ -7,6 +11,7 @@ export interface YogaSubscribeNowComponent { header?: string; placeHolderEmail?: string; buttonSubscribeLabel?: string; + image?: { data: Media }; }; } export interface YogaSubscribeNowComponent_Plain { @@ -15,6 +20,7 @@ export interface YogaSubscribeNowComponent_Plain { header?: string; placeHolderEmail?: string; buttonSubscribeLabel?: string; + image?: Media_Plain; } export interface YogaSubscribeNowComponent_NoRelations { @@ -23,6 +29,7 @@ export interface YogaSubscribeNowComponent_NoRelations { header?: string; placeHolderEmail?: string; buttonSubscribeLabel?: string; + image?: number; } export interface YogaSubscribeNowComponent_AdminPanelLifeCycle { @@ -31,4 +38,5 @@ export interface YogaSubscribeNowComponent_AdminPanelLifeCycle { header?: string; placeHolderEmail?: string; buttonSubscribeLabel?: string; + image?: AdminPanelRelationPropertyModification; } diff --git a/yoga-cms/src/api/yoga-subscribe-now-component/content-types/yoga-subscribe-now-component/schema.json b/yoga-cms/src/api/yoga-subscribe-now-component/content-types/yoga-subscribe-now-component/schema.json index cde8c1f..d58394b 100644 --- a/yoga-cms/src/api/yoga-subscribe-now-component/content-types/yoga-subscribe-now-component/schema.json +++ b/yoga-cms/src/api/yoga-subscribe-now-component/content-types/yoga-subscribe-now-component/schema.json @@ -4,7 +4,8 @@ "info": { "singularName": "yoga-subscribe-now-component", "pluralName": "yoga-subscribe-now-components", - "displayName": "YogaSubscribeNowComponent" + "displayName": "YogaSubscribeNowComponent", + "description": "" }, "options": { "draftAndPublish": true @@ -22,6 +23,14 @@ }, "buttonSubscribeLabel": { "type": "string" + }, + "image": { + "allowedTypes": [ + "images", + "files" + ], + "type": "media", + "multiple": false } } } diff --git a/yoga-cms/types/generated/contentTypes.d.ts b/yoga-cms/types/generated/contentTypes.d.ts index bf54d11..8f3191f 100644 --- a/yoga-cms/types/generated/contentTypes.d.ts +++ b/yoga-cms/types/generated/contentTypes.d.ts @@ -2038,6 +2038,7 @@ export interface ApiYogaSubscribeNowComponentYogaSubscribeNowComponent extends Struct.CollectionTypeSchema { collectionName: 'yoga_subscribe_now_components'; info: { + description: ''; displayName: 'YogaSubscribeNowComponent'; pluralName: 'yoga-subscribe-now-components'; singularName: 'yoga-subscribe-now-component'; @@ -2051,6 +2052,7 @@ export interface ApiYogaSubscribeNowComponentYogaSubscribeNowComponent createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & Schema.Attribute.Private; header: Schema.Attribute.String; + image: Schema.Attribute.Media<'images' | 'files'>; locale: Schema.Attribute.String & Schema.Attribute.Private; localizations: Schema.Attribute.Relation< 'oneToMany',