Skip to content

Commit

Permalink
Merge pull request #89 from Codehagen/88-feature-add-timeline-for-user
Browse files Browse the repository at this point in the history
Timeline MVP
  • Loading branch information
Codehagen authored Aug 22, 2024
2 parents aa61b54 + 8b233ae commit 23a824f
Show file tree
Hide file tree
Showing 27 changed files with 551 additions and 285 deletions.
6 changes: 3 additions & 3 deletions apps/www/src/app/(marketing)/error.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
"use client"

import { Button } from "@dingify/ui/components/button";
import { Button } from "@propdock/ui/components/button"

export default function Error({ reset }: { reset: () => void }) {
return (
Expand All @@ -10,5 +10,5 @@ export default function Error({ reset }: { reset: () => void }) {
Try again
</Button>
</div>
);
)
}
5 changes: 5 additions & 0 deletions apps/www/src/app/(tenant)/tenant/[id]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export default async function DashboardLayout({
href: `/tenant/${params.id}/contactperson`,
icon: "user",
},
{
title: "Tidslinje",
href: `/tenant/${params.id}/timeline`,
icon: "calendarClock",
},
{
title: "Økonomi",
href: `/tenant/${params.id}/finance`,
Expand Down
63 changes: 63 additions & 0 deletions apps/www/src/app/(tenant)/tenant/[id]/timeline/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { getTenantDetails } from "@/actions/get-tenant-details"
import { getServerSession } from "next-auth/next"

import { authOptions } from "@/lib/auth"
import { prisma } from "@/lib/db"
import { DashboardHeader } from "@/components/dashboard/header"
import { DashboardShell } from "@/components/dashboard/shell"
import CustomerTimeline from "@/components/tenant/CustomerTimeline"

export default async function TimelinePage({
params,
}: {
params: { id: string }
}) {
const tenantId = params.id

if (!tenantId) {
return (
<DashboardShell>
<DashboardHeader heading="Tenant not found" text="Invalid tenant ID." />
</DashboardShell>
)
}

const session = await getServerSession(authOptions)

const user = await prisma.user.findUnique({
where: { id: session?.user.id },
select: { workspaceId: true },
})

try {
const tenantDetails = await getTenantDetails(tenantId)

if (!tenantDetails) {
return (
<DashboardShell>
<DashboardHeader
heading="Tenant not found"
text="Unable to retrieve tenant details."
/>
</DashboardShell>
)
}

return (
<DashboardShell>
<DashboardHeader
heading={`${tenantDetails.name} Tidslinje`}
text="Se kundeinteraksjoner og viktige hendelser."
/>
<CustomerTimeline />
</DashboardShell>
)
} catch (error) {
console.error("Error in TimelinePage:", error)
return (
<DashboardShell>
<DashboardHeader heading="Error" text={error.message} />
</DashboardShell>
)
}
}
29 changes: 14 additions & 15 deletions apps/www/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import "../styles/globals.css";
import "../styles/globals.css"

import { Metadata } from "next";
import { fontHeading, fontSans, fontUrban } from "@/assets/fonts";
import { Metadata } from "next"
import { fontHeading, fontSans, fontUrban } from "@/assets/fonts"
import { Toaster } from "@propdock/ui/components/sonner"

import { Toaster } from "@dingify/ui/components/sonner";

import { siteConfig } from "@/config/site";
import { cn } from "@/lib/utils";
import { Analytics } from "@/components/analytics";
import { ModalProvider } from "@/components/modal-provider";
import { Providers } from "@/components/providers";
import { TailwindIndicator } from "@/components/tailwind-indicator";
import { siteConfig } from "@/config/site"
import { cn } from "@/lib/utils"
import { Analytics } from "@/components/analytics"
import GlobalSearch from "@/components/command-window"
import { ModalProvider } from "@/components/modal-provider"
import { Providers } from "@/components/providers"
import { TailwindIndicator } from "@/components/tailwind-indicator"

interface RootLayoutProps {
children: React.ReactNode;
children: React.ReactNode
}

export const metadata = {
Expand Down Expand Up @@ -63,7 +62,7 @@ export const metadata = {
apple: "/apple-touch-icon.png",
},
manifest: `${siteConfig.url}/site.webmanifest`,
};
}

export default function RootLayout({ children }: RootLayoutProps) {
return (
Expand All @@ -84,8 +83,8 @@ export default function RootLayout({ children }: RootLayoutProps) {
<ModalProvider />
<TailwindIndicator />
</Providers>
<GlobalSearch/>
<GlobalSearch />
</body>
</html>
);
)
}
8 changes: 4 additions & 4 deletions apps/www/src/components/UserBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// components/shared/ClickableBadge.tsx
import { Badge } from "@dingify/ui/components/badge";
import { Badge } from "@propdock/ui/components/badge"

export function UserBadge({ customerId, userId, variant, onClick }) {
const handleClick = (e) => {
onClick(customerId);
};
onClick(customerId)
}

return (
<Badge
Expand All @@ -14,5 +14,5 @@ export function UserBadge({ customerId, userId, variant, onClick }) {
>
{userId}
</Badge>
);
)
}
4 changes: 2 additions & 2 deletions apps/www/src/components/analytics/CardSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
CardContent,
CardHeader,
CardTitle,
} from "@dingify/ui/components/card";
} from "@propdock/ui/components/card"

export default function CardSection(
{
Expand Down Expand Up @@ -107,5 +107,5 @@ export default function CardSection(
</CardContent>
</Card>
</div>
);
)
}
20 changes: 10 additions & 10 deletions apps/www/src/components/billing-info.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
"use client";
"use client"

