Skip to content

Commit

Permalink
Update - Projects
Browse files Browse the repository at this point in the history
- added dueDateAt field in all create tasks dialogs

Update - CRM - Opportunites
- added budget value to data-table views
- updated tasks routes
  • Loading branch information
pdovhomilja committed Sep 11, 2023
1 parent 5627fa3 commit 6e56c75
Show file tree
Hide file tree
Showing 13 changed files with 348 additions and 77 deletions.
26 changes: 12 additions & 14 deletions app/[locale]/(auth)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import Footer from "@/app/[locale]/(routes)/components/Footer";
import "@/app/[locale]/globals.css";
import { ThemeToggle } from "@/components/ThemeToggle";
import axios from "axios";
import { GithubIcon, Star } from "lucide-react";
import { createTranslator } from "next-intl";
import { notFound } from "next/navigation";
import Link from "next/link";
import { notFound } from "next/navigation";
import { createTranslator } from "next-intl";
import { GithubIcon, Star } from "lucide-react";

import "@/app/[locale]/globals.css";
import { ThemeToggle } from "@/components/ThemeToggle";
import Footer from "@/app/[locale]/(routes)/components/Footer";

type Props = {
params: {locale: string};
params: { locale: string };
};

async function getLocales(locale: string) {
Expand All @@ -19,20 +20,17 @@ async function getLocales(locale: string) {
}
}

