[yoga-20] subscribe.component.tsx: make image editable
This commit is contained in:
@@ -72,7 +72,16 @@
|
||||
}
|
||||
},
|
||||
"subscribeNow": {
|
||||
"fields": ["*"]
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": [
|
||||
"name",
|
||||
"mime",
|
||||
"url"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"fields": ["*"],
|
||||
|
||||
@@ -16,8 +16,17 @@
|
||||
"fields": ["*"]
|
||||
},
|
||||
"subscribe": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": [
|
||||
"name",
|
||||
"mime",
|
||||
"url"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
|
||||
@@ -51,8 +51,17 @@
|
||||
}
|
||||
},
|
||||
"subscribe": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": [
|
||||
"name",
|
||||
"mime",
|
||||
"url"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
|
||||
@@ -43,8 +43,17 @@
|
||||
}
|
||||
},
|
||||
"subscribeNow": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": [
|
||||
"name",
|
||||
"mime",
|
||||
"url"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"blogs": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
|
||||
@@ -48,7 +48,16 @@
|
||||
}
|
||||
},
|
||||
"subscribe": {
|
||||
"fields": ["*"]
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": [
|
||||
"name",
|
||||
"mime",
|
||||
"url"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"fields": ["*"],
|
||||
|
||||
@@ -18,8 +18,17 @@
|
||||
}
|
||||
},
|
||||
"subscribeNow": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": [
|
||||
"name",
|
||||
"mime",
|
||||
"url"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
|
||||
@@ -10,8 +10,17 @@
|
||||
}
|
||||
},
|
||||
"subscribeNow": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": [
|
||||
"name",
|
||||
"mime",
|
||||
"url"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
|
||||
@@ -90,8 +90,17 @@
|
||||
}
|
||||
},
|
||||
"subscribe": {
|
||||
"fields": ["*"]
|
||||
},
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
"image": {
|
||||
"fields": [
|
||||
"name",
|
||||
"mime",
|
||||
"url"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"footer": {
|
||||
"fields": ["*"],
|
||||
"populate": {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user