diff --git a/yoga-app/src/components/subscribe.component.tsx b/yoga-app/src/components/subscribe.component.tsx
index 454e4d5..c357b49 100644
--- a/yoga-app/src/components/subscribe.component.tsx
+++ b/yoga-app/src/components/subscribe.component.tsx
@@ -5,7 +5,7 @@ import {
import clsx from "clsx";
export interface Props{
config: YogaSubscribeNowComponent_Plain,
- styleClass: string
+ styleClass?: string
}
const SubscribeComponent = ({
config: {title,header,placeHolderEmail,buttonSubscribeLabel},
diff --git a/yoga-app/src/components/yoga.image.component.tsx b/yoga-app/src/components/yoga.image.component.tsx
index 901b0d9..8b2c41b 100644
--- a/yoga-app/src/components/yoga.image.component.tsx
+++ b/yoga-app/src/components/yoga.image.component.tsx
@@ -11,6 +11,7 @@ export interface Properties {
const YogaImageComponent = ( {src,alt,className,style}: Properties ) => {
return (
+ /* eslint-disable @next/next/no-img-element */

);
}
diff --git a/yoga-app/src/types/generated-strapi-interfaces/api/article.ts b/yoga-app/src/types/generated-strapi-interfaces/api/article.ts
index 0ed5302..4d334fe 100644
--- a/yoga-app/src/types/generated-strapi-interfaces/api/article.ts
+++ b/yoga-app/src/types/generated-strapi-interfaces/api/article.ts
@@ -17,7 +17,7 @@ export interface Article {
cover?: { data: Media };
author?: { data: Author };
category?: { data: Category };
- blocks?: any;
+ blocks?: object;
};
}
export interface Article_Plain {
@@ -28,7 +28,7 @@ export interface Article_Plain {
cover?: Media_Plain;
author?: Author_Plain;
category?: Category_Plain;
- blocks?: any;
+ blocks?: object;
}
export interface Article_NoRelations {
@@ -39,7 +39,7 @@ export interface Article_NoRelations {
cover?: number;
author?: number;
category?: number;
- blocks?: any;
+ blocks?: object;
}
export interface Article_AdminPanelLifeCycle {
@@ -50,5 +50,5 @@ export interface Article_AdminPanelLifeCycle {
cover?: AdminPanelRelationPropertyModification
;
author?: AdminPanelRelationPropertyModification;
category?: AdminPanelRelationPropertyModification;
- blocks?: any;
+ blocks?: object;
}
diff --git a/yoga-app/src/util/form-util.ts b/yoga-app/src/util/form-util.ts
new file mode 100644
index 0000000..25f1762
--- /dev/null
+++ b/yoga-app/src/util/form-util.ts
@@ -0,0 +1,53 @@
+import {ValidateFunction} from "ajv";
+
+export type FormControl = {
+ name: string,
+ value?: string,
+ error?: string
+}
+
+export function formDataToJson(formData: FormData) {
+ const object: Record = {};
+ formData.forEach((value, key) => {
+ if ( key == 'formState'){
+ return;
+ }
+ // Reflect.has in favor of: object.hasOwnProperty(key)
+ if (!Reflect.has(object, key)) {
+ object[key] = value;
+ return;
+ }
+ if (!Array.isArray(object[key])) {
+ object[key] = [];
+ }
+ if (value instanceof File) {
+ (object[key] as File[]).push(value);
+ } else {
+ (object[key] as string[]).push(value);
+ }
+ });
+ return object;
+}
+
+/* eslint-disable @typescript-eslint/no-explicit-any */
+export function copyFormValues(form: Record,jsonFormData: Record){
+ const keys = Object.getOwnPropertyNames(form);
+ for(const key of keys){
+ if (key == 'formState'){
+ continue;
+ }
+ const formControl: FormControl = form[key];
+ formControl.value = jsonFormData[key] as string;
+
+ }
+}
+/* eslint-disable @typescript-eslint/no-explicit-any */
+export function copyValidationErrors(form: Record,validateFunction: ValidateFunction){
+ const keys = Object.getOwnPropertyNames(form);
+ for(const key of keys){
+ const formControl: FormControl = form[key];
+ if ( key == 'formState') continue;
+ formControl.error = validateFunction.errors?.find( err => err.instancePath =="/"+key)?.message;
+
+ }
+}
diff --git a/yoga-app/src/validation/validation.ts b/yoga-app/src/validation/validation.ts
new file mode 100644
index 0000000..d62cdcc
--- /dev/null
+++ b/yoga-app/src/validation/validation.ts
@@ -0,0 +1,23 @@
+import Ajv, {JSONSchemaType} from "ajv"
+import addFormats from "ajv-formats"
+import {ContactFormData} from "@/actions/contactus-actions";
+
+const ajv = new Ajv({allErrors: true}) // options can be passed, e.g. {allErrors: true}
+addFormats(ajv)
+
+const contactUsFormSchema: JSONSchemaType = {
+ type: "object",
+ properties: {
+ firstname: {type: "string",minLength: 3,maxLength: 20},
+ lastname: {type: "string",minLength: 3,maxLength: 20},
+ phone: {type: "string",minLength: 3,maxLength: 20},
+ email: {type: "string", format: 'email'},
+ comment: {type: "string",minLength: 3,maxLength: 500}
+ },
+ required: ["firstname","lastname","phone","email","comment"],
+ additionalProperties: true
+}
+
+export const contactUsFormValidator = ajv.compile(contactUsFormSchema)
+
+
diff --git a/yoga-cms/Dockerfile b/yoga-cms/Dockerfile
index ac0bf16..051c910 100644
--- a/yoga-cms/Dockerfile
+++ b/yoga-cms/Dockerfile
@@ -7,11 +7,11 @@ ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY package.json package-lock.json ./
RUN npm install -g node-gyp
-RUN npm config set fetch-retry-maxtimeout 600000 -g && npm install --only=production
+RUN npm config set fetch-retry-maxtimeout 600000 -g && npm install --only=production --debug
ENV PATH=/opt/node_modules/.bin:$PATH
WORKDIR /opt/app
COPY . .
-RUN npm run build
+RUN npm run build --debug
# Creating final production image
FROM node:18-alpine
diff --git a/yoga-cms/Dockerfile.prod b/yoga-cms/Dockerfile.prod
new file mode 100644
index 0000000..e4873e8
--- /dev/null
+++ b/yoga-cms/Dockerfile.prod
@@ -0,0 +1,31 @@
+# Creating multi-stage build for production
+FROM node:18-alpine as build
+RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev git > /dev/null 2>&1
+ARG NODE_ENV=production
+ENV NODE_ENV=${NODE_ENV}
+
+WORKDIR /opt/
+COPY package.json package-lock.json ./
+RUN npm install -g node-gyp
+RUN npm config set fetch-retry-maxtimeout 600000 -g && npm install --only=production --debug
+ENV PATH=/opt/node_modules/.bin:$PATH
+WORKDIR /opt/app
+COPY . .
+RUN pwd && ls -lah
+RUN npm run build --debug
+
+# Creating final production image
+FROM node:18-alpine
+# RUN apk add --no-cache vips-dev
+# ARG NODE_ENV=production
+# ENV NODE_ENV=${NODE_ENV}
+# WORKDIR /opt/
+# COPY --from=build /opt/node_modules ./node_modules
+# WORKDIR /opt/app
+# COPY --from=build /opt/app ./
+# ENV PATH=/opt/node_modules/.bin:$PATH
+
+# RUN chown -R node:node /opt/app
+USER node
+EXPOSE 1337
+# CMD ["npm", "run", "start"]