export async function generateMetadata({params: {locale}}: Props) {
export async function generateMetadata({ params: { locale } }: Props) {
const messages = await getLocales(locale);

const t = createTranslator({locale, messages});

const t = createTranslator({ locale, messages });
return {
title: t('RootLayout.title'),
description: t('RootLayout.description')
title: t("RootLayout.title"),
description: t("RootLayout.description"),
};
}

const AuthLayout = async ({ children }: { children: React.ReactNode }) => {
//Get github stars from github api

const github = await axios
.get(`https://api.github.com/repos/pdovhomilja/nextcrm-app`)
.then((res) => res.data);
Expand Down
46 changes: 21 additions & 25 deletions app/[locale]/(auth)/register/components/RegisterComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
"use client";

import React, { startTransition, useCallback } from "react";
import { z, ZodType } from "zod";
import { signIn } from "next-auth/react";
import { z } from "zod";
import axios from "axios";
import Link from "next/link";
import { useRouter } from "next-intl/client";
//import { toast } from "react-hot-toast";
import { useToast } from "@/components/ui/use-toast";

import { signIn } from "next-auth/react";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import axios from "axios";
import { useRouter } from "next-intl/client";
import React, { startTransition } from "react";
import { FingerprintIcon } from "lucide-react";
import { usePathname } from "next-intl/client";
import { zodResolver } from "@hookform/resolvers/zod";
import { useLocale, useTranslations } from "next-intl";

import { Icons } from "@/components/ui/icons";
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
CardDescription,
} from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import {
Form,
FormControl,
Expand All @@ -39,9 +34,10 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";

import { useLocale, useTranslations } from "next-intl";
import { usePathname } from "next-intl/client";
import { Icons } from "@/components/ui/icons";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { useToast } from "@/components/ui/use-toast";

export function RegisterComponent() {
const router = useRouter();
Expand Down Expand Up @@ -108,22 +104,22 @@ export function RegisterComponent() {
}
};

const t = useTranslations('RegisterComponent');
const t = useTranslations("RegisterComponent");
const locale = useLocale();
const pathname = usePathname();

function onValueChange( value: string ) {
function onValueChange(value: string) {
const nextLocale = value;
startTransition(() => {
router.replace(pathname, {locale: nextLocale});
router.replace(pathname, { locale: nextLocale });
});
}

return (
<Card className="shadow-lg ">
<CardHeader className="space-y-1">
<CardTitle className="text-2xl">{t('cardTitle')}</CardTitle>
<CardDescription>{t('cardDescription')}</CardDescription>
<CardTitle className="text-2xl">{t("cardTitle")}</CardTitle>
<CardDescription>{t("cardDescription")}</CardDescription>
</CardHeader>
<CardContent className="grid gap-4 overflow-auto">
<div className="grid grid-cols-2 gap-6">
Expand Down Expand Up @@ -209,7 +205,7 @@ export function RegisterComponent() {
name="language"
render={({ field }) => (
<FormItem>
<FormLabel>{t('label')}</FormLabel>
<FormLabel>{t("label")}</FormLabel>
<Select
disabled={isLoading}
onValueChange={onValueChange}
Expand All @@ -224,9 +220,9 @@ export function RegisterComponent() {
</SelectTrigger>
</FormControl>
<SelectContent>
{['en', 'de', 'cz'].map((cur) => (
{["en", "de", "cz"].map((cur) => (
<SelectItem key={cur} value={cur}>
{t('locale', {locale: cur})}
{t("locale", { locale: cur })}
</SelectItem>
))}
</SelectContent>
Expand Down
6 changes: 2 additions & 4 deletions app/[locale]/(auth)/register/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { RegisterComponent } from "./components/RegisterComponent";

type Props = {};

const RegistrPage = (props: Props) => {
const RegisterPage = () => {
return (
<div className="flex flex-col w-full h-full overflow-auto p-10 space-y-5">
<div className="">
Expand All @@ -15,4 +13,4 @@ const RegistrPage = (props: Props) => {
);
};

export default RegistrPage;
export default RegisterPage;
1 change: 1 addition & 0 deletions app/[locale]/(routes)/crm/accounts/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getAccounts } from "@/actions/crm/get-accounts";
const AccountsPage = async () => {
const crmData = await getAllCrmData();
const accounts = await getAccounts();

return (
<Container
title="Accounts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ export const columns: ColumnDef<Opportunity>[] = [
enableSorting: true,
enableHiding: true,
},
{
accessorKey: "budget",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Budget" />
),

cell: ({ row }) => {
console.log(row.original.budget);
return (
<div>
{row.original.budget
? row.original.budget.toLocaleString("en-US", {
style: "currency",
currency: "USD",
})
: "N/A"}
</div>
);
},
enableSorting: true,
enableHiding: true,
},
{
accessorKey: "next_step",
header: ({ column }) => (
Expand Down
12 changes: 9 additions & 3 deletions app/[locale]/(routes)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ const DashboardPage = async () => {
const usersTasks = await getUserTasks(userId);
const revenue = await getExpectedRevenue();

console.log(revenue, "revenue");

//Find which modules are enabled
const crmModule = modules.find((module) => module.name === "crm");
const invoiceModule = modules.find((module) => module.name === "invoice");
Expand Down Expand Up @@ -85,7 +83,15 @@ const DashboardPage = async () => {
<DollarSignIcon className="w-4 h-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-medium">{revenue}</div>
<div className="text-2xl font-medium">
{
//I need revenue value in forma 1.000.000
revenue.toLocaleString("en-US", {
style: "currency",
currency: "USD",
})
}
</div>
</CardContent>
</Card>
<Link href="/admin/users">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
"use client";

import LoadingComponent from "@/components/LoadingComponent";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogHeader,
DialogTrigger,
DialogTitle,
DialogDescription,
DialogFooter,
} from "@/components/ui/dialog";
import { z } from "zod";
import axios from "axios";
import { useForm } from "react-hook-form";
import { useRouter } from "next/navigation";
import React, { useEffect, useState } from "react";
import { zodResolver } from "@hookform/resolvers/zod";

import {
Form,
FormControl,
Expand All @@ -19,23 +15,18 @@ import {
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
Dialog,
DialogContent,
DialogHeader,
DialogTrigger,
DialogTitle,
DialogDescription,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { useToast } from "@/components/ui/use-toast";
import { zodResolver } from "@hookform/resolvers/zod";
import axios from "axios";
import { useRouter } from "next/navigation";

import React, { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import LoadingComponent from "@/components/LoadingComponent";

type Props = {
boardId: string;
Expand Down Expand Up @@ -85,6 +76,9 @@ const NewSectionDialog = ({ boardId }: Props) => {
description: error?.response?.data,
});
} finally {
form.reset({
title: "",
});
setIsLoading(false);
setOpen(false);
router.refresh();
Expand Down Expand Up @@ -132,10 +126,10 @@ const NewSectionDialog = ({ boardId }: Props) => {
/>
</div>
<div className="flex w-full justify-end space-x-2 pt-2">
<Button type="submit">Create</Button>
<DialogTrigger asChild>
<Button variant={"destructive"}>Cancel</Button>
</DialogTrigger>
<Button type="submit">Create</Button>
</div>
</form>
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import LoadingComponent from "@/components/LoadingComponent";
import { Button } from "@/components/ui/button";
import { Calendar } from "@/components/ui/calendar";
import {
Dialog,
DialogContent,
Expand All @@ -20,6 +21,11 @@ import {
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
import {
Select,
SelectContent,
Expand All @@ -29,8 +35,11 @@ import {
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
import { useToast } from "@/components/ui/use-toast";
import { cn } from "@/lib/utils";
import { zodResolver } from "@hookform/resolvers/zod";
import axios from "axios";
import { format } from "date-fns";
import { CalendarIcon } from "lucide-react";
import { useRouter } from "next/navigation";

import React, { useEffect, useState } from "react";
Expand All @@ -55,6 +64,7 @@ const NewTaskInProjectDialog = ({ users, boardId, sections }: Props) => {
const formSchema = z.object({
title: z.string().min(3).max(255),
user: z.string().min(3).max(255),
dueDateAt: z.date().default(new Date()),
priority: z.string().min(3).max(10),
section: z.string().min(3).max(255),
content: z.string().min(3).max(500),
Expand Down Expand Up @@ -166,6 +176,47 @@ const NewTaskInProjectDialog = ({ users, boardId, sections }: Props) => {
</FormItem>
)}
/>
<FormField
control={form.control}
name="dueDateAt"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Due date</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>
<Button
variant={"outline"}
className={cn(
"w-[240px] pl-3 text-left font-normal",
!field.value && "text-muted-foreground"
)}
>
{field.value ? (
format(field.value, "PPP")
) : (
<span>Pick a expected close date</span>
)}
<CalendarIcon className="ml-auto h-4 w-4 opacity-50" />
</Button>
</FormControl>
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="start">
<Calendar
mode="single"
selected={field.value}
//@ts-ignore
//TODO: fix this
onSelect={field.onChange}
disabled={(date) => date < new Date("1900-01-01")}
initialFocus
/>
</PopoverContent>
</Popover>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="user"
Expand Down
Loading

6 comments on commit 6e56c75

@vercel
Copy link

@vercel vercel bot commented on 6e56c75 Sep 11, 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
others.nextcrm.io
nextcrm-others-e-osvc.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 6e56c75 Sep 11, 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 6e56c75 Sep 11, 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 – ./

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

@vercel
Copy link

@vercel vercel bot commented on 6e56c75 Sep 11, 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 – ./

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

@vercel
Copy link

@vercel vercel bot commented on 6e56c75 Sep 11, 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 6e56c75 Sep 11, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.