Commit 113647d2 authored by Max Alekseenko's avatar Max Alekseenko

update schema

parent 123cf3f8
...@@ -4,6 +4,7 @@ import chain from '../chain'; ...@@ -4,6 +4,7 @@ import chain from '../chain';
import { getEnvValue, getExternalAssetFilePath } from '../utils'; import { getEnvValue, getExternalAssetFilePath } from '../utils';
// config file will be downloaded at run-time and saved in the public folder // config file will be downloaded at run-time and saved in the public folder
const enabled = getEnvValue('NEXT_PUBLIC_MARKETPLACE_ENABLED');
const configUrl = getExternalAssetFilePath('NEXT_PUBLIC_MARKETPLACE_CONFIG_URL'); const configUrl = getExternalAssetFilePath('NEXT_PUBLIC_MARKETPLACE_CONFIG_URL');
const submitFormUrl = getEnvValue('NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM'); const submitFormUrl = getEnvValue('NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM');
const suggestIdeasFormUrl = getEnvValue('NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM'); const suggestIdeasFormUrl = getEnvValue('NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM');
...@@ -17,7 +18,7 @@ const config: Feature<( ...@@ -17,7 +18,7 @@ const config: Feature<(
{ api: { endpoint: string; basePath: string } } { api: { endpoint: string; basePath: string } }
) & { submitFormUrl: string; categoriesUrl: string | undefined; suggestIdeasFormUrl: string | undefined } ) & { submitFormUrl: string; categoriesUrl: string | undefined; suggestIdeasFormUrl: string | undefined }
> = (() => { > = (() => {
if (chain.rpcUrl && submitFormUrl) { if (enabled === 'true' && chain.rpcUrl && submitFormUrl) {
if (configUrl) { if (configUrl) {
return Object.freeze({ return Object.freeze({
title, title,
......
...@@ -83,15 +83,27 @@ const marketplaceSchema = yup ...@@ -83,15 +83,27 @@ const marketplaceSchema = yup
NEXT_PUBLIC_MARKETPLACE_CONFIG_URL: yup NEXT_PUBLIC_MARKETPLACE_CONFIG_URL: yup
.array() .array()
.json() .json()
.of(marketplaceAppSchema), .of(marketplaceAppSchema)
.when('NEXT_PUBLIC_MARKETPLACE_ENABLED', {
is: true,
then: (schema) => schema,
// eslint-disable-next-line max-len
otherwise: (schema) => schema.max(1, 'NEXT_PUBLIC_MARKETPLACE_CONFIG_URL cannot not be used without NEXT_PUBLIC_MARKETPLACE_ENABLED'),
}),
NEXT_PUBLIC_MARKETPLACE_CATEGORIES_URL: yup NEXT_PUBLIC_MARKETPLACE_CATEGORIES_URL: yup
.array() .array()
.json() .json()
.of(yup.string()), .of(yup.string())
.when('NEXT_PUBLIC_MARKETPLACE_ENABLED', {
is: true,
then: (schema) => schema,
// eslint-disable-next-line max-len
otherwise: (schema) => schema.max(1, 'NEXT_PUBLIC_MARKETPLACE_CATEGORIES_URL cannot not be used without NEXT_PUBLIC_MARKETPLACE_ENABLED'),
}),
NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM: yup NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM: yup
.string() .string()
.when('NEXT_PUBLIC_MARKETPLACE_ENABLED', { .when('NEXT_PUBLIC_MARKETPLACE_ENABLED', {
is: (enabled: boolean) => enabled, is: true,
then: (schema) => schema.test(urlTest).required(), then: (schema) => schema.test(urlTest).required(),
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
otherwise: (schema) => schema.max(-1, 'NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM cannot not be used without NEXT_PUBLIC_MARKETPLACE_ENABLED'), otherwise: (schema) => schema.max(-1, 'NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM cannot not be used without NEXT_PUBLIC_MARKETPLACE_ENABLED'),
...@@ -99,7 +111,7 @@ const marketplaceSchema = yup ...@@ -99,7 +111,7 @@ const marketplaceSchema = yup
NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM: yup NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM: yup
.string() .string()
.when('NEXT_PUBLIC_MARKETPLACE_ENABLED', { .when('NEXT_PUBLIC_MARKETPLACE_ENABLED', {
is: (enabled: boolean) => enabled, is: true,
then: (schema) => schema.test(urlTest), then: (schema) => schema.test(urlTest),
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
otherwise: (schema) => schema.max(-1, 'NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM cannot not be used without NEXT_PUBLIC_MARKETPLACE_ENABLED'), otherwise: (schema) => schema.max(-1, 'NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM cannot not be used without NEXT_PUBLIC_MARKETPLACE_ENABLED'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment