Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional message fields to promotion #190

Merged
merged 2 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/graphql/generates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8911,14 +8911,14 @@ export type GetPromotionsQueryVariables = Exact<{
}>;


export type GetPromotionsQuery = { __typename?: 'Query', promotions: { __typename?: 'PromotionConnection', totalCount: number, nodes?: Array<{ __typename?: 'Promotion', _id: string, triggerType: TriggerType, promotionType: string, label: string, description?: string | null, enabled: boolean, name: string, state: PromotionState, referenceId: number, shopId: string, startDate: any, endDate?: any | null, createdAt: any, updatedAt: any, triggers?: Array<{ __typename?: 'Trigger', triggerKey: string, triggerParameters?: any | null }> | null, actions?: Array<{ __typename?: 'Action', actionKey: string, actionParameters?: any | null }> | null, stackability?: { __typename?: 'Stackability', key: string, parameters?: any | null } | null } | null> | null } };
export type GetPromotionsQuery = { __typename?: 'Query', promotions: { __typename?: 'PromotionConnection', totalCount: number, nodes?: Array<{ __typename?: 'Promotion', _id: string, triggerType: TriggerType, promotionType: string, label: string, description?: string | null, enabled: boolean, name: string, state: PromotionState, referenceId: number, shopId: string, startDate: any, endDate?: any | null, callToActionMessage?: string | null, termsAndConditionsUrl?: string | null, createdAt: any, updatedAt: any, triggers?: Array<{ __typename?: 'Trigger', triggerKey: string, triggerParameters?: any | null }> | null, actions?: Array<{ __typename?: 'Action', actionKey: string, actionParameters?: any | null }> | null, stackability?: { __typename?: 'Stackability', key: string, parameters?: any | null } | null } | null> | null } };

export type GetPromotionQueryVariables = Exact<{
input?: InputMaybe<PromotionQueryInput>;
}>;


export type GetPromotionQuery = { __typename?: 'Query', promotion?: { __typename?: 'Promotion', _id: string, triggerType: TriggerType, promotionType: string, label: string, description?: string | null, enabled: boolean, name: string, state: PromotionState, referenceId: number, shopId: string, startDate: any, endDate?: any | null, createdAt: any, updatedAt: any, triggers?: Array<{ __typename?: 'Trigger', triggerKey: string, triggerParameters?: any | null }> | null, actions?: Array<{ __typename?: 'Action', actionKey: string, actionParameters?: any | null }> | null, stackability?: { __typename?: 'Stackability', key: string, parameters?: any | null } | null } | null };
export type GetPromotionQuery = { __typename?: 'Query', promotion?: { __typename?: 'Promotion', _id: string, triggerType: TriggerType, promotionType: string, label: string, description?: string | null, enabled: boolean, name: string, state: PromotionState, referenceId: number, shopId: string, startDate: any, endDate?: any | null, callToActionMessage?: string | null, termsAndConditionsUrl?: string | null, createdAt: any, updatedAt: any, triggers?: Array<{ __typename?: 'Trigger', triggerKey: string, triggerParameters?: any | null }> | null, actions?: Array<{ __typename?: 'Action', actionKey: string, actionParameters?: any | null }> | null, stackability?: { __typename?: 'Stackability', key: string, parameters?: any | null } | null } | null };

export type UpdatePromotionMutationVariables = Exact<{
input?: InputMaybe<PromotionUpdateInput>;
Expand Down Expand Up @@ -9591,6 +9591,8 @@ export const GetPromotionsDocument = `
key
parameters
}
callToActionMessage
termsAndConditionsUrl
createdAt
updatedAt
}
Expand Down Expand Up @@ -9639,6 +9641,8 @@ export const GetPromotionDocument = `
key
parameters
}
callToActionMessage
termsAndConditionsUrl
createdAt
updatedAt
}
Expand Down
16 changes: 15 additions & 1 deletion src/pages/Promotions/Details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type PromotionFormValue = {
startDate: string | null
endDate: string | null
enabled: boolean
callToActionMessage: string
termsAndConditionsUrl: string
}


Expand Down Expand Up @@ -146,6 +148,8 @@ const PromotionDetails = () => {
) : [],
stackability: data?.promotion?.stackability || { key: "none", parameters: {} },
label: data?.promotion?.label || "",
callToActionMessage: data?.promotion?.callToActionMessage || "",
termsAndConditionsUrl: data?.promotion?.termsAndConditionsUrl || "",
startDate: data?.promotion?.startDate || null,
endDate: data?.promotion?.endDate || null,
enabled: data?.promotion?.enabled || false
Expand Down Expand Up @@ -234,12 +238,22 @@ const PromotionDetails = () => {
<AvailableDateField disabled={shouldDisableField}/>
</Card>
<Card title="Promotion Message" divider>
<Box mt={1} width="50%">
<Box mt={1} sx={{ width: { md: "50%", sm: "100%" } }}>
<FastField
name="label"
component={TextField}
label="Checkout Label"
/>
<FastField
name="callToActionMessage"
component={TextField}
label="PDP Call to Action"
/>
<FastField
name="termsAndConditionsUrl"
component={TextField}
label="Terms & Conditions Link"
/>
</Box>
</Card>
</Stack>
Expand Down
4 changes: 4 additions & 0 deletions src/pages/Promotions/Details/validation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as Yup from "yup";

import { urlSchema } from "@utils/validate";

const ruleSchema = Yup.object({
path: Yup.string().required("This field is required"),
operator: Yup.string().required("This field is required"),
Expand All @@ -15,6 +17,8 @@ const shippingRuleSchema = Yup.object({ value: Yup.array().min(1, "This field mu
export const promotionSchema = Yup.object().shape({
name: Yup.string().trim().required("This field is required").max(280, "This field must be at most 280 characters"),
label: Yup.string().trim().required("This field is required").max(280, "This field must be at most 280 characters"),
callToActionMessage: Yup.string().trim().max(100, "This field must be at most 100 characters"),
termsAndConditionsUrl: urlSchema,
description: Yup.string().max(5000, "This field must be at most 5000 characters"),
actions: Yup.array().of(Yup.object({
actionKey: Yup.string(),
Expand Down
4 changes: 4 additions & 0 deletions src/pages/Promotions/promotions.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ query getPromotions(
key
parameters
}
callToActionMessage
termsAndConditionsUrl
createdAt
updatedAt
}
Expand Down Expand Up @@ -68,6 +70,8 @@ query getPromotion($input: PromotionQueryInput) {
key
parameters
}
callToActionMessage
termsAndConditionsUrl
createdAt
updatedAt
}
Expand Down