[yoga-20] subscribe.component.tsx: make image editable

This commit is contained in:
Roland Schneider
2025-08-27 09:21:20 +02:00
parent 917918d742
commit 622f2a7686
18 changed files with 166 additions and 41 deletions

View File

@@ -72,7 +72,16 @@
}
},
"subscribeNow": {
"fields": ["*"]
"fields": ["*"],
"populate": {
"image": {
"fields": [
"name",
"mime",
"url"
]
}
}
},
"footer": {
"fields": ["*"],

View File

@@ -16,8 +16,17 @@
"fields": ["*"]
},
"subscribe": {
"fields": ["*"]
},
"fields": ["*"],
"populate": {
"image": {
"fields": [
"name",
"mime",
"url"
]
}
}
},
"footer": {
"fields": ["*"],
"populate": {

View File

@@ -51,8 +51,17 @@
}
},
"subscribe": {
"fields": ["*"]
},
"fields": ["*"],
"populate": {
"image": {
"fields": [
"name",
"mime",
"url"
]
}
}
},
"footer": {
"fields": ["*"],
"populate": {

View File

@@ -43,8 +43,17 @@
}
},
"subscribeNow": {
"fields": ["*"]
},
"fields": ["*"],
"populate": {
"image": {
"fields": [
"name",
"mime",
"url"
]
}
}
},
"blogs": {
"fields": ["*"],
"populate": {

View File

@@ -48,7 +48,16 @@
}
},
"subscribe": {
"fields": ["*"]
"fields": ["*"],
"populate": {
"image": {
"fields": [
"name",
"mime",
"url"
]
}
}
},
"footer": {
"fields": ["*"],

View File

@@ -18,8 +18,17 @@
}
},
"subscribeNow": {
"fields": ["*"]
},
"fields": ["*"],
"populate": {
"image": {
"fields": [
"name",
"mime",
"url"
]
}
}
},
"footer": {
"fields": ["*"],
"populate": {

View File

@@ -10,8 +10,17 @@
}
},
"subscribeNow": {
"fields": ["*"]
},
"fields": ["*"],
"populate": {
"image": {
"fields": [
"name",
"mime",
"url"
]
}
}
},
"footer": {
"fields": ["*"],
"populate": {

View File

@@ -90,8 +90,17 @@
}
},
"subscribe": {
"fields": ["*"]
},
"fields": ["*"],
"populate": {
"image": {
"fields": [
"name",
"mime",
"url"
]
}
}
},
"footer": {
"fields": ["*"],
"populate": {

View File

@@ -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<T>(url: string): Promise<Payload<T>>{
const response = await this.httpGet(url);
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>>{
public async findContentType<T>(contentType: string, options?: FindContentOptions): Promise<Payload<T>> {
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;
}