Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
- changed auth route from pages to app directory

Small change in Header and CommandComponent
- moved user name and email from header to UserAvatar

Invoices
- started invoice detail view
  • Loading branch information
pdovhomilja committed Sep 24, 2023
1 parent 61b3ab0 commit ce7d4f9
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 211 deletions.
2 changes: 1 addition & 1 deletion app/[locale]/(auth)/sign-in/components/LoginComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function LoginComponent() {
});
}
if (status?.ok) {
console.log("Status OK");
// console.log("Status OK");
toast({
description: "Login successful.",
});
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/(routes)/components/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Feedback = () => {
const [open, setOpen] = useState(false);
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<PopoverTrigger asChild className="hidden sm:flex">
<Button variant={"secondary"} onClick={() => setOpen(false)}>
<ChatBubbleIcon className="w-4 h-4 mr-2" />
Feedback
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/(routes)/components/FulltextSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const FulltextSearch = () => {
onChange={(e) => setSearch(e.target.value)}
/>
<Button type="submit" className="gap-2" onClick={handleSearch}>
<span className="hidden md:flex">Search</span>
<span className="hidden sm:flex">Search</span>
<SearchIcon />
</Button>
</div>
Expand Down
24 changes: 11 additions & 13 deletions app/[locale]/(routes)/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { CommandComponent } from "@/components/CommandComponent";
import Feedback from "./Feedback";
import FulltextSearch from "./FulltextSearch";
import AvatarDropdown from "./ui/AvatarDropdown";

import { ThemeToggle } from "@/components/ThemeToggle";
import { Separator } from "@/components/ui/separator";

import { SetLanguage } from "@/components/SetLanguage";
import FulltextSearch from "./FulltextSearch";
import Link from "next/link";
import { GithubIcon } from "lucide-react";
import Feedback from "./Feedback";
import { ThemeToggle } from "@/components/ThemeToggle";
import { CommandComponent } from "@/components/CommandComponent";

type Props = {
id: string;
Expand All @@ -30,12 +27,13 @@ const Header = ({ id, name, email, avatar, lang }: Props) => {
<SetLanguage userId={id} />
<Feedback />
<ThemeToggle />
<div className="hidden lg:flex flex-col text-xs text-gray-500">
<div>{name}</div>
<div>{email}</div>
<div>Language: {lang}</div>
</div>
<AvatarDropdown avatar={avatar} userId={id} />
<div className="hidden lg:flex flex-col text-xs text-gray-500"></div>
<AvatarDropdown
avatar={avatar}
userId={id}
name={name}
email={email}
/>
</div>
</div>
<Separator />
Expand Down
41 changes: 26 additions & 15 deletions app/[locale]/(routes)/components/ui/AvatarDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";

import React from "react";
import { Avatar, AvatarImage } from "@/components/ui/avatar";
import {
Expand All @@ -9,16 +10,21 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { signOut, useSession } from "next-auth/react";
import { signOut } from "next-auth/react";
import Link from "next/link";
import { Settings } from "lucide-react";
import { LogOut, Settings } from "lucide-react";
import { useRouter } from "next/navigation";

type Props = {
avatar: string;
userId: string;
name: string;
email: string;
};

const AvatarDropdown = ({ avatar, userId }: Props) => {
const AvatarDropdown = ({ avatar, userId, name, email }: Props) => {
const router = useRouter();

return (
<DropdownMenu>
<DropdownMenuTrigger>
Expand All @@ -33,24 +39,29 @@ const AvatarDropdown = ({ avatar, userId }: Props) => {
</Avatar>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuLabel className="space-y-1">
<div>{name}</div>
<div className="text-xs text-gray-500">{email}</div>
</DropdownMenuLabel>

<DropdownMenuSeparator />
<DropdownMenuItem asChild>
<Link href={`/projects/dashboard`}>Todo dashboard</Link>
<DropdownMenuItem onClick={() => router.push("/projects/dashboard")}>
Todo dashboard
</DropdownMenuItem>
<DropdownMenuItem asChild>
<Link href={`/crm/dashboard/${userId}`}>CRM dashboard</Link>
<DropdownMenuItem
onClick={() => router.push(`/crm/dashboard/${userId}`)}
>
Sales dashboard
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem asChild>
<Link href="/profile">
<Settings className="w-4 h-4 inline-block mr-2 stroke-current text-gray-500" />
Profile
</Link>
<DropdownMenuItem onClick={() => router.push("/profile")}>
<Settings className="w-4 h-4 inline-block mr-2 stroke-current text-gray-500" />
<span>Profile settings</span>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>
<div onClick={() => signOut()}>Sign out</div>
<DropdownMenuItem onClick={() => signOut()}>
<LogOut className="w-4 h-4 inline-block mr-2 stroke-current text-gray-500" />
<span>Sign out</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
Expand Down
21 changes: 20 additions & 1 deletion app/[locale]/(routes)/invoice/detail/[invoiceId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import Container from "../../../components/ui/Container";
import { getInvoice } from "@/actions/invoice/get-invoice";
import { MessageCircle, MessagesSquare } from "lucide-react";
import InvoiceChat from "../_dialogs/InvoiceChat";

interface InvoiceDetailProps {
params: { invoiceId: string };
Expand All @@ -12,7 +14,24 @@ const InvoiceDetailPage = async ({ params }: InvoiceDetailProps) => {

return (
<Container title={`Invoice ${invoiceId}`} description="Invoice detail page">
<pre>{JSON.stringify(invoiceData, null, 2)}</pre>
<div className="flex">
<div className="w-1/2">
<embed
style={{
width: "100%",
height: "100%",
}}
type="application/pdf"
src={invoiceData.invoice_file_url}
/>
</div>
<div className="py-2">
<InvoiceChat />
</div>
<div className="w-1/2">
<pre>{JSON.stringify(invoiceData, null, 2)}</pre>
</div>
</div>
</Container>
);
};
Expand Down
29 changes: 29 additions & 0 deletions app/[locale]/(routes)/invoice/detail/_dialogs/InvoiceChat.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use client";

import { MessagesSquare } from "lucide-react";

import {
Sheet,
SheetContent,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@/components/ui/sheet";

const InvoiceChat = () => {
return (
<Sheet>
<SheetTrigger asChild>
<MessagesSquare className="w-6 h-6 m-2 cursor-pointer" />
</SheetTrigger>
<SheetContent>
<SheetHeader>
<SheetTitle>Invoice conversation</SheetTitle>
</SheetHeader>
content here - in progress
</SheetContent>
</Sheet>
);
};

export default InvoiceChat;
7 changes: 7 additions & 0 deletions app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import NextAuth from "next-auth";

import { authOptions } from "@/lib/auth";

const handler = NextAuth(authOptions);

export { handler as GET, handler as POST };
16 changes: 13 additions & 3 deletions components/CommandComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ export function CommandComponent() {
if (e.key === "Escape") {
setOpen(false);
}
if (e.key === "p" && e.metaKey) {
if (e.key === "D" && e.metaKey && e.shiftKey) {
router.push("/");
setOpen(false);
}
if (e.key === "P" && e.metaKey && e.shiftKey) {
router.push("/profile");
setOpen(false);
}
if (e.key === "k" && e.metaKey) {
signOut();
Expand All @@ -47,7 +52,7 @@ export function CommandComponent() {

document.addEventListener("keydown", down);
return () => document.removeEventListener("keydown", down);
}, []);
}, [router]);

return (
<div className="hidden lg:block">
Expand Down Expand Up @@ -77,10 +82,15 @@ export function CommandComponent() {
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Settings">
<CommandItem onClick={() => redirect("/")}>
<User className="mr-2 h-4 w-4" />
<span>Dashboard</span>
<CommandShortcut>Shift + ⌘ + D</CommandShortcut>
</CommandItem>
<CommandItem onClick={() => redirect("/profile")}>
<User className="mr-2 h-4 w-4" />
<span>Profile</span>
<CommandShortcut>P</CommandShortcut>
<CommandShortcut>Shift + ⌘ + P</CommandShortcut>
</CommandItem>
<CommandItem>
<CreditCard className="mr-2 h-4 w-4" />
Expand Down
5 changes: 0 additions & 5 deletions pages/api/auth/[...nextauth].ts

This file was deleted.

20 changes: 0 additions & 20 deletions pages/api/cron/demo.ts

This file was deleted.

Loading

6 comments on commit ce7d4f9

@vercel
Copy link

@vercel vercel bot commented on ce7d4f9 Sep 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextcrm-others – ./

nextcrm-others-git-main-e-osvc.vercel.app
nextcrm-others-e-osvc.vercel.app
others.nextcrm.io

@vercel
Copy link

@vercel vercel bot commented on ce7d4f9 Sep 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on ce7d4f9 Sep 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextcrm-test – ./

nextcrm-test-git-main-e-osvc.vercel.app
nextcrm-test-e-osvc.vercel.app
test.nextcrm.io

@vercel
Copy link

@vercel vercel bot commented on ce7d4f9 Sep 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on ce7d4f9 Sep 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on ce7d4f9 Sep 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextcrm-demo – ./

nextcrm-demo-e-osvc.vercel.app
demo.nextcrm.io
nextcrm-demo-git-main-e-osvc.vercel.app

Please sign in to comment.