diff --git a/client/src/components/generic/ProfileInformationPanel/ProfileInformationPanel.story.tsx b/client/src/components/generic/ProfileInformationPanel/ProfileInformationPanel.story.tsx new file mode 100644 index 000000000..7c1904f8c --- /dev/null +++ b/client/src/components/generic/ProfileInformationPanel/ProfileInformationPanel.story.tsx @@ -0,0 +1,115 @@ +import type { Meta, StoryObj } from "@storybook/react" + +import ProfileInformationPanel from "./ProfileInformationPanel" + +const meta: Meta = { + component: ProfileInformationPanel +} +export default meta +type Story = StoryObj + +interface TestElements { + subtitle: string + description: string +} + +const ChildMapper = (children: Array) => { + return children.map((child) => ( + <> +
+

+ {child.subtitle} +

+

+ {child.description} +

+
+ + )) +} + +const firstStoryElements: Array = [ + { + subtitle: "Dietary requirements", + description: "Allergic to nuts" + }, + { + subtitle: "Skiier/Snowboarder", + description: "Both" + } +] + +const secondStoryElements = [ + { + subtitle: "Name", + description: "John Doe" + }, + { + subtitle: "Gender", + description: "Male" + }, + { + subtitle: "Student ID", + description: "910867209" + }, + { + subtitle: "Date of birth", + description: "23/06/2003" + }, + { + subtitle: "Email", + description: "email@domain.com" + }, + { + subtitle: "Phone number", + description: "021 123 1234" + }, + { + subtitle: "Emergency contact info", + description: "Jason, Father, 021 432, 4321" + } +] + +const thirdStoryElements = [ + { + subtitle: "Membership type", + description: "UoA Student" + }, + { + subtitle: "Valid till", + description: "9/12/24" + } +] + +export const littleElementsWithEdit = () => { + return ( + <> + { + alert("Additional details button clicked") + }} + > + {ChildMapper(firstStoryElements)} + + + ) +} + +export const ManyElementsWithEdit: Story = { + args: { + title: "Personal Details", + onEdit: () => { + alert("Personal details edit button") + }, + children: ChildMapper(secondStoryElements) + } +} + +export const elementsWithoutEdit = () => { + return ( + + {ChildMapper(thirdStoryElements)} + + ) +} diff --git a/client/src/components/generic/ProfileInformationPanel/ProfileInformationPanel.tsx b/client/src/components/generic/ProfileInformationPanel/ProfileInformationPanel.tsx new file mode 100644 index 000000000..61fc7d4b2 --- /dev/null +++ b/client/src/components/generic/ProfileInformationPanel/ProfileInformationPanel.tsx @@ -0,0 +1,35 @@ +import { ReactNode } from "react" +import EditIcon from "assets/icons/edit.svg?react" +interface IProfileInformationPanel { + title: string // The title field + children?: ReactNode + onEdit?: () => void // The edit button +} + +const ProfileInformationPanel = ({ + title, + children, + onEdit +}: IProfileInformationPanel) => { + return ( +
+
+

{title}

+ {onEdit && ( +
+ +
+ )} +
+ +
+ {children} +
+
+ ) +} + +export default ProfileInformationPanel