diff --git a/apps/admin-x-settings/src/api/recommendations.ts b/apps/admin-x-settings/src/api/recommendations.ts index 53c6855b9f..25f5001c7f 100644 --- a/apps/admin-x-settings/src/api/recommendations.ts +++ b/apps/admin-x-settings/src/api/recommendations.ts @@ -4,7 +4,7 @@ import {Meta, apiUrl, createInfiniteQuery, createMutation, useFetchApi} from '.. export type Recommendation = { id: string title: string - reason: string|null + description: string|null excerpt: string|null // Fetched from the site meta data featured_image: string|null // Fetched from the site meta data favicon: string|null // Fetched from the site meta data diff --git a/apps/admin-x-settings/src/components/settings/site/recommendations/AddRecommendationModal.tsx b/apps/admin-x-settings/src/components/settings/site/recommendations/AddRecommendationModal.tsx index faab2694e5..2aeda99a91 100644 --- a/apps/admin-x-settings/src/components/settings/site/recommendations/AddRecommendationModal.tsx +++ b/apps/admin-x-settings/src/components/settings/site/recommendations/AddRecommendationModal.tsx @@ -61,7 +61,7 @@ const AddRecommendationModal: React.FC = ({r }, onSaveError: handleError, onValidate: (state) => { - const newErrors = validateReasonForm(state); + const newErrors = validateDescriptionForm(state); if (Object.keys(newErrors).length !== 0) { showToast({ @@ -127,7 +127,7 @@ const AddRecommendationModalConfirm: React.FC = ({r } }} > - + ; }; diff --git a/apps/admin-x-settings/src/components/settings/site/recommendations/EditRecommendationModal.tsx b/apps/admin-x-settings/src/components/settings/site/recommendations/EditRecommendationModal.tsx index 41d2e26bd6..4d5feb3597 100644 --- a/apps/admin-x-settings/src/components/settings/site/recommendations/EditRecommendationModal.tsx +++ b/apps/admin-x-settings/src/components/settings/site/recommendations/EditRecommendationModal.tsx @@ -2,7 +2,7 @@ import ConfirmationModal from '../../../../admin-x-ds/global/modal/ConfirmationM import Modal from '../../../../admin-x-ds/global/modal/Modal'; import NiceModal, {useModal} from '@ebay/nice-modal-react'; import React from 'react'; -import RecommendationReasonForm, {validateReasonForm} from './RecommendationReasonForm'; +import RecommendationDescriptionForm, {validateDescriptionForm} from './RecommendationDescriptionForm'; import useForm from '../../../../hooks/useForm'; import useHandleError from '../../../../utils/api/handleError'; import useRouting from '../../../../hooks/useRouting'; @@ -33,7 +33,7 @@ const EditRecommendationModal: React.FC { - const newErrors = validateReasonForm(state); + const newErrors = validateDescriptionForm(state); if (Object.keys(newErrors).length !== 0) { showToast({ @@ -119,7 +119,7 @@ const EditRecommendationModal: React.FC - + ; }; diff --git a/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationReasonForm.tsx b/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationDescriptionForm.tsx similarity index 71% rename from apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationReasonForm.tsx rename to apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationDescriptionForm.tsx index 04cc7e3c17..e65936362e 100644 --- a/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationReasonForm.tsx +++ b/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationDescriptionForm.tsx @@ -18,7 +18,7 @@ interface Props { setErrors: (errors: ErrorMessages) => void } -export const validateReasonFormField = function (errors: ErrorMessages, field: 'title'|'reason', value: string|null) { +export const validateDescriptionFormField = function (errors: ErrorMessages, field: 'title'|'description', value: string|null) { const cloned = {...errors}; switch (field) { case 'title': @@ -28,11 +28,11 @@ export const validateReasonFormField = function (errors: ErrorMessages, field: ' delete cloned.title; } break; - case 'reason': + case 'description': if (value && value.length > 200) { - cloned.reason = 'Description cannot be longer than 200 characters'; + cloned.description = 'Description cannot be longer than 200 characters'; } else { - delete cloned.reason; + delete cloned.description; } break; default: @@ -43,16 +43,16 @@ export const validateReasonFormField = function (errors: ErrorMessages, field: ' return cloned; }; -export const validateReasonForm = function (formState: EditOrAddRecommendation) { +export const validateDescriptionForm = function (formState: EditOrAddRecommendation) { let newErrors: ErrorMessages = {}; - newErrors = validateReasonFormField(newErrors, 'title', formState.title); - newErrors = validateReasonFormField(newErrors, 'reason', formState.reason); + newErrors = validateDescriptionFormField(newErrors, 'title', formState.title); + newErrors = validateDescriptionFormField(newErrors, 'description', formState.description); return newErrors; }; -const RecommendationReasonForm: React.FC> = ({showURL, formState, updateForm, errors, clearError, setErrors}) => { - const [reasonLength, setReasonLength] = React.useState(formState?.reason?.length || 0); - const reasonLengthColor = reasonLength > 200 ? 'text-red' : 'text-green'; +const RecommendationDescriptionForm: React.FC> = ({showURL, formState, updateForm, errors, clearError, setErrors}) => { + const [descriptionLength, setDescriptionLength] = React.useState(formState?.description?.length || 0); + const descriptionLengthColor = descriptionLength > 200 ? 'text-red' : 'text-green'; // Do an intial validation on mounting const didValidate = React.useRef(false); @@ -61,7 +61,7 @@ const RecommendationReasonForm: React.FC {formState.title} - {formState.reason && {formState.reason}} + {formState.description && {formState.description}} {formState.one_click_subscribe && Subscribe} @@ -108,7 +108,7 @@ const RecommendationReasonForm: React.FC setErrors( - validateReasonFormField(errors, 'title', formState.title) + validateDescriptionFormField(errors, 'title', formState.title) )} onChange={(e) => { clearError?.('title'); @@ -117,22 +117,22 @@ const RecommendationReasonForm: React.FC