import type { UserSubscriptionPlan } from "@/types";
import * as React from "react";
import Link from "next/link";
import { cn, formatDate } from "@/lib/utils";

import { buttonVariants } from "@dingify/ui/components/button";
import type { UserSubscriptionPlan } from "@/types"
import * as React from "react"
import Link from "next/link"
import { buttonVariants } from "@propdock/ui/components/button"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@dingify/ui/components/card";
} from "@propdock/ui/components/card"

import { cn, formatDate } from "@/lib/utils"

interface BillingInfoProps extends React.HTMLAttributes<HTMLFormElement> {
subscriptionPlan: UserSubscriptionPlan;
subscriptionPlan: UserSubscriptionPlan
}

export function BillingInfo({ subscriptionPlan }: BillingInfoProps) {
Expand Down Expand Up @@ -45,5 +45,5 @@ export function BillingInfo({ subscriptionPlan }: BillingInfoProps) {
) : null}
</CardFooter>
</Card>
);
)
}
15 changes: 7 additions & 8 deletions apps/www/src/components/buttons/AddContactPersonSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
import { useState } from "react"
import { createContactPerson } from "@/actions/create-contact-person"
import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { toast } from "sonner"
import { z } from "zod"

import { Button } from "@dingify/ui/components/button"
import { Button } from "@propdock/ui/components/button"
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@dingify/ui/components/form"
import { Input } from "@dingify/ui/components/input"
} from "@propdock/ui/components/form"
import { Input } from "@propdock/ui/components/input"
import {
Sheet,
SheetClose,
Expand All @@ -26,7 +22,10 @@ import {
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@dingify/ui/components/sheet"
} from "@propdock/ui/components/sheet"
import { useForm } from "react-hook-form"
import { toast } from "sonner"
import { z } from "zod"

// Define the validation schema
const ContactPersonSchema = z.object({
Expand Down
17 changes: 8 additions & 9 deletions apps/www/src/components/buttons/AddTenantSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,23 @@ import { createTenant } from "@/actions/create-tenant"
import { getBuildings } from "@/actions/get-buildings"
import { getProperties } from "@/actions/get-properties"
import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { toast } from "sonner"
import { z } from "zod"

import { Button } from "@dingify/ui/components/button"
import { Button } from "@propdock/ui/components/button"
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@dingify/ui/components/form"
import { Input } from "@dingify/ui/components/input"
} from "@propdock/ui/components/form"
import { Input } from "@propdock/ui/components/input"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@dingify/ui/components/select"
} from "@propdock/ui/components/select"
import {
Sheet,
SheetContent,
Expand All @@ -34,7 +30,10 @@ import {
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@dingify/ui/components/sheet"
} from "@propdock/ui/components/sheet"
import { useForm } from "react-hook-form"
import { toast } from "sonner"
import { z } from "zod"

const TenantSchema = z.object({
name: z.string().min(1, "Navn er påkrevd"),
Expand Down
51 changes: 25 additions & 26 deletions apps/www/src/components/channels/ChannelCard.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
"use client";
"use client"

import { useRouter } from "next/navigation";
import { deleteEvent } from "@/actions/Dingify/delete-event";
import {
ChevronDownIcon,
CircleIcon,
PlusIcon,
StarIcon,
} from "@radix-ui/react-icons";
import { format } from "date-fns";
import { BellIcon, BellOffIcon, Tag, TrashIcon } from "lucide-react";
import { toast } from "sonner";

import { Badge } from "@dingify/ui/components/badge";
import { Button } from "@dingify/ui/components/button";
import { useRouter } from "next/navigation"
import { deleteEvent } from "@/actions/Dingify/delete-event"
import { Badge } from "@propdock/ui/components/badge"
import { Button } from "@propdock/ui/components/button"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@dingify/ui/components/card";
} from "@propdock/ui/components/card"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@dingify/ui/components/dropdown-menu";
import { Separator } from "@dingify/ui/components/separator";
} from "@propdock/ui/components/dropdown-menu"
import { Separator } from "@propdock/ui/components/separator"
import {
ChevronDownIcon,
CircleIcon,
PlusIcon,
StarIcon,
} from "@radix-ui/react-icons"
import { format } from "date-fns"
import { BellIcon, BellOffIcon, Tag, TrashIcon } from "lucide-react"
import { toast } from "sonner"

export function ChannelCard({ channelDetails }) {
const router = useRouter();
const router = useRouter()

const handleDelete = async (eventId) => {
try {
await deleteEvent(eventId);
toast.success("The event has been deleted successfully.");
router.refresh();
await deleteEvent(eventId)
toast.success("The event has been deleted successfully.")
router.refresh()
} catch (error) {
toast.error("There was an error deleting the event.");
console.error("Error deleting event:", error);
toast.error("There was an error deleting the event.")
console.error("Error deleting event:", error)
}
};
}

return (
<div>
Expand Down Expand Up @@ -108,5 +107,5 @@ export function ChannelCard({ channelDetails }) {
</Card>
))}
</div>
);
)
}
3 changes: 1 addition & 2 deletions apps/www/src/components/command-window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import { useEffect, useState } from "react"
import Link from "next/link"

import {
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@dingify/ui/components/command"
} from "@propdock/ui/components/command"

export default function GlobalSearch() {
const [open, setOpen] = useState(false)
Expand Down
Loading

0 comments on commit 23a824f

Please sign in to comment.