From 93af3607e990eb3bc48f926e1556b74ea730d4ac Mon Sep 17 00:00:00 2001 From: Schneider Roland Date: Tue, 28 Jan 2025 23:09:42 +0100 Subject: [PATCH] add prices page --- api.http | 2 +- yoga-app/src/api/strapi/query/prices.json | 63 +++++++++++++++++++ yoga-app/src/api/strapi/strapi-api.ts | 7 +++ yoga-app/src/app/prices/page.tsx | 43 ++++++++----- .../src/components/breadcrumbs.component.tsx | 3 +- .../api/prices-page.ts | 58 +++++++++++++++++ .../api/prices-page.ts | 58 +++++++++++++++++ .../content-types/prices-page/schema.json | 46 ++++++++++++++ .../prices-page/controllers/prices-page.ts | 7 +++ .../src/api/prices-page/routes/prices-page.ts | 7 +++ .../api/prices-page/services/prices-page.ts | 7 +++ yoga-cms/types/generated/contentTypes.d.ts | 50 +++++++++++++++ 12 files changed, 333 insertions(+), 18 deletions(-) create mode 100644 yoga-app/src/api/strapi/query/prices.json create mode 100644 yoga-app/src/types/generated-strapi-interfaces/api/prices-page.ts create mode 100644 yoga-cms/generated-strapi-interfaces/api/prices-page.ts create mode 100644 yoga-cms/src/api/prices-page/content-types/prices-page/schema.json create mode 100644 yoga-cms/src/api/prices-page/controllers/prices-page.ts create mode 100644 yoga-cms/src/api/prices-page/routes/prices-page.ts create mode 100644 yoga-cms/src/api/prices-page/services/prices-page.ts diff --git a/api.http b/api.http index af64e3c..1a1fc63 100644 --- a/api.http +++ b/api.http @@ -13,7 +13,7 @@ Accept: application/json #Authorization: Bearer {{token}} ### GET request with a header -GET {{domain}}/api/about?api/services-page? +GET {{domain}}/api/prices-page?fields[0]=*&populate[price][fields][0]=*&populate[price][populate][prices][fields][0]=*&populate[price][populate][prices][populate][icon][fields][0]=name&populate[price][populate][prices][populate][icon][fields][1]=mime&populate[price][populate][prices][populate][icon][fields][2]=url&populate[price][populate][prices][populate][image][fields][0]=name&populate[price][populate][prices][populate][image][fields][1]=mime&populate[price][populate][prices][populate][image][fields][2]=url&populate[discount][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[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]=* Accept: application/json #Authorization: Bearer {{token}} diff --git a/yoga-app/src/api/strapi/query/prices.json b/yoga-app/src/api/strapi/query/prices.json new file mode 100644 index 0000000..1832b93 --- /dev/null +++ b/yoga-app/src/api/strapi/query/prices.json @@ -0,0 +1,63 @@ +{ + "fields": ["*"], + "populate": { + "price": { + "fields": ["*"], + "populate": { + "prices": { + "fields": ["*"], + "populate": { + "icon": { + "fields": ["name","mime","url"] + }, + "image": { + "fields": ["name","mime","url"] + } + } + } + } + }, + "discount": { + "fields": ["*"] + }, + "blogs": { + "fields": ["*"], + "populate": { + "button": { + "fields": ["*"] + }, + "posts": { + "fields": ["name", "id", "header","documentId" ], + "populate": { + "tags": { + "fields": ["*" ] + }, + "teaserImage": { + "fields": ["name","mime","url"] + } + } + } + } + }, + "subscribe": { + "fields": ["*"] + }, + "footer": { + "fields": ["*"], + "populate": { + "links": { + "fields": ["*"] + }, + "contactUsEmail": { + "fields": ["*"] + }, + "contactUsLocation": { + "fields": ["*"] + }, + "contactUsPhoneNumber": { + "fields": ["*"] + } + } + } + } +} diff --git a/yoga-app/src/api/strapi/strapi-api.ts b/yoga-app/src/api/strapi/strapi-api.ts index 8ac59e8..02c2a82 100644 --- a/yoga-app/src/api/strapi/strapi-api.ts +++ b/yoga-app/src/api/strapi/strapi-api.ts @@ -4,9 +4,11 @@ import qs from "qs"; import aboutQuery from "@/api/strapi/query/about.json"; import homeQuery from "@/api/strapi/query/home.json"; import servicesQuery from "@/api/strapi/query/services.json"; +import pricesQuery from "@/api/strapi/query/prices.json"; import {YogaBlogPost_Plain} from "@/types/generated-strapi-interfaces/api/yoga-blog-post"; import {Home_Plain} from "@/types/generated-strapi-interfaces/api/home"; import {ServicesPage_Plain} from "@/types/generated-strapi-interfaces/api/services-page"; +import {PricesPage_Plain} from "@/types/generated-strapi-interfaces/api/prices-page"; class StrapiApi{ @@ -36,6 +38,11 @@ class StrapiApi{ return this.getJson("/api/services-page?",servicesQuery); } + public getPricesPage(): Promise{ + return this.getJson("/api/prices-page?",pricesQuery); + } + + public getBlog(blogId: string): Promise{ return this.getJson("/api/yoga-blog-posts/"+blogId,undefined); diff --git a/yoga-app/src/app/prices/page.tsx b/yoga-app/src/app/prices/page.tsx index 7cd76ce..284285e 100644 --- a/yoga-app/src/app/prices/page.tsx +++ b/yoga-app/src/app/prices/page.tsx @@ -1,28 +1,39 @@ import React from "react"; import AosComponent from "@/components/aos.component"; -import OurServicesComponent from "@/components/our.services.component"; -import AboutUsComponent from "@/components/about.us.component"; -import OurSpecialitiesComponent from "@/components/our.specialities.component"; -import ContactUsComponent from "@/components/contact.us.component"; import PricingComponent from "@/components/pricing.component"; -import FeedbackComponent from "@/components/feedbackComponent"; import BlogPostsComponent from "@/components/blog.posts.component"; -import FooterComponent from "@/components/footer.component"; import SubscribeComponent from "@/components/subscribe.component"; +import SubHeaderComponent from "@/components/subHeader.component"; +import YogaDiscountComponent from "@/components/yogaDiscountComponent"; +import {PricesPage_Plain} from "@/types/generated-strapi-interfaces/api/prices-page"; +import FooterComponent from "@/components/footer.component"; +import strapiApi from "@/api/strapi/strapi-api"; +import BootstrapComponent from "@/components/bootstrap.component"; -export default function About() { +export interface Props{ + config: PricesPage_Plain +} +export default async function PricesPage( ) { + const { + header, + description, + price, + discount, + blogs, + subscribe, + footer + } = await strapiApi.getPricesPage(); return ( <> - - - - - - - - - + + { price && } + { discount && } + { blogs && } + { subscribe && } + { footer && } + + ); diff --git a/yoga-app/src/components/breadcrumbs.component.tsx b/yoga-app/src/components/breadcrumbs.component.tsx index 29ec1ff..19474cd 100644 --- a/yoga-app/src/components/breadcrumbs.component.tsx +++ b/yoga-app/src/components/breadcrumbs.component.tsx @@ -11,7 +11,8 @@ type Props = { const pathToBreadCrumbs = (path: string) => { const mapping: Record = { '/' : 'Kezdőlap', - 'about' : 'Rólam' + 'about' : 'Rólam', + 'services' : 'Szolgáltatásaim', } if ( mapping.hasOwnProperty(path)){ return mapping[path]; diff --git a/yoga-app/src/types/generated-strapi-interfaces/api/prices-page.ts b/yoga-app/src/types/generated-strapi-interfaces/api/prices-page.ts new file mode 100644 index 0000000..b940f7b --- /dev/null +++ b/yoga-app/src/types/generated-strapi-interfaces/api/prices-page.ts @@ -0,0 +1,58 @@ +// Interface automatically generated by schemas-to-ts + +import { YogaPriceComponent } from './yoga-price-component'; +import { YogaDiscountComponent } from './yoga-discount-component'; +import { YogaBlogPostsComponent } from './yoga-blog-posts-component'; +import { YogaSubscribeNowComponent } from './yoga-subscribe-now-component'; +import { YogaFooter } from './yoga-footer'; +import { YogaPriceComponent_Plain } from './yoga-price-component'; +import { YogaDiscountComponent_Plain } from './yoga-discount-component'; +import { YogaBlogPostsComponent_Plain } from './yoga-blog-posts-component'; +import { YogaSubscribeNowComponent_Plain } from './yoga-subscribe-now-component'; +import { YogaFooter_Plain } from './yoga-footer'; +import { AdminPanelRelationPropertyModification } from '../common/AdminPanelRelationPropertyModification'; + +export interface PricesPage { + id: number; + attributes: { + createdAt: Date; updatedAt: Date; publishedAt?: Date; header?: string; + description?: string; + price?: { data: YogaPriceComponent }; + discount?: { data: YogaDiscountComponent }; + blogs?: { data: YogaBlogPostsComponent }; + subscribe?: { data: YogaSubscribeNowComponent }; + footer?: { data: YogaFooter }; + }; +} +export interface PricesPage_Plain { + id: number; + createdAt: Date; updatedAt: Date; publishedAt?: Date; header?: string; + description?: string; + price?: YogaPriceComponent_Plain; + discount?: YogaDiscountComponent_Plain; + blogs?: YogaBlogPostsComponent_Plain; + subscribe?: YogaSubscribeNowComponent_Plain; + footer?: YogaFooter_Plain; +} + +export interface PricesPage_NoRelations { + id: number; + createdAt: Date; updatedAt: Date; publishedAt?: Date; header?: string; + description?: string; + price?: number; + discount?: number; + blogs?: number; + subscribe?: number; + footer?: number; +} + +export interface PricesPage_AdminPanelLifeCycle { + id: number; + createdAt: Date; updatedAt: Date; publishedAt?: Date; header?: string; + description?: string; + price?: AdminPanelRelationPropertyModification; + discount?: AdminPanelRelationPropertyModification; + blogs?: AdminPanelRelationPropertyModification; + subscribe?: AdminPanelRelationPropertyModification; + footer?: AdminPanelRelationPropertyModification; +} diff --git a/yoga-cms/generated-strapi-interfaces/api/prices-page.ts b/yoga-cms/generated-strapi-interfaces/api/prices-page.ts new file mode 100644 index 0000000..b940f7b --- /dev/null +++ b/yoga-cms/generated-strapi-interfaces/api/prices-page.ts @@ -0,0 +1,58 @@ +// Interface automatically generated by schemas-to-ts + +import { YogaPriceComponent } from './yoga-price-component'; +import { YogaDiscountComponent } from './yoga-discount-component'; +import { YogaBlogPostsComponent } from './yoga-blog-posts-component'; +import { YogaSubscribeNowComponent } from './yoga-subscribe-now-component'; +import { YogaFooter } from './yoga-footer'; +import { YogaPriceComponent_Plain } from './yoga-price-component'; +import { YogaDiscountComponent_Plain } from './yoga-discount-component'; +import { YogaBlogPostsComponent_Plain } from './yoga-blog-posts-component'; +import { YogaSubscribeNowComponent_Plain } from './yoga-subscribe-now-component'; +import { YogaFooter_Plain } from './yoga-footer'; +import { AdminPanelRelationPropertyModification } from '../common/AdminPanelRelationPropertyModification'; + +export interface PricesPage { + id: number; + attributes: { + createdAt: Date; updatedAt: Date; publishedAt?: Date; header?: string; + description?: string; + price?: { data: YogaPriceComponent }; + discount?: { data: YogaDiscountComponent }; + blogs?: { data: YogaBlogPostsComponent }; + subscribe?: { data: YogaSubscribeNowComponent }; + footer?: { data: YogaFooter }; + }; +} +export interface PricesPage_Plain { + id: number; + createdAt: Date; updatedAt: Date; publishedAt?: Date; header?: string; + description?: string; + price?: YogaPriceComponent_Plain; + discount?: YogaDiscountComponent_Plain; + blogs?: YogaBlogPostsComponent_Plain; + subscribe?: YogaSubscribeNowComponent_Plain; + footer?: YogaFooter_Plain; +} + +export interface PricesPage_NoRelations { + id: number; + createdAt: Date; updatedAt: Date; publishedAt?: Date; header?: string; + description?: string; + price?: number; + discount?: number; + blogs?: number; + subscribe?: number; + footer?: number; +} + +export interface PricesPage_AdminPanelLifeCycle { + id: number; + createdAt: Date; updatedAt: Date; publishedAt?: Date; header?: string; + description?: string; + price?: AdminPanelRelationPropertyModification; + discount?: AdminPanelRelationPropertyModification; + blogs?: AdminPanelRelationPropertyModification; + subscribe?: AdminPanelRelationPropertyModification; + footer?: AdminPanelRelationPropertyModification; +} diff --git a/yoga-cms/src/api/prices-page/content-types/prices-page/schema.json b/yoga-cms/src/api/prices-page/content-types/prices-page/schema.json new file mode 100644 index 0000000..a1b1964 --- /dev/null +++ b/yoga-cms/src/api/prices-page/content-types/prices-page/schema.json @@ -0,0 +1,46 @@ +{ + "kind": "singleType", + "collectionName": "prices_pages", + "info": { + "singularName": "prices-page", + "pluralName": "prices-pages", + "displayName": "PricesPage" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "header": { + "type": "string" + }, + "description": { + "type": "text" + }, + "price": { + "type": "relation", + "relation": "oneToOne", + "target": "api::yoga-price-component.yoga-price-component" + }, + "discount": { + "type": "relation", + "relation": "oneToOne", + "target": "api::yoga-discount-component.yoga-discount-component" + }, + "blogs": { + "type": "relation", + "relation": "oneToOne", + "target": "api::yoga-blog-posts-component.yoga-blog-posts-component" + }, + "subscribe": { + "type": "relation", + "relation": "oneToOne", + "target": "api::yoga-subscribe-now-component.yoga-subscribe-now-component" + }, + "footer": { + "type": "relation", + "relation": "oneToOne", + "target": "api::yoga-footer.yoga-footer" + } + } +} diff --git a/yoga-cms/src/api/prices-page/controllers/prices-page.ts b/yoga-cms/src/api/prices-page/controllers/prices-page.ts new file mode 100644 index 0000000..4f89bca --- /dev/null +++ b/yoga-cms/src/api/prices-page/controllers/prices-page.ts @@ -0,0 +1,7 @@ +/** + * prices-page controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::prices-page.prices-page'); diff --git a/yoga-cms/src/api/prices-page/routes/prices-page.ts b/yoga-cms/src/api/prices-page/routes/prices-page.ts new file mode 100644 index 0000000..5fb9ef9 --- /dev/null +++ b/yoga-cms/src/api/prices-page/routes/prices-page.ts @@ -0,0 +1,7 @@ +/** + * prices-page router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::prices-page.prices-page'); diff --git a/yoga-cms/src/api/prices-page/services/prices-page.ts b/yoga-cms/src/api/prices-page/services/prices-page.ts new file mode 100644 index 0000000..ee25cd8 --- /dev/null +++ b/yoga-cms/src/api/prices-page/services/prices-page.ts @@ -0,0 +1,7 @@ +/** + * prices-page service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::prices-page.prices-page'); diff --git a/yoga-cms/types/generated/contentTypes.d.ts b/yoga-cms/types/generated/contentTypes.d.ts index 2aefb1f..5400735 100644 --- a/yoga-cms/types/generated/contentTypes.d.ts +++ b/yoga-cms/types/generated/contentTypes.d.ts @@ -700,6 +700,55 @@ export interface ApiPersonPerson extends Struct.SingleTypeSchema { }; } +export interface ApiPricesPagePricesPage extends Struct.SingleTypeSchema { + collectionName: 'prices_pages'; + info: { + displayName: 'PricesPage'; + pluralName: 'prices-pages'; + singularName: 'prices-page'; + }; + options: { + draftAndPublish: true; + }; + attributes: { + blogs: Schema.Attribute.Relation< + 'oneToOne', + 'api::yoga-blog-posts-component.yoga-blog-posts-component' + >; + createdAt: Schema.Attribute.DateTime; + createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + description: Schema.Attribute.Text; + discount: Schema.Attribute.Relation< + 'oneToOne', + 'api::yoga-discount-component.yoga-discount-component' + >; + footer: Schema.Attribute.Relation< + 'oneToOne', + 'api::yoga-footer.yoga-footer' + >; + header: Schema.Attribute.String; + locale: Schema.Attribute.String & Schema.Attribute.Private; + localizations: Schema.Attribute.Relation< + 'oneToMany', + 'api::prices-page.prices-page' + > & + Schema.Attribute.Private; + price: Schema.Attribute.Relation< + 'oneToOne', + 'api::yoga-price-component.yoga-price-component' + >; + publishedAt: Schema.Attribute.DateTime; + subscribe: Schema.Attribute.Relation< + 'oneToOne', + 'api::yoga-subscribe-now-component.yoga-subscribe-now-component' + >; + updatedAt: Schema.Attribute.DateTime; + updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + }; +} + export interface ApiServicesPageServicesPage extends Struct.SingleTypeSchema { collectionName: 'services_pages'; info: { @@ -2252,6 +2301,7 @@ declare module '@strapi/strapi' { 'api::home.home': ApiHomeHome; 'api::page.page': ApiPagePage; 'api::person.person': ApiPersonPerson; + 'api::prices-page.prices-page': ApiPricesPagePricesPage; 'api::services-page.services-page': ApiServicesPageServicesPage; 'api::yoga-about-us-component.yoga-about-us-component': ApiYogaAboutUsComponentYogaAboutUsComponent; 'api::yoga-about-us-with-boxes-component.yoga-about-us-with-boxes-component': ApiYogaAboutUsWithBoxesComponentYogaAboutUsWithBoxesComponent;