Skip to content

Commit

Permalink
Merge pull request #123 from Sitecore/change-content-source
Browse files Browse the repository at this point in the history
Change content source
  • Loading branch information
jst-cyr authored Dec 12, 2023
2 parents 84775a7 + 45bde99 commit 3db2fd7
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 62 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/OutcomeFlow/outcome.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('Outcome Page', () => {
it('XM Cloud should be the only product', () => {
cy.visit('/');
cy.get('#start').click();
cy.get('.css-1izj7gt > :nth-child(4)').click();
cy.get('[value="Developer"]').click();
cy.get(':nth-child(9) > .chakra-button').click();
cy.get('.chakra-container > :nth-child(3) > .chakra-button').click();
cy.get('[value="xm"]').click();
Expand All @@ -22,7 +22,7 @@ describe('Outcome Page', () => {
cy.visit('/');
cy.get('#start').click();
cy.get(':nth-child(11) > .chakra-button').click();
cy.get('.css-1izj7gt > :nth-child(2)').click();
cy.get('[value="Developer"]').click();
cy.get('.chakra-container > :nth-child(3) > .chakra-button').click();
cy.get('[value="xp"]').click();
cy.get('[value="sessionpersonalization"]').click();
Expand Down
4 changes: 2 additions & 2 deletions cypress/fixtures/themes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "a5F4KpHzIkO1Re9iHmJjWA",
"name": "Fantasy Adventure",
"description": "Migrations can be fun! Take a journey through the fantasy world of the 5th Age. You will be guided through a maze of challenges that will help you find the scroll of Sitecore migration that will guide you and your party to saving the realm!",
"characterImage": {
"image": {
"results": [
{
"id": "vMw9EsLFnkuUk7bATvTOJQ",
Expand All @@ -22,4 +22,4 @@
]
}
}
]
]
10 changes: 5 additions & 5 deletions src/GraphQL/Queries/Outcome.gql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
fragment OutcomeDetails on GameOutcome {
fragment OutcomeDetails on Outcome {
id
name
themes {
results {
... on GameTheme {
... on Theme {
id
name
}
Expand All @@ -13,7 +13,7 @@ fragment OutcomeDetails on GameOutcome {
productsIntro
outcomeReasons {
results {
... on GameOutcomeReason {
... on Outcomereason {
product
reason
}
Expand All @@ -34,15 +34,15 @@ fragment OutcomeDetails on GameOutcome {
}

query GetOutcomeByThemeIdQuery($id: ID!) {
allGameOutcome(where: { themes: { gameOutcome_ids: $id } }) {
allOutcome(where: { themes: { outcome_ids: $id } }) {
results {
...OutcomeDetails
}
}
}

query GetOutcomeByIdQuery($id: String!) {
gameOutcome(id: $id) {
outcome(id: $id) {
...OutcomeDetails
}
}
10 changes: 5 additions & 5 deletions src/GraphQL/Queries/Personas.gql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fragment PersonaFragment on GamePersona {
fragment PersonaFragment on Persona {
id
name
personaImage {
Expand All @@ -10,7 +10,7 @@ fragment PersonaFragment on GamePersona {
}
theme {
results {
... on GameTheme {
... on Theme {
id
name
}
Expand All @@ -19,21 +19,21 @@ fragment PersonaFragment on GamePersona {
}

query GetAllPersonasQuery {
allGamePersona {
allPersona {
results {
...PersonaFragment
}
}
}

query GetPersonaByIdQuery($id: String!) {
gamePersona(id: $id) {
persona(id: $id) {
...PersonaFragment
}
}

query GetPersonasByThemeIdQuery($id: ID!) {
allGamePersona(where: { theme: { gamePersona_ids: $id } }) {
allPersona(where: { theme: { persona_ids: $id } }) {
results {
...PersonaFragment
}
Expand Down
10 changes: 5 additions & 5 deletions src/GraphQL/Queries/Prompts.gql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
fragment PromptDetails on Prompt {
id
name
questionid
text
questionId
question
bodyText
theme {
results {
__typename
... on GameTheme {
... on Theme {
id
}
}
Expand All @@ -21,14 +21,14 @@ fragment PromptDetails on Prompt {
}
persona {
results {
... on GamePersona {
... on Persona {
id
}
}
}
optionType {
results {
... on PromptOptionTypes {
... on PromptOptionType {
id
name
}
Expand Down
12 changes: 6 additions & 6 deletions src/GraphQL/Queries/Themes.gql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
fragment Theme on GameTheme {
fragment ThemeFragment on Theme {
id
name
description
chakraTheme
startButtonText
disabled
characterImage {
image {
results {
id
fileUrl
Expand All @@ -22,15 +22,15 @@ fragment Theme on GameTheme {
}

query GetAllThemesQuery {
allGameTheme {
allTheme {
results {
...Theme
...ThemeFragment
}
}
}

query GetThemesByIdQuery($id: String!) {
gameTheme(id: $id) {
...Theme
theme(id: $id) {
...ThemeFragment
}
}
10 changes: 5 additions & 5 deletions src/components/Prompts/CurrentPrompt/CurrentPrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const CurrentPrompt: FC<PromptProps> = ({ prompt, answerSelected }) => {

let answer: IAnswer = {
promptId: prompt!.id,
promptQuestionId: prompt!.questionid,
prompt: prompt!.text,
promptQuestionId: prompt!.questionId,
prompt: prompt!.question,
value: new Array(option.value),
valuePrettyText: new Array(option.label),
};
Expand All @@ -32,8 +32,8 @@ export const CurrentPrompt: FC<PromptProps> = ({ prompt, answerSelected }) => {
const multiSelectSubmit = (selectedOptions: IOption[]) => {
let answer: IAnswer = {
promptId: prompt!.id,
promptQuestionId: prompt!.questionid,
prompt: prompt!.text,
promptQuestionId: prompt!.questionId,
prompt: prompt!.question,
value: selectedOptions.map((o) => o.value),
valuePrettyText: selectedOptions.map((o) => o.label),
};
Expand Down Expand Up @@ -67,7 +67,7 @@ export const CurrentPrompt: FC<PromptProps> = ({ prompt, answerSelected }) => {
paddingLeft={{ base: '15px', md: '15px' }}
paddingRight={{ base: '15px', md: '15px' }}
>
{prompt?.text}
{prompt?.question}
</Text>
</CardBody>
<CardFooter padding={'15px'}>
Expand Down
3 changes: 0 additions & 3 deletions src/components/ui/ChooseCharacterDisplay/ChooseCharacter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ export const ChooseCharacter: FC<ChooseCharacterProps> = ({ avatars, personas })
router.push('/prompt');
};

console.log('Personas', personas);
console.log('Avatars', avatars);

return (
<>
<PersonaList
Expand Down
6 changes: 3 additions & 3 deletions src/components/ui/InfoBar/InfoBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export const InfoBar: FC<InfoBarProps> = ({ remainingQuestions, isSolution = fal
)}
</GridItem>
<GridItem colSpan={6}>
{gameInfoContext.theme?.characterImage?.results !== undefined && (
{gameInfoContext.theme?.image?.results !== undefined && (
<AvatarGroup spacing="xs">
<Avatar
size={'xl'}
src={gameInfoContext.theme.characterImage!.results[0].fileUrl}
title={gameInfoContext.theme.characterImage!.results[0].fileName ?? ''}
src={gameInfoContext.theme.image!.results[0].fileUrl}
title={gameInfoContext.theme.image!.results[0].fileName ?? ''}
/>
<div style={{ flex: 1 }}>
<Text>{gameInfoContext.theme.name}</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/ui/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export const Settings: FC<SettingsProps> = () => {

if (themes && themes.length > 0) {
setThemes(themes);
} else {
throw new Error('No themes loaded. At least one theme is required.');
}

setLoading(false);
Expand Down
18 changes: 4 additions & 14 deletions src/components/ui/ThemeList/ThemeList.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import {
Box,
Button,
Center,
Flex,
Heading,
Image,
Stack,
Text,
useColorModeValue
} from '@chakra-ui/react';
import { Box, Button, Center, Flex, Heading, Image, Stack, Text, useColorModeValue } from '@chakra-ui/react';
import { ITheme } from 'models';
import { FC } from 'react';

Expand Down Expand Up @@ -47,10 +37,10 @@ export const ThemeList: FC<ThemeListProps> = ({ themes, handleThemeChange, class
height={'100%'}
bg={useColorModeValue('white', 'gray.800')}
>
{theme.characterImage?.results !== undefined && (
{theme.image?.results !== undefined && (
<Image
src={theme.characterImage!.results[0].fileUrl}
alt={theme.characterImage!.results[0].fileName ?? ''}
src={theme.image!.results[0].fileUrl}
alt={theme.image!.results[0].fileName ?? ''}
maxHeight={['0', '300px']}
fit={'cover'}
rounded={['sm', 'lg']}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/OutcomeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { GetOutcomeByIdQuery, GetOutcomeByThemeIdQuery } from '../GraphQL/Querie
import { chOneService } from './CHOneService';

export const OutcomeService = () => {
const GetOutcomeById = async (gameOutcomeId: string): Promise<IOutcome | undefined> => {
const GetOutcomeById = async (outcomeId: string): Promise<IOutcome | undefined> => {
const { error, data } = await chOneService().query({
query: GetOutcomeByIdQuery,
variables: { id: gameOutcomeId },
variables: { id: outcomeId },
});

if (error) {
console.log(error);
return undefined;
}

const results = data?.gameOutcome as IOutcome;
const results = data?.outcome as IOutcome;

return results;
};
Expand All @@ -31,7 +31,7 @@ export const OutcomeService = () => {
return undefined;
}

const results = data?.allGameOutcome as IResult<IOutcome[]>;
const results = data?.allOutcome as IResult<IOutcome[]>;

return results;
};
Expand Down
4 changes: 2 additions & 2 deletions src/lib/PersonaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const PersonaService = () => {
return undefined;
}

const results = data?.gamePersona as IPersona;
const results = data?.persona as IPersona;

return results;
};
Expand All @@ -28,7 +28,7 @@ export const PersonaService = () => {
return undefined;
}

const results = data?.allGamePersona as IResult<IPersona[]>;
const results = data?.allPersona as IResult<IPersona[]>;

return results;
};
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ThemeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const ThemeService = () => {
return null;
}

const results = data?.allGameTheme as IResult<ITheme[]>;
const results = data?.allTheme as IResult<ITheme[]>;

return results;
};
Expand All @@ -24,7 +24,7 @@ export const ThemeService = () => {
return undefined;
}

const results = data?.gameTheme as ITheme;
const results = data?.theme as ITheme;

return results;
};
Expand Down
4 changes: 2 additions & 2 deletions src/models/IPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { JSONContent } from '@tiptap/core';
import { IImage, IOption, IOptionType, IPersona, IResult, ITheme } from 'models';

export interface IPrompt {
text: string;
question: string;
bodyText?: JSONContent;
id: string;
name: string;
questionid: string;
questionId: string;
options?: IResult<IOption[]>;
optionType: IResult<IOptionType[]>;
nextPrompts?: IResult<IPrompt[]>; // If prompt requires additional prompts, this is the list of prompt ids
Expand Down
2 changes: 1 addition & 1 deletion src/models/ITheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface ITheme {
name: string;
description: string;
id: string;
characterImage?: IResult<IImage[]>;
image?: IResult<IImage[]>;
avatarGallery?: IResult<IImage[]>;
chakraTheme: string;
startButtonText: string;
Expand Down
2 changes: 1 addition & 1 deletion src/models/OutcomeConditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class OutcomeConditions {
}

/**
* Analyzes current answers to determine if this is a complex personalizations cenario
* Analyzes current answers to determine if this is a complex personalization scenario
* that would require Sitecore Personalize or CDP
*/
isComplexPersonalization(): boolean {
Expand Down

1 comment on commit 3db2fd7

@vercel
Copy link

@vercel vercel bot commented on 3db2fd7 Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.