home and about page
This commit is contained in:
86
yoga-app/src/api/strapi/query/about.json
Normal file
86
yoga-app/src/api/strapi/query/about.json
Normal file
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"populate": {
|
||||
"header": {
|
||||
"fields": ["header1","description"]
|
||||
},
|
||||
"aboutUs": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": ["name","mime","url"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"discount": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"ourMission": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": ["name","mime","url"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ourVision": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": ["name","mime","url"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"achievements": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"achievements": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": ["name","mime","url"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"blogs": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"button": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"posts": {
|
||||
"fields": ["name", "id", "header","documentId" ],
|
||||
"populate": {
|
||||
"tags": {
|
||||
"fields": ["*" ]
|
||||
},
|
||||
"teaserImage": {
|
||||
"fields": ["name","mime","url"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"subscribeNow": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"footer": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"links": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"contactUsEmail": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"contactUsLocation": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"contactUsPhoneNumber": {
|
||||
"fields": ["*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
135
yoga-app/src/api/strapi/query/home.json
Normal file
135
yoga-app/src/api/strapi/query/home.json
Normal file
@@ -0,0 +1,135 @@
|
||||
{
|
||||
"populate": {
|
||||
"header": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"button": {
|
||||
"fields": [
|
||||
"*"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"links": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"contactUsEmail": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"contactUsLocation": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"contactUsPhoneNumber": {
|
||||
"fields": ["*"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"subscribeNow": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"blogs": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"button": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"posts": {
|
||||
"fields": ["name", "id", "header","documentId" ],
|
||||
"populate": {
|
||||
"tags": {
|
||||
"fields": ["*" ]
|
||||
},
|
||||
"teaserImage": {
|
||||
"fields": ["name","mime","url"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"feedbacks": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"feedbacks": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"customerImage": {
|
||||
"fields": ["name","mime","url"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ourServices": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"services": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": ["name","mime","url"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"aboutUs": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": ["name","mime","url"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"contactUs": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"prices": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"prices": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"icon": {
|
||||
"fields": ["name","mime","url"]
|
||||
},
|
||||
"image": {
|
||||
"fields": ["name","mime","url"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ourSpecialities": {
|
||||
"fields": ["*"] ,
|
||||
"populate": {
|
||||
"left1": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"left2": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"left3": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"left4": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"right1": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"right2": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"right3": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"right4": {
|
||||
"fields": ["*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
yoga-app/src/api/strapi/strapi-api.ts
Normal file
42
yoga-app/src/api/strapi/strapi-api.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import {About_Plain} from "@/types/generated-strapi-interfaces/api/about";
|
||||
import strapiClient from "@/api/strapi/strapi-client";
|
||||
import qs from "qs";
|
||||
import aboutQuery from "@/api/strapi/query/about.json";
|
||||
import homeQuery from "@/api/strapi/query/home.json";
|
||||
import {YogaBlogPost_Plain} from "@/types/generated-strapi-interfaces/api/yoga-blog-post";
|
||||
import {Home_Plain} from "@/types/generated-strapi-interfaces/api/home";
|
||||
|
||||
|
||||
class StrapiApi{
|
||||
constructor( ) {
|
||||
}
|
||||
|
||||
protected async getJson<T>(path: string, params?: object){
|
||||
const query = params ? qs.stringify(params,{ arrayFormat: 'indices' , encode: false}) : "";
|
||||
const payload = await strapiClient.httpGetJson<T>(
|
||||
path+ query
|
||||
);
|
||||
return payload?.data;
|
||||
}
|
||||
|
||||
public getImageUrl(imagePath: string){
|
||||
return strapiClient.getImageUrl(imagePath);
|
||||
}
|
||||
public async getAboutPage(): Promise<About_Plain>{
|
||||
return this.getJson("/api/about?",aboutQuery);
|
||||
}
|
||||
|
||||
public getHomePage(): Promise<Home_Plain>{
|
||||
return this.getJson("/api/home?",homeQuery);
|
||||
|
||||
}
|
||||
|
||||
public getBlog(blogId: string): Promise<YogaBlogPost_Plain>{
|
||||
return this.getJson("/api/yoga-blog-posts/"+blogId,undefined);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const api = new StrapiApi();
|
||||
export default api;
|
||||
43
yoga-app/src/api/strapi/strapi-client.ts
Normal file
43
yoga-app/src/api/strapi/strapi-client.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import httpClient from "@/api/http-client";
|
||||
import {Payload} from "@/types/generated-strapi-interfaces/common/Payload";
|
||||
|
||||
const STRAPI_URL = process.env.STRAPI_URL;
|
||||
|
||||
class StrapiClient{
|
||||
|
||||
constructor(private strapiUrl: string = "http://localhost:1337") {
|
||||
}
|
||||
public getImageUrl(imagePath: string){
|
||||
return this.strapiUrl + imagePath;
|
||||
}
|
||||
public async httpGet(path: string){
|
||||
return await httpClient.httpGet(this.strapiUrl + path);
|
||||
}
|
||||
public async httpGetJson<T>(url: string): Promise<Payload<T>>{
|
||||
const response = await this.httpGet(url);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
public async findContentType<T>(contentType: string,options?: FindContentOptions): Promise<Payload<T>>{
|
||||
const searchParams = new URLSearchParams();
|
||||
if ( options?.populateAll ){
|
||||
searchParams.append("populate","*");
|
||||
}
|
||||
if (options?.localeAll){
|
||||
searchParams.append("_locale","all");
|
||||
}
|
||||
|
||||
|
||||
|
||||
const response = await this.httpGet("/api/"+contentType+"?"+searchParams.toString());
|
||||
return await response.json();
|
||||
}
|
||||
}
|
||||
|
||||
export interface FindContentOptions{
|
||||
populateAll?: boolean;
|
||||
localeAll?: boolean;
|
||||
}
|
||||
|
||||
const client = new StrapiClient(STRAPI_URL);
|
||||
export default client;
|
||||
3
yoga-app/src/api/strapi/strapi-query.ts
Normal file
3
yoga-app/src/api/strapi/strapi-query.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const StrapiQuery = {
|
||||
aboutUrl: "/api/about?populate[header][fields][0]=header1&populate[header][fields][1]=description&populate[ourServices][fields][0]=*&populate[aboutUs][fields][0]=*&populate[ourSpecialities][fields][0]=*&populate[ourSpecialities][populate][specialityLeft1][fields][0]=*&populate[ourSpecialities][populate][specialityLeft2][fields][0]=*&populate[ourSpecialities][populate][specialityLeft3][fields][0]=*&populate[ourSpecialities][populate][specialityLeft4][fields][0]=*&populate[ourSpecialities][populate][specialityRight1][fields][0]=*&populate[ourSpecialities][populate][specialityRight2][fields][0]=*&populate[ourSpecialities][populate][specialityRight3][fields][0]=*&populate[ourSpecialities][populate][specialityRight4][fields][0]=*"
|
||||
}
|
||||
Reference in New Issue
Block a user