Skip to content

Commit ece98ac

Browse files
Merge pull request #37 from GoldenLabHuji:ShlomiShitrit/issue35
Issue35: add mail button
2 parents 07da370 + a8ab857 commit ece98ac

File tree

3 files changed

+46
-17
lines changed

3 files changed

+46
-17
lines changed

package-lock.json

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/components/Header/Header.tsx

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22
import { useState } from "react";
33
import { styles } from "./Header.style";
4-
import { Box, Typography } from "@mui/material";
4+
import { Box, Typography, Link } from "@mui/material";
55
import Table from "@/app/components/Table";
66
import Dialog from "@/app/components/Dialog";
77
import CustomButton from "@/app/components/CustomButton";
@@ -13,18 +13,21 @@ import {
1313
import { strOrNum } from "@/app/general/types";
1414
import {
1515
SAMPLE_SIZE,
16-
ATTRIBUTES_BUTTON_TEXT,
17-
SAMPLE_BUTTON_TEXT,
16+
HEADER_BUTTONS_TEXTS,
1817
NO_HELP_DESCRIPTION,
18+
NO_MAIL_PROVIDED,
19+
HEADER_DIALOGS_TITLES,
1920
} from "@/app/general/constants";
2021
import { getTableInfo } from "@/app/general/utils";
2122

2223
export default function Header({ bot }: HeaderProps) {
2324
const [openAttribute, setOpenAttribute] = useState<boolean>(false);
2425
const [openData, setOpenData] = useState<boolean>(false);
2526
const [openHelp, setOpenHelp] = useState<boolean>(false);
27+
const [openMail, setOpenMail] = useState<boolean>(false);
2628

2729
const helpDescription = bot?._details.helpDescription;
30+
const mailInfo = bot?._details.mailInfo;
2831
const { botHeaders, botColumns, rows } = getTableInfo(bot);
2932
const sampleRows = rows.slice(0, SAMPLE_SIZE);
3033

@@ -34,16 +37,20 @@ export default function Header({ bot }: HeaderProps) {
3437
}));
3538

3639
const buttons = [
37-
{ onClick: () => setOpenAttribute(true), text: ATTRIBUTES_BUTTON_TEXT },
38-
{ onClick: () => setOpenData(true), text: SAMPLE_BUTTON_TEXT },
39-
{ onClick: () => setOpenHelp(true), text: "Help!" },
40+
{
41+
onClick: () => setOpenAttribute(true),
42+
text: HEADER_BUTTONS_TEXTS.attributes,
43+
},
44+
{ onClick: () => setOpenData(true), text: HEADER_BUTTONS_TEXTS.data },
45+
{ onClick: () => setOpenHelp(true), text: HEADER_BUTTONS_TEXTS.help },
46+
{ onClick: () => setOpenMail(true), text: HEADER_BUTTONS_TEXTS.mail },
4047
];
4148

4249
const dialogs = [
4350
{
4451
open: openAttribute,
4552
setOpen: setOpenAttribute,
46-
title: "Details of Attributes",
53+
title: HEADER_DIALOGS_TITLES.attributes,
4754
children: (
4855
<Table<NameAndDescription>
4956
headers={["name", "description"]}
@@ -54,7 +61,7 @@ export default function Header({ bot }: HeaderProps) {
5461
{
5562
open: openData,
5663
setOpen: setOpenData,
57-
title: "Sample of Data",
64+
title: HEADER_DIALOGS_TITLES.data,
5865
children: (
5966
<Table<generalObject<strOrNum>>
6067
headers={botHeaders}
@@ -65,9 +72,19 @@ export default function Header({ bot }: HeaderProps) {
6572
{
6673
open: openHelp,
6774
setOpen: setOpenHelp,
68-
title: "Help!",
75+
title: HEADER_DIALOGS_TITLES.help,
6976
content: helpDescription ?? NO_HELP_DESCRIPTION,
7077
},
78+
{
79+
open: openMail,
80+
setOpen: setOpenMail,
81+
title: HEADER_DIALOGS_TITLES.mail,
82+
children: (
83+
<Link href={`mailto:${mailInfo}`}>
84+
{mailInfo ?? NO_MAIL_PROVIDED}
85+
</Link>
86+
),
87+
},
7188
];
7289

7390
return (

src/app/general/constants.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
export const NO_RESULTS_FOUND = "No results found";
22
export const SAMPLE_SIZE = 5;
3-
export const ATTRIBUTES_BUTTON_TEXT = "Display Attributes";
4-
export const SAMPLE_BUTTON_TEXT = "Display Data Sample";
53
export const NO_HELP_DESCRIPTION = "No help description available";
4+
export const NO_MAIL_PROVIDED = "No mail provided for comments";
65
export const DOWNLOAD_RESULTS = "Download Results";
76
export const SEND = "Send";
7+
8+
export const HEADER_BUTTONS_TEXTS = {
9+
attributes: "Display Attributes",
10+
data: "Display Data Sample",
11+
help: "Help!",
12+
mail: "Leave us a comment",
13+
};
14+
export const HEADER_DIALOGS_TITLES = {
15+
attributes: "Details of Attributes",
16+
data: "Sample of Data",
17+
help: "Help!",
18+
mail: "Leave us a comment",
19+
};
20+

0 commit comments

Comments
 (0)