diff --git a/src/app/components/CSVButton/CSVButton.tsx b/src/app/components/CSVButton/CSVButton.tsx
index 9f7b0c6..9f2c5ae 100755
--- a/src/app/components/CSVButton/CSVButton.tsx
+++ b/src/app/components/CSVButton/CSVButton.tsx
@@ -3,7 +3,7 @@ import { parse } from "json2csv";
import { WordData } from "@/app/general/interfaces";
import { styles } from "@/app/components/CSVButton/CSVButton.style";
import CustomButton from "@/app/components/CustomButton";
-import { DOWNLOAD_RESULTS } from "@/app/general/constants";
+import { GENERAL_BUTTONS_TEXTS } from "@/app/general/constants";
export default function CSVButton({ queryWords }: { queryWords: WordData[] }) {
const handleDownload = () => {
@@ -16,7 +16,7 @@ export default function CSVButton({ queryWords }: { queryWords: WordData[] }) {
);
}
diff --git a/src/app/components/ChatButton/ChatButton.tsx b/src/app/components/ChatButton/ChatButton.tsx
index ca23a2c..8c4fc90 100644
--- a/src/app/components/ChatButton/ChatButton.tsx
+++ b/src/app/components/ChatButton/ChatButton.tsx
@@ -3,7 +3,7 @@ import { Grid } from "@mui/material";
import CustomButton from "@/app/components/CustomButton";
import SendIcon from "@mui/icons-material/Send";
import { styles } from "./ChatButton.style";
-import { SEND } from "@/app/general/constants";
+import { GENERAL_BUTTONS_TEXTS } from "@/app/general/constants";
export default function ChatButton() {
return (
@@ -12,7 +12,7 @@ export default function ChatButton() {
sx={styles.button}
endIcon={}
type="submit"
- text={SEND}
+ text={GENERAL_BUTTONS_TEXTS.send}
/>
);
diff --git a/src/app/components/Header/Header.tsx b/src/app/components/Header/Header.tsx
index 22606d9..fce5df4 100644
--- a/src/app/components/Header/Header.tsx
+++ b/src/app/components/Header/Header.tsx
@@ -11,13 +11,7 @@ import {
generalObject,
} from "@/app/general/interfaces";
import { strOrNum } from "@/app/general/types";
-import {
- SAMPLE_SIZE,
- HEADER_BUTTONS_TEXTS,
- NO_HELP_DESCRIPTION,
- NO_MAIL_PROVIDED,
- HEADER_DIALOGS_TITLES,
-} from "@/app/general/constants";
+import { HEADER_TEXTS } from "@/app/general/constants";
import { getTableInfo, convertToCSV, downloadCSV } from "@/app/general/utils";
import _ from "lodash";
@@ -30,7 +24,7 @@ export default function Header({ bot }: HeaderProps) {
const helpDescription = bot?._details.helpDescription;
const mailInfo = bot?._details.mailInfo;
const { botHeaders, botColumns, rows } = getTableInfo(bot);
- const sampleRows = _.sampleSize(rows, SAMPLE_SIZE);
+ const sampleRows = _.sampleSize(rows, HEADER_TEXTS.general.sampleSize);
const attributesRows = botColumns?.map((column) => ({
name: column.displayName,
@@ -42,24 +36,25 @@ export default function Header({ bot }: HeaderProps) {
const dataButtons = [
{
onClick: () => setOpenAttribute(true),
- text: HEADER_BUTTONS_TEXTS.attributes,
+ text: HEADER_TEXTS.buttons.attributes,
},
- { onClick: () => setOpenData(true), text: HEADER_BUTTONS_TEXTS.data },
+ { onClick: () => setOpenData(true), text: HEADER_TEXTS.buttons.data },
{
onClick: () => downloadCSV(csv, "data.csv"),
- text: HEADER_BUTTONS_TEXTS.download,
+ text: HEADER_TEXTS.buttons.download,
},
];
+
const helpButtons = [
- { onClick: () => setOpenHelp(true), text: HEADER_BUTTONS_TEXTS.help },
- { onClick: () => setOpenMail(true), text: HEADER_BUTTONS_TEXTS.mail },
+ { onClick: () => setOpenHelp(true), text: HEADER_TEXTS.buttons.help },
+ { onClick: () => setOpenMail(true), text: HEADER_TEXTS.buttons.mail },
];
const dialogs = [
{
open: openAttribute,
setOpen: setOpenAttribute,
- title: HEADER_DIALOGS_TITLES.attributes,
+ title: HEADER_TEXTS.dialogs.attributes,
children: (
headers={["name", "description"]}
@@ -70,7 +65,7 @@ export default function Header({ bot }: HeaderProps) {
{
open: openData,
setOpen: setOpenData,
- title: HEADER_DIALOGS_TITLES.data,
+ title: HEADER_TEXTS.dialogs.data,
children: (
>
headers={botHeaders}
@@ -81,16 +76,16 @@ export default function Header({ bot }: HeaderProps) {
{
open: openHelp,
setOpen: setOpenHelp,
- title: HEADER_DIALOGS_TITLES.help,
- content: helpDescription ?? NO_HELP_DESCRIPTION,
+ title: HEADER_TEXTS.dialogs.help,
+ content: helpDescription ?? HEADER_TEXTS.general.noHelpDescription,
},
{
open: openMail,
setOpen: setOpenMail,
- title: HEADER_DIALOGS_TITLES.mail,
+ title: HEADER_TEXTS.dialogs.mail,
children: (
- {mailInfo ?? NO_MAIL_PROVIDED}
+ {mailInfo ?? HEADER_TEXTS.general.noMailProvided}
),
},
diff --git a/src/app/components/Message/Message.test.tsx b/src/app/components/Message/Message.test.tsx
index 5403b8c..8bf56a5 100644
--- a/src/app/components/Message/Message.test.tsx
+++ b/src/app/components/Message/Message.test.tsx
@@ -3,7 +3,7 @@ import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import Message from "@/app/components/Message";
import { Colors, Message as IMessage } from "@/app/general/interfaces";
-import { colorCodes } from "@/app/general/resources";
+import { colorCodes } from "@/app/general/constants";
import { TypeOfQuestion, Sender } from "@/app/general/types";
// Mock props
diff --git a/src/app/components/Message/Message.tsx b/src/app/components/Message/Message.tsx
index 29e0e82..6c45536 100755
--- a/src/app/components/Message/Message.tsx
+++ b/src/app/components/Message/Message.tsx
@@ -3,7 +3,7 @@ import { styles } from "@/app/components/Message/Message.style";
import { MessageProps } from "@/app/general/interfaces";
import SmartToyIcon from "@mui/icons-material/SmartToy";
import PersonIcon from "@mui/icons-material/Person";
-import { colorCodes } from "@/app/general/resources";
+import { colorCodes } from "@/app/general/constants";
export default function Message({ message, colors }: MessageProps) {
const isBot = message?.sender === "bot";
diff --git a/src/app/general/constants.ts b/src/app/general/constants.ts
index d87e1b0..69e3345 100644
--- a/src/app/general/constants.ts
+++ b/src/app/general/constants.ts
@@ -1,20 +1,79 @@
-export const NO_RESULTS_FOUND = "No results found";
-export const SAMPLE_SIZE = 5;
-export const NO_HELP_DESCRIPTION = "No help description available";
-export const NO_MAIL_PROVIDED = "No mail provided for comments";
-export const DOWNLOAD_RESULTS = "Download Results";
-export const SEND = "Send";
+export const GENERAL_BUTTONS_TEXTS = {
+ downloadResults: "Download Results",
+ send: "Send",
+};
+
+export const RESOURCES_TEXTS = {
+ paramMessageDefault: "Enter value for parameter",
+ noResultsFound: "No results found",
+ propertyMessage: "Which property would you like to start with?",
+ factorOptions: "The options for this factor attribute are:",
+ addParameter: "Do you want to add another parameter?",
+ yesOption: "1. Yes",
+ noOption: "2. No",
+ restartMessage:
+ "To add another parameter, I will go through the same process as before.",
+ emptyMessage: "empty message",
+};
+
+const HEADER_GENERAL_TEXTS = {
+ sampleSize: 5,
+ noHelpDescription: "No help description available",
+ noMailProvided: "No mail provided for comments",
+};
-export const HEADER_BUTTONS_TEXTS = {
+const HEADER_BUTTONS_TEXTS = {
attributes: "Display Attributes",
data: "Display Data Sample",
help: "Help!",
mail: "Leave us a comment",
download: "Download Full Data",
};
-export const HEADER_DIALOGS_TITLES = {
+
+const HEADER_DIALOGS_TITLES = {
attributes: "Details of Attributes",
data: "Sample of Data",
help: "Help!",
mail: "Leave us a comment",
};
+
+export const HEADER_TEXTS = {
+ buttons: HEADER_BUTTONS_TEXTS,
+ dialogs: HEADER_DIALOGS_TITLES,
+ general: HEADER_GENERAL_TEXTS,
+};
+
+export const colorCodes = {
+ blue: {
+ dark: "primary.main",
+ light: "primary.light",
+ },
+ green: {
+ dark: "#006400",
+ light: "#90EE90",
+ },
+ red: {
+ dark: "#800000",
+ light: "#FFB6C1",
+ },
+ yellow: {
+ dark: "#FFD700",
+ light: "#FFFFE0",
+ },
+ purple: {
+ dark: "secondary.main",
+ light: "secondary.light",
+ },
+ orange: {
+ dark: "#FF8C00",
+ light: "#FFA500",
+ },
+ black: {
+ dark: "#000000",
+ light: "#696969",
+ },
+ white: {
+ dark: "#D3D3D3",
+ light: "#FFFFFF",
+ },
+};
diff --git a/src/app/general/resources.ts b/src/app/general/resources.ts
index 4d9c463..9324c3b 100644
--- a/src/app/general/resources.ts
+++ b/src/app/general/resources.ts
@@ -1,7 +1,7 @@
import { Message, MessageSection, Bot } from "@/app/general/interfaces";
-import { Sender, TypeOfQuestion } from "@/app/general/types";
+import { Sender, TypeOfQuestion, DataType } from "@/app/general/types";
import { convertTextToMessage } from "@/app/general/utils";
-import { NO_RESULTS_FOUND } from "@/app/general/constants";
+import { RESOURCES_TEXTS } from "@/app/general/constants";
export const botMessages = (bot: Bot): Message[] => {
const headers = bot?._data.headers || [];
@@ -28,7 +28,7 @@ export const botMessages = (bot: Bot): Message[] => {
${headersString}
-Which property would you like to start with?`,
+${RESOURCES_TEXTS.propertyMessage}`,
sender: Sender.BOT,
typeOfQuestion: TypeOfQuestion.PARAMETER,
answerOptions: Array.from(
@@ -101,17 +101,32 @@ export const botFunctionParamsMessages = (
bot: Bot,
currentParam: string
): Message[] => {
- const operators = bot?._data.columns.filter(
+ const column = bot?._data.columns.filter(
(col) => col._id === currentParam
- )[0]?.operatorsArray;
+ )[0];
+ const operators = column?.operatorsArray;
+ const columnType = column?.dataType;
+ const rows = column?.rows;
const chosenOperator = operators[bot.currentOperatorIndex];
const params = chosenOperator.params;
+ const isFactor = columnType === DataType.FACTOR;
+ const factorOptions = Array.from(new Set(rows));
+ const factorOptionsMessage = `${
+ RESOURCES_TEXTS.factorOptions
+ } ${factorOptions?.join(", ")}`;
+ const extraMessage = isFactor ? factorOptionsMessage : "";
+
const messages: Message[] = params.map((prm, index) => {
return {
id: index,
- text: prm?.message ?? `Enter value for parameter ${prm?.name}:`,
+ text:
+ (prm?.message ??
+ `${RESOURCES_TEXTS.paramMessageDefault} ${prm?.name}`) +
+ "\n" +
+ "\n" +
+ extraMessage,
sender: Sender.BOT,
typeOfQuestion: TypeOfQuestion.FUNCTION_PARAMS,
};
@@ -138,10 +153,10 @@ export const botFunctionParamsMessages = (
export const botAddMessages: Message[] = [
{
id: 0,
- text: `Do you want to add another parameter?
+ text: `${RESOURCES_TEXTS.addParameter}
- 1. Yes
- 2. No`,
+ ${RESOURCES_TEXTS.yesOption}
+ ${RESOURCES_TEXTS.noOption}`,
sender: Sender.BOT,
typeOfQuestion: TypeOfQuestion.ADD,
answerOptions: [1, 2],
@@ -162,7 +177,7 @@ export const botRestartMessages = (bot: Bot): Message[] => {
...restartSlotArray,
{
id: 0,
- text: `To add another parameter, I will go through the same process as before.
+ text: `${RESOURCES_TEXTS.restartMessage}
${bot?._messages.customMessages.continueMessage}`,
sender: Sender.BOT,
@@ -188,7 +203,7 @@ export const resultMsg = (bot: Bot, foundResults: boolean): Message[] => {
id: 0,
text: foundResults
? bot?._messages?.customMessages.resultMessage
- : NO_RESULTS_FOUND,
+ : RESOURCES_TEXTS.noResultsFound,
sender: Sender.BOT,
typeOfQuestion: TypeOfQuestion.RESULT,
},
@@ -204,42 +219,7 @@ export const defaultMsgSection = [
export const emptyMessage: Message = {
id: 0,
- text: "empty message",
+ text: RESOURCES_TEXTS.emptyMessage,
sender: Sender.BOT,
typeOfQuestion: TypeOfQuestion.FUNCTION_PARAMS,
};
-
-export const colorCodes = {
- blue: {
- dark: "primary.main",
- light: "primary.light",
- },
- green: {
- dark: "#006400",
- light: "#90EE90",
- },
- red: {
- dark: "#800000",
- light: "#FFB6C1",
- },
- yellow: {
- dark: "#FFD700",
- light: "#FFFFE0",
- },
- purple: {
- dark: "secondary.main",
- light: "secondary.light",
- },
- orange: {
- dark: "#FF8C00",
- light: "#FFA500",
- },
- black: {
- dark: "#000000",
- light: "#696969",
- },
- white: {
- dark: "#D3D3D3",
- light: "#FFFFFF",
- },
-};