Skip to content

Commit

Permalink
Merge pull request #45 from josch87/feature/gunther32-upcoming-events
Browse files Browse the repository at this point in the history
Feature/gunther32 upcoming events
  • Loading branch information
josch87 authored Dec 2, 2023
2 parents d5e9ed8 + 1475f6d commit 078e5e5
Show file tree
Hide file tree
Showing 27 changed files with 452 additions and 49 deletions.
3 changes: 3 additions & 0 deletions assets/Icons8.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/ActionMenu/ActionMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function ActionMenu() {
icon: materialContact,
iconAlt: "Contact icon",
title: "New contact",
url: "/new",
url: "/contacts/new",
},
{
icon: materialMeeting,
Expand Down
2 changes: 1 addition & 1 deletion components/ContactListItem/ContactListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { materialImage } from "@/assets/Icons8";
export default function ContactListItem({ contact }) {
return (
<ListItem>
<StyledLink href={`/${contact.id}`} title="Show contact details">
<StyledLink href={`/contacts/${contact.id}`} title="Show contact details">
{contact.profilePicture ? (
<ProfileImage
src={getProfilePicture(contact)}
Expand Down
2 changes: 1 addition & 1 deletion components/CreateDataInvitation/CreateDataInvitation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function CreateDataInvitation({
<Image src={materialWarning} width={25} height={25} alt="Warning" />
You need to have at least one contact in order to create interactions.
</StyledParagraph>
<Button buttonType="primary" href="/">
<Button buttonType="primary" href="/contacts">
Switch to contacts
</Button>
</>
Expand Down
21 changes: 21 additions & 0 deletions components/DashboardWidgets/UpcomingWidget/UpcomingWidget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import InteractionListItem from "@/components/InteractionListItem/InteractionListItem";
import Scopebox from "@/components/Scopebox/Scopebox";
import { StyledUnorderedList } from "./UpcomingWidget.styled";

export default function UpcomingWidget({ interactions, contacts }) {
return (
<Scopebox heading="Upcoming">
<StyledUnorderedList>
{interactions.map((interaction) => {
return (
<InteractionListItem
key={interaction.id}
interaction={interaction}
contacts={contacts}
/>
);
})}
</StyledUnorderedList>
</Scopebox>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import styled from "styled-components";

export const StyledUnorderedList = styled.ul`
display: flex;
flex-direction: column;
gap: 5px;
`;
36 changes: 36 additions & 0 deletions components/DashboardWidgets/UpcomingWidget/UpcomingWidget.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
contactsTestData,
interactionsTestData,
threeFutureInteractionsTestData,
} from "@/data/TestData";
import UpcomingWidget from "./UpcomingWidget";
import { render, screen } from "@testing-library/react";

test("renders the heading 'Upcoming'", () => {
render(
<UpcomingWidget
interactions={interactionsTestData}
contacts={contactsTestData}
/>
);

const heading = screen.getByRole("heading", {
level: 2,
name: "Upcoming",
});

expect(heading).toBeInTheDocument();
});

test("renders three upcoming interactions", () => {
render(
<UpcomingWidget
interactions={threeFutureInteractionsTestData}
contacts={contactsTestData}
/>
);

const interactionItems = screen.getAllByRole("listitem");

expect(interactionItems).toHaveLength(3);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { StyledLink, StyledParagraph } from "./WelcomeMessageWidget.styled";

export default function WelcomeMessageWidget() {
return (
<StyledParagraph>
Welcome to Gunther - your Personal Relationship Management app. Manage
your <StyledLink href="/contacts">contacts</StyledLink> and social{" "}
<StyledLink href="/interactions">interactions</StyledLink> and cultivate a
fulfilling network!
</StyledParagraph>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Link from "next/link";
import styled from "styled-components";

export const StyledParagraph = styled.p`
line-height: 1.5rem;
`;

export const StyledLink = styled(Link)`
color: var(--primary-text-color);
text-decoration-color: var(--primary-color);
text-underline-offset: 2px;
&:active {
background-color: var(--primary-color);
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function InteractionDetailsSection({ interaction, contacts }) {
(sortedParticipant) => (
<ParticipantLink
key={sortedParticipant.id}
href={`/${sortedParticipant.id}`}
href={`/contacts/${sortedParticipant.id}`}
title="Show contact details"
>
{getFullName(sortedParticipant)}
Expand Down
5 changes: 3 additions & 2 deletions components/InteractionList/InteractionList.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import InteractionListItem from "../InteractionListItem/InteractionListItem";
import { StyledUnorderedList } from "./InteractionList.styled";

export default function InteractionList({ interactions, contacts }) {
return (
<ul>
<StyledUnorderedList>
{interactions.map((interaction) => {
return (
<InteractionListItem
Expand All @@ -12,6 +13,6 @@ export default function InteractionList({ interactions, contacts }) {
/>
);
})}
</ul>
</StyledUnorderedList>
);
}
7 changes: 7 additions & 0 deletions components/InteractionList/InteractionList.styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import styled from "styled-components";

export const StyledUnorderedList = styled.ul`
display: flex;
flex-direction: column;
gap: 10px;
`;
2 changes: 0 additions & 2 deletions components/InteractionListItem/InteractionListItem.styled.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Image from "next/image";
import Link from "next/link";
import styled from "styled-components";

export const ListItem = styled.li`
margin-bottom: 10px;
list-style: none;
`;

Expand Down
16 changes: 13 additions & 3 deletions components/MobileNavigation/MobileNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import {
UnorderedList,
} from "./MobileNavigation.styled";
import Image from "next/image";
import { materialContact, materialMeeting } from "@/assets/Icons8";
import {
materialContact,
materialHome,
materialMeeting,
} from "@/assets/Icons8";
import { useRouter } from "next/router";
import { Tooltip } from "react-tooltip";

Expand All @@ -14,12 +18,18 @@ export default function MobileNavigation() {
const linksData = [
{
id: 1,
title: "Contacts",
title: "Dashboard",
href: "/",
icon: materialContact,
icon: materialHome,
},
{
id: 2,
title: "Contacts",
href: "/contacts",
icon: materialContact,
},
{
id: 3,
title: "Interactions",
href: "/interactions",
icon: materialMeeting,
Expand Down
11 changes: 8 additions & 3 deletions components/Scopebox/Scopebox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { StyledScopebox } from "./Scopebox.styled";
import { StyledHeading, StyledScopebox } from "./Scopebox.styled";

export default function Scopebox({ children }) {
return <StyledScopebox>{children}</StyledScopebox>;
export default function Scopebox({ children, heading }) {
return (
<>
{heading ? <StyledHeading>{heading}</StyledHeading> : null}
<StyledScopebox>{children}</StyledScopebox>
</>
);
}
5 changes: 5 additions & 0 deletions components/Scopebox/Scopebox.styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ export const StyledScopebox = styled.article`
margin-top: 10px;
background-color: #ffffff;
`;

export const StyledHeading = styled.h2`
font-size: 1rem;
margin-bottom: -5px;
`;
132 changes: 132 additions & 0 deletions data/TestData.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,135 @@ export const contactsTestData = [
isSampleData: true,
},
];

export const interactionsTestData = [
{
id: "1",
type: "Call",
dateOfInteraction: "2012-11-03T00:00:00.000+00:00",
participants: [],
notes:
"I was calling coz' I forgot about his birthday and apologised. After a while, he was fine with it and invited me to his party next Friday. I said that I'm pretty busy right now but I'll try to make it ...",
dateCreated: "2023-07-06T16:54:11.000+00:00",
dateDeleted: "",
isSampleData: true,
},
{
id: "2",
type: "Call",
dateOfInteraction: "2038-11-07T18:30:00.000+00:00",
participants: [],
notes:
"I called my best friend to catch up. We talked about our recent experiences, shared funny stories, and reminisced about old times. It was a long and enjoyable conversation.",
dateCreated: "2038-11-07T18:30:00.000+00:00",
dateDeleted: "2023-11-25T16:23:30.742Z",
isSampleData: true,
},
{
id: "3",
type: "Video conference",
dateOfInteraction: "2038-11-10T19:00:00.000+00:00",
participants: [],
notes:
"We had a family video conference to celebrate my sister's graduation. We couldn't all be physically present, so we decided to have a virtual gathering. We congratulated her, shared our pride, and virtually toasted to her success.",
dateCreated: "2038-11-10T19:00:00.000+00:00",
dateDeleted: "",
isSampleData: true,
},
{
id: "4",
type: "Homecoming Event",
dateOfInteraction: "2038-11-09T20:00:00.000+00:00",
participants: [],

notes:
"My cousin called to invite me to her wedding. We talked about the ceremony details, the venue, and the guest list. I congratulated her and promised to attend the wedding.",
dateCreated: "2038-11-09T20:00:00.000+00:00",
dateDeleted: "",
isSampleData: true,
},
{
id: "5",
type: "Party",
dateOfInteraction: "2038-11-01T20:00:00.000+00:00",
participants: [],

notes:
"My cousin called to invite me to her wedding. We talked about the ceremony details, the venue, and the guest list. I congratulated her and promised to attend the wedding.",
dateCreated: "2038-11-09T20:00:00.000+00:00",
dateDeleted: "",
isSampleData: true,
},
];

export const pastInteractionsTestData = [
{
id: "1",
type: "Call",
dateOfInteraction: "2018-11-03",
participants: [],
notes:
"I was calling coz' I forgot about his birthday and apologised. After a while, he was fine with it and invited me to his party next Friday. I said that I'm pretty busy right now but I'll try to make it ...",
dateCreated: "2023-07-06T16:54:11.000+00:00",
dateDeleted: "",
isSampleData: true,
},
{
id: "2",
type: "Call",
dateOfInteraction: "2005-07-12",
participants: [],
notes:
"I called my best friend to catch up. We talked about our recent experiences, shared funny stories, and reminisced about old times. It was a long and enjoyable conversation.",
dateCreated: "2038-11-07T18:30:00.000+00:00",
dateDeleted: "",
isSampleData: true,
},
{
id: "3",
type: "Video conference",
dateOfInteraction: "1995-06-01",
participants: [],
notes:
"We had a family video conference to celebrate my sister's graduation. We couldn't all be physically present, so we decided to have a virtual gathering. We congratulated her, shared our pride, and virtually toasted to her success.",
dateCreated: "2038-11-10T19:00:00.000+00:00",
dateDeleted: "",
isSampleData: true,
},
];

export const threeFutureInteractionsTestData = [
{
id: "1",
type: "Call",
dateOfInteraction: "2089-11-03",
participants: [],
notes:
"I was calling coz' I forgot about his birthday and apologised. After a while, he was fine with it and invited me to his party next Friday. I said that I'm pretty busy right now but I'll try to make it ...",
dateCreated: "2023-07-06T16:54:11.000+00:00",
dateDeleted: "",
isSampleData: true,
},
{
id: "2",
type: "Call",
dateOfInteraction: "2070-07-12",
participants: [],
notes:
"I called my best friend to catch up. We talked about our recent experiences, shared funny stories, and reminisced about old times. It was a long and enjoyable conversation.",
dateCreated: "2038-11-07T18:30:00.000+00:00",
dateDeleted: "",
isSampleData: true,
},
{
id: "3",
type: "Video conference",
dateOfInteraction: "2098-06-01",
participants: [],
notes:
"We had a family video conference to celebrate my sister's graduation. We couldn't all be physically present, so we decided to have a virtual gathering. We congratulated her, shared our pride, and virtually toasted to her success.",
dateCreated: "2038-11-10T19:00:00.000+00:00",
dateDeleted: "",
isSampleData: true,
},
];
4 changes: 2 additions & 2 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default function App({ Component, pageProps }) {
}
})
);
router.push(`/${updatedContact.id}`);
router.push(`/contacts/${updatedContact.id}`);

toast.success("Contact updated", {
progress: undefined,
Expand All @@ -136,7 +136,7 @@ export default function App({ Component, pageProps }) {
})
);

router.push("/");
router.push("/contacts");

toast.success("Contact deleted", {
progress: undefined,
Expand Down
File renamed without changes.
Loading

0 comments on commit 078e5e5

Please sign in to comment.