mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
Merge remote-tracking branch 'origin/back-end' into back-end
This commit is contained in:
commit
6408d071ca
1
.prettierignore
Normal file
1
.prettierignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
/tailwind.config.ts
|
||||||
1914
package-lock.json
generated
1914
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@ -12,6 +12,10 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.9.0",
|
"@hookform/resolvers": "^3.9.0",
|
||||||
"@mdxeditor/editor": "^3.15.0",
|
"@mdxeditor/editor": "^3.15.0",
|
||||||
|
"@nextui-org/calendar": "^2.0.12",
|
||||||
|
"@nextui-org/date-input": "^2.1.4",
|
||||||
|
"@nextui-org/system": "^2.2.6",
|
||||||
|
"@nextui-org/theme": "^2.2.11",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.2",
|
"@radix-ui/react-alert-dialog": "^1.1.2",
|
||||||
"@radix-ui/react-avatar": "^1.1.0",
|
"@radix-ui/react-avatar": "^1.1.0",
|
||||||
"@radix-ui/react-checkbox": "^1.1.2",
|
"@radix-ui/react-checkbox": "^1.1.2",
|
||||||
@ -32,25 +36,28 @@
|
|||||||
"@stripe/react-stripe-js": "^2.8.1",
|
"@stripe/react-stripe-js": "^2.8.1",
|
||||||
"@stripe/stripe-js": "^4.7.0",
|
"@stripe/stripe-js": "^4.7.0",
|
||||||
"@supabase-cache-helpers/postgrest-react-query": "^1.10.1",
|
"@supabase-cache-helpers/postgrest-react-query": "^1.10.1",
|
||||||
"@supabase/ssr": "^0.4.1",
|
"@supabase/ssr": "^0.5.2",
|
||||||
"@supabase/supabase-js": "^2.46.1",
|
"@supabase/supabase-js": "^2.46.1",
|
||||||
|
"@tailwindcss/line-clamp": "^0.4.4",
|
||||||
"@tanstack/react-query": "^5.59.0",
|
"@tanstack/react-query": "^5.59.0",
|
||||||
"@tanstack/react-query-devtools": "^5.59.0",
|
"@tanstack/react-query-devtools": "^5.59.0",
|
||||||
|
"@tanstack/react-table": "^8.20.5",
|
||||||
"b2d-ventures": "file:",
|
"b2d-ventures": "file:",
|
||||||
"chart.js": "^4.4.6",
|
"chart.js": "^4.4.6",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cmdk": "1.0.0",
|
"cmdk": "1.0.0",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^3.0.0",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"embla-carousel-react": "^8.2.0",
|
"embla-carousel-react": "^8.2.0",
|
||||||
|
"framer-motion": "^11.11.17",
|
||||||
"lucide-react": "^0.428.0",
|
"lucide-react": "^0.428.0",
|
||||||
"next": "^14.2.15",
|
"next": "^14.2.15",
|
||||||
"next-themes": "^0.3.0",
|
"next-themes": "^0.3.0",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-chartjs-2": "^5.2.0",
|
"react-chartjs-2": "^5.2.0",
|
||||||
"react-countup": "^6.5.3",
|
"react-countup": "^6.5.3",
|
||||||
"react-day-picker": "^9",
|
"react-day-picker": "^9.*",
|
||||||
"react-dom": "^18",
|
"react-dom": "^18",
|
||||||
"react-file-icon": "^1.5.0",
|
"react-file-icon": "^1.5.0",
|
||||||
"react-hook-form": "^7.53.0",
|
"react-hook-form": "^7.53.0",
|
||||||
|
|||||||
@ -1,42 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogDescription,
|
|
||||||
DialogFooter,
|
|
||||||
DialogHeader,
|
|
||||||
DialogTitle,
|
|
||||||
DialogTrigger,
|
|
||||||
} from "@/components/ui/dialog";
|
|
||||||
import Image from "next/image";
|
|
||||||
import { StaticImport } from "next/dist/shared/lib/get-img-props";
|
|
||||||
|
|
||||||
interface ItemProps {
|
|
||||||
src: string | StaticImport;
|
|
||||||
alt: string;
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ImageModal = ({ src, alt, width, height, className }: ItemProps) => {
|
|
||||||
return (
|
|
||||||
<Dialog>
|
|
||||||
<DialogTrigger asChild>
|
|
||||||
<Image src={src} alt={alt} width={width} height={height} className={className} />
|
|
||||||
</DialogTrigger>
|
|
||||||
<DialogContent>
|
|
||||||
<DialogHeader>
|
|
||||||
<DialogTitle>Image Preview</DialogTitle>
|
|
||||||
<DialogDescription>Click outside to close the image preview.</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
<Image src={src} alt={alt} width={700} height={400} />
|
|
||||||
<DialogFooter />
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export function DisplayFullImage({ src, alt, width, height, className }: ItemProps) {
|
|
||||||
return <ImageModal src={src} alt={alt} width={width} height={height} className={className} />;
|
|
||||||
}
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
import CustomTooltip from "@/components/customToolTip";
|
||||||
import { ShareIcon, StarIcon } from "lucide-react";
|
import { ShareIcon, StarIcon } from "lucide-react";
|
||||||
import { deleteFollow, getFollow, insertFollow } from "@/lib/data/followQuery";
|
import { deleteFollow, getFollow, insertFollow } from "@/lib/data/followQuery";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
@ -13,9 +13,10 @@ import { useQuery } from "@supabase-cache-helpers/postgrest-react-query";
|
|||||||
interface FollowShareButtons {
|
interface FollowShareButtons {
|
||||||
userId: string;
|
userId: string;
|
||||||
projectId: number;
|
projectId: number;
|
||||||
|
projectName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FollowShareButtons = ({ userId, projectId }: FollowShareButtons) => {
|
const FollowShareButtons = ({ userId, projectId, projectName }: FollowShareButtons) => {
|
||||||
const supabase = createSupabaseClient();
|
const supabase = createSupabaseClient();
|
||||||
const { data: follow, isLoading: followIsLoading } = useQuery(getFollow(supabase, userId, projectId), {
|
const { data: follow, isLoading: followIsLoading } = useQuery(getFollow(supabase, userId, projectId), {
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
@ -71,16 +72,9 @@ const FollowShareButtons = ({ userId, projectId }: FollowShareButtons) => {
|
|||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-2 gap-5 justify-self-end ">
|
<div className="grid grid-cols-2 gap-5 justify-self-end ">
|
||||||
<div className="mt-2 cursor-pointer" onClick={handleFollow}>
|
<div className="mt-2 cursor-pointer" onClick={handleFollow}>
|
||||||
<TooltipProvider>
|
<CustomTooltip message={`Follow ${projectName}`}>
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger asChild>
|
|
||||||
<StarIcon id="follow" fill={isFollowState ? "#fcb30e" : "#fff"} strokeWidth={2} />
|
<StarIcon id="follow" fill={isFollowState ? "#fcb30e" : "#fff"} strokeWidth={2} />
|
||||||
</TooltipTrigger>
|
</CustomTooltip>
|
||||||
<TooltipContent>
|
|
||||||
<p>Follow NVIDIA</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</TooltipProvider>
|
|
||||||
</div>
|
</div>
|
||||||
<div onClick={handleShare} className="cursor-pointer mt-2">
|
<div onClick={handleShare} className="cursor-pointer mt-2">
|
||||||
<ShareIcon />
|
<ShareIcon />
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
import ReactMarkdown from "react-markdown";
|
import ReactMarkdown from "react-markdown";
|
||||||
|
|
||||||
import * as Tabs from "@radix-ui/react-tabs";
|
import * as Tabs from "@radix-ui/react-tabs";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/ui/card";
|
||||||
@ -10,7 +8,6 @@ import { Progress } from "@/components/ui/progress";
|
|||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { createSupabaseClient } from "@/lib/supabase/serverComponentClient";
|
import { createSupabaseClient } from "@/lib/supabase/serverComponentClient";
|
||||||
import FollowShareButtons from "./followShareButton";
|
import FollowShareButtons from "./followShareButton";
|
||||||
|
|
||||||
import { getProjectData } from "@/lib/data/projectQuery";
|
import { getProjectData } from "@/lib/data/projectQuery";
|
||||||
import { getDealList } from "@/app/api/dealApi";
|
import { getDealList } from "@/app/api/dealApi";
|
||||||
import { sumByKey, toPercentage } from "@/lib/utils";
|
import { sumByKey, toPercentage } from "@/lib/utils";
|
||||||
@ -89,7 +86,7 @@ export default async function ProjectDealPage({ params }: { params: { id: number
|
|||||||
<Image src="/logo.svg" alt="logo" width={50} height={50} className="sm:scale-75" />
|
<Image src="/logo.svg" alt="logo" width={50} height={50} className="sm:scale-75" />
|
||||||
<h1 className="mt-3 font-bold text-lg md:text-3xl">{projectData?.project_name}</h1>
|
<h1 className="mt-3 font-bold text-lg md:text-3xl">{projectData?.project_name}</h1>
|
||||||
</span>
|
</span>
|
||||||
<FollowShareButtons userId={user!.user.id} projectId={params.id} />
|
<FollowShareButtons userId={user!.user.id} projectId={params.id} projectName={projectData?.project_name} />
|
||||||
</div>
|
</div>
|
||||||
{/* end of pack */}
|
{/* end of pack */}
|
||||||
<p className="mt-2 sm:text-sm">{projectData?.project_short_description}</p>
|
<p className="mt-2 sm:text-sm">{projectData?.project_short_description}</p>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { UserIcon, UsersIcon } from "lucide-react";
|
import { Building2, ClipboardPen, Tag } from "lucide-react";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { getAllBusinessTypeQuery, getAllTagsQuery, getAllProjectStatusQuery } from "@/lib/data/dropdownQuery";
|
import { getAllBusinessTypeQuery, getAllTagsQuery, getAllProjectStatusQuery } from "@/lib/data/dropdownQuery";
|
||||||
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
||||||
@ -140,7 +140,7 @@ export default function Deals() {
|
|||||||
{/* Business Type Filter */}
|
{/* Business Type Filter */}
|
||||||
<Select value={businessTypeFilter} onValueChange={(value) => setBusinessTypeFilter(value)}>
|
<Select value={businessTypeFilter} onValueChange={(value) => setBusinessTypeFilter(value)}>
|
||||||
<SelectTrigger className="w-full sm:w-[180px]">
|
<SelectTrigger className="w-full sm:w-[180px]">
|
||||||
<UsersIcon className="ml-2" />
|
<Building2 className="ml-2" />
|
||||||
<SelectValue placeholder="Business Type" />
|
<SelectValue placeholder="Business Type" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
@ -169,7 +169,7 @@ export default function Deals() {
|
|||||||
{/* Project Status Filter */}
|
{/* Project Status Filter */}
|
||||||
<Select value={projectStatusFilter} onValueChange={(value) => setProjectStatusFilter(value)}>
|
<Select value={projectStatusFilter} onValueChange={(value) => setProjectStatusFilter(value)}>
|
||||||
<SelectTrigger className="w-full sm:w-[180px]">
|
<SelectTrigger className="w-full sm:w-[180px]">
|
||||||
<UserIcon className="ml-2" />
|
<ClipboardPen className="ml-2" />
|
||||||
<SelectValue placeholder="Project Status" />
|
<SelectValue placeholder="Project Status" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
@ -198,7 +198,7 @@ export default function Deals() {
|
|||||||
{/* Tags Filter */}
|
{/* Tags Filter */}
|
||||||
<Select value={tagFilter} onValueChange={(value) => setTagFilter(value)}>
|
<Select value={tagFilter} onValueChange={(value) => setTagFilter(value)}>
|
||||||
<SelectTrigger className="w-full sm:w-[180px]">
|
<SelectTrigger className="w-full sm:w-[180px]">
|
||||||
<UserIcon className="ml-2" />
|
<Tag className="ml-2" />
|
||||||
<SelectValue placeholder="Tags" />
|
<SelectValue placeholder="Tags" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@ -13,10 +13,20 @@ import {
|
|||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Clock } from "lucide-react";
|
import { Clock } from "lucide-react";
|
||||||
import { DateTimePicker, TimePicker } from "@/components/ui/datetime-picker";
|
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { createCalendarEvent } from "./actions";
|
import { createCalendarEvent, createMeetingLog, getFreeDate } from "./actions";
|
||||||
import { Session } from "@supabase/supabase-js";
|
import { Session } from "@supabase/supabase-js";
|
||||||
|
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
||||||
|
import { TimeInput } from "@nextui-org/date-input";
|
||||||
|
import { Calendar, DateValue } from "@nextui-org/calendar";
|
||||||
|
import { TimeValue } from "@react-types/datepicker";
|
||||||
|
import { CalendarDate, getLocalTimeZone, today } from "@internationalized/date";
|
||||||
|
// import { useLocale } from "@react-aria/i18n";
|
||||||
|
import { getMeetingLog } from "./actions";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
import { useQuery } from "@supabase-cache-helpers/postgrest-react-query";
|
||||||
|
import { LegacyLoader } from "@/components/loading/LegacyLoader";
|
||||||
|
import { isEventOverlapping } from "./overlapEvent";
|
||||||
|
|
||||||
interface DialogProps {
|
interface DialogProps {
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
@ -27,37 +37,126 @@ interface DialogProps {
|
|||||||
modal?: boolean;
|
modal?: boolean;
|
||||||
session: Session;
|
session: Session;
|
||||||
projectName: string;
|
projectName: string;
|
||||||
|
projectId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MeetEventDialog(props: DialogProps) {
|
export function MeetEventDialog(props: DialogProps) {
|
||||||
const [eventDate, setEventDate] = useState<Date | undefined>(undefined);
|
const supabase = createSupabaseClient();
|
||||||
const [startTime, setStartTime] = useState<Date | undefined>(undefined);
|
const timezone = getLocalTimeZone();
|
||||||
const [endTime, setEndTime] = useState<Date | undefined>(undefined);
|
const [eventDate, setEventDate] = useState<CalendarDate | undefined>(undefined);
|
||||||
|
const [startTime, setStartTime] = useState<TimeValue | undefined>(undefined);
|
||||||
|
const [endTime, setEndTime] = useState<TimeValue | undefined>(undefined);
|
||||||
const [eventName, setEventName] = useState(`Meet with ${props.projectName}`);
|
const [eventName, setEventName] = useState(`Meet with ${props.projectName}`);
|
||||||
const [eventDescription, setEventDescription] = useState(
|
const [eventDescription, setEventDescription] = useState(
|
||||||
"Meet and gather more information on business in B2DVentures"
|
"Meet and gather more information on business in B2DVentures"
|
||||||
);
|
);
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
|
||||||
const [noteToBusiness, setNoteToBusiness] = useState<string>("");
|
const [noteToBusiness, setNoteToBusiness] = useState<string>("");
|
||||||
const session = props.session;
|
const session = props.session;
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: freeDate,
|
||||||
|
error: freeDateError,
|
||||||
|
isLoading: isLoadingFreeDate,
|
||||||
|
} = useQuery(getFreeDate(supabase, props.projectId), { enabled: !!props.projectId });
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (props.projectName) {
|
||||||
|
setEventName(`Meet with ${props.projectName}`);
|
||||||
|
}
|
||||||
|
}, [props.projectName]);
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: meetingLog,
|
||||||
|
error: meetingLogError,
|
||||||
|
isLoading: isLoadingMeetingLog,
|
||||||
|
} = useQuery(getMeetingLog(supabase, props.projectId), { enabled: !!props.projectId });
|
||||||
|
|
||||||
const handleCreateEvent = async () => {
|
const handleCreateEvent = async () => {
|
||||||
if (!session || !eventDate || !startTime || !endTime || !eventName) {
|
if (!session || !eventDate || !startTime || !endTime || !eventName) {
|
||||||
alert("Please fill in all event details.");
|
toast.error("Please fill in all event details.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const startDate = new Date(eventDate);
|
setIsSubmitting(true);
|
||||||
startDate.setHours(startTime.getHours(), startTime.getMinutes());
|
|
||||||
|
try {
|
||||||
|
const startDate = eventDate.toDate(timezone);
|
||||||
|
startDate.setHours(startTime.hour, startTime.minute);
|
||||||
|
|
||||||
|
const endDate = eventDate.toDate(timezone);
|
||||||
|
endDate.setHours(endTime.hour, startTime.minute);
|
||||||
|
|
||||||
|
const existingEvents = (meetingLog || []).map((log) => ({
|
||||||
|
meet_date: log.meet_date,
|
||||||
|
start_time: log.start_time,
|
||||||
|
end_time: log.end_time,
|
||||||
|
}));
|
||||||
|
const hasOverlap = isEventOverlapping(eventDate, startTime, endTime, existingEvents);
|
||||||
|
|
||||||
|
if (hasOverlap) {
|
||||||
|
toast.error("This current selected date and time is overlaped with any existing events.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const endDate = new Date(eventDate);
|
|
||||||
endDate.setHours(endTime.getHours(), endTime.getMinutes());
|
|
||||||
await createCalendarEvent(session, startDate, endDate, eventName, eventDescription);
|
await createCalendarEvent(session, startDate, endDate, eventName, eventDescription);
|
||||||
|
|
||||||
|
const { status, error } = await createMeetingLog({
|
||||||
|
client: supabase,
|
||||||
|
meet_date: eventDate.toString().split("T")[0],
|
||||||
|
start_time: startTime.toString(),
|
||||||
|
end_time: endTime.toString(),
|
||||||
|
note: noteToBusiness,
|
||||||
|
userId: session.user.id,
|
||||||
|
projectId: props.projectId!,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!status) {
|
||||||
|
console.error("Meeting log error:", error);
|
||||||
|
toast.error("Failed to log the meeting. Please try again.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
toast.success("Meeting event created successfully!");
|
||||||
props.onOpenChange?.(false);
|
props.onOpenChange?.(false);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error creating event:", error);
|
||||||
|
toast.error("There was an error creating the event. Please try again.");
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const meetingLogRanges = (meetingLog || []).map((log) => {
|
||||||
|
const [year, month, day] = log.meet_date.split("-").map(Number);
|
||||||
|
const startDate = new CalendarDate(year, month, day);
|
||||||
|
const endDate = new CalendarDate(year, month, day);
|
||||||
|
return [startDate, endDate];
|
||||||
|
});
|
||||||
|
|
||||||
|
const freetimeLogRanges = (freeDate || []).map((log) => {
|
||||||
|
const [year, month, day] = log.meet_date.split("-").map(Number);
|
||||||
|
const startDate = new CalendarDate(year, month, day);
|
||||||
|
const endDate = new CalendarDate(year, month, day);
|
||||||
|
return [startDate, endDate];
|
||||||
|
});
|
||||||
|
|
||||||
|
// const disabledRanges = [...meetingLogRanges];
|
||||||
|
// const { locale } = useLocale();
|
||||||
|
|
||||||
|
const isDateUnavailable = (date: DateValue) => {
|
||||||
|
const isFreeDate = freetimeLogRanges.some(
|
||||||
|
(interval) => date.compare(interval[0]) >= 0 && date.compare(interval[1]) <= 0
|
||||||
|
);
|
||||||
|
const isMeetingDate = meetingLogRanges.some(
|
||||||
|
(interval) => date.compare(interval[0]) >= 0 && date.compare(interval[1]) <= 0
|
||||||
|
);
|
||||||
|
return !isFreeDate || isMeetingDate;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog {...props}>
|
<Dialog {...props}>
|
||||||
<DialogContent className="sm:max-w-md">
|
<DialogContent className="sm:max-w-md overflow-y-auto h-[80%]">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="flex gap-2 items-center">
|
<DialogTitle className="flex gap-2 items-center">
|
||||||
<Clock />
|
<Clock />
|
||||||
@ -68,6 +167,11 @@ export function MeetEventDialog(props: DialogProps) {
|
|||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
|
{meetingLogError || freeDateError ? (
|
||||||
|
<div className="error-message">
|
||||||
|
<p>Error loading meeting logs</p>
|
||||||
|
</div>
|
||||||
|
) : !isLoadingMeetingLog || !isLoadingFreeDate ? (
|
||||||
<div className="space-y-4 w-[90%]">
|
<div className="space-y-4 w-[90%]">
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="eventName">Event Name</Label>
|
<Label htmlFor="eventName">Event Name</Label>
|
||||||
@ -96,25 +200,33 @@ export function MeetEventDialog(props: DialogProps) {
|
|||||||
onChange={(e) => setNoteToBusiness(e.target.value)}
|
onChange={(e) => setNoteToBusiness(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="flex flex-col space-y-2">
|
||||||
<Label>Date</Label>
|
<Label>Date</Label>
|
||||||
<DateTimePicker granularity="day" hourCycle={24} value={eventDate} onChange={setEventDate} />
|
<Calendar
|
||||||
|
value={eventDate}
|
||||||
|
onChange={setEventDate}
|
||||||
|
minValue={today(getLocalTimeZone())}
|
||||||
|
isDateUnavailable={isDateUnavailable}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<Label>Start Time</Label>
|
<Label>Start Time</Label>
|
||||||
<TimePicker date={startTime} onChange={setStartTime} />
|
<TimeInput label="Start Time" value={startTime} onChange={setStartTime} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Label>End Time</Label>
|
<Label>End Time</Label>
|
||||||
<TimePicker date={endTime} onChange={setEndTime} />
|
<TimeInput label="End Time" value={endTime} onChange={setEndTime} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
<LegacyLoader />
|
||||||
|
)}
|
||||||
|
|
||||||
<DialogFooter className="sm:justify-start mt-4">
|
<DialogFooter className="sm:justify-start mt-4">
|
||||||
<Button type="button" onClick={handleCreateEvent} className="mr-2">
|
<Button type="button" onClick={handleCreateEvent} className="mr-2" disabled={isSubmitting}>
|
||||||
Create Event
|
{isSubmitting ? "Creating..." : "Create Event"}
|
||||||
</Button>
|
</Button>
|
||||||
<DialogClose asChild>
|
<DialogClose asChild>
|
||||||
<Button type="button" variant="secondary">
|
<Button type="button" variant="secondary">
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { Session } from "@supabase/supabase-js";
|
import { Database } from "@/types/database.types";
|
||||||
|
import { Session, SupabaseClient } from "@supabase/supabase-js";
|
||||||
|
|
||||||
export async function createCalendarEvent(
|
export async function createCalendarEvent(
|
||||||
session: Session,
|
session: Session,
|
||||||
@ -33,9 +34,81 @@ export async function createCalendarEvent(
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log(data);
|
console.log(data);
|
||||||
alert("Event created, check your Google Calendar!");
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating calendar event:", error);
|
console.error("Error creating calendar event:", error);
|
||||||
alert("Failed to create the event.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface CreateMeetingLogProps {
|
||||||
|
client: SupabaseClient;
|
||||||
|
userId: string;
|
||||||
|
projectId: number;
|
||||||
|
meet_date: string;
|
||||||
|
start_time: string;
|
||||||
|
end_time: string;
|
||||||
|
note: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createMeetingLog({
|
||||||
|
client,
|
||||||
|
userId,
|
||||||
|
projectId,
|
||||||
|
meet_date,
|
||||||
|
start_time,
|
||||||
|
end_time,
|
||||||
|
note,
|
||||||
|
}: CreateMeetingLogProps) {
|
||||||
|
const { error } = await client.from("meeting_log").insert([
|
||||||
|
{
|
||||||
|
meet_date: meet_date, // Format date as YYYY-MM-DD
|
||||||
|
start_time: start_time, // Format time as HH:MM:SS
|
||||||
|
end_time: end_time, // Format time as HH:MM:SS
|
||||||
|
note: note, // Text for meeting notes
|
||||||
|
user_id: userId, // Replace with a valid UUID
|
||||||
|
project_id: projectId,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
return error ? { status: false, error } : { status: true, error: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMeetingLog(client: SupabaseClient<Database>, projectId: number) {
|
||||||
|
return client
|
||||||
|
.from("meeting_log")
|
||||||
|
.select(
|
||||||
|
`
|
||||||
|
id,
|
||||||
|
meet_date,
|
||||||
|
start_time,
|
||||||
|
end_time,
|
||||||
|
note,
|
||||||
|
user_id,
|
||||||
|
project_id,
|
||||||
|
created_at
|
||||||
|
`
|
||||||
|
)
|
||||||
|
.eq("project_id", projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getFreeDate(client: SupabaseClient<Database>, projectId: number) {
|
||||||
|
return client.from("project_meeting_time").select("*").eq("project_id", projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function specifyFreeDate({
|
||||||
|
client,
|
||||||
|
meet_date,
|
||||||
|
projectId,
|
||||||
|
}: {
|
||||||
|
client: SupabaseClient<Database>;
|
||||||
|
meet_date: string;
|
||||||
|
projectId: number;
|
||||||
|
}) {
|
||||||
|
const { error } = await client.from("project_meeting_time").insert([
|
||||||
|
{
|
||||||
|
project_id: projectId,
|
||||||
|
meet_date: meet_date, // Format date as YYYY-MM-DD
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
return error ? { status: false, error } : { status: true, error: null };
|
||||||
|
}
|
||||||
|
|||||||
196
src/app/calendar/manage/FreeTimeDialog.tsx
Normal file
196
src/app/calendar/manage/FreeTimeDialog.tsx
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Calendar, DateValue } from "@nextui-org/calendar";
|
||||||
|
import { specifyFreeDate, getFreeDate } from "../actions";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
import { CalendarDate, getLocalTimeZone, today } from "@internationalized/date";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { useQuery } from "@supabase-cache-helpers/postgrest-react-query";
|
||||||
|
import { LegacyLoader } from "@/components/loading/LegacyLoader";
|
||||||
|
import {
|
||||||
|
AlertDialog,
|
||||||
|
AlertDialogContent,
|
||||||
|
AlertDialogHeader,
|
||||||
|
AlertDialogTitle,
|
||||||
|
AlertDialogDescription,
|
||||||
|
AlertDialogFooter,
|
||||||
|
AlertDialogCancel,
|
||||||
|
AlertDialogAction,
|
||||||
|
} from "@/components/ui/alert-dialog";
|
||||||
|
|
||||||
|
interface DialogProps {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
open?: boolean;
|
||||||
|
defaultOpen?: boolean;
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
onOpenChange?(open: boolean): void;
|
||||||
|
modal?: boolean;
|
||||||
|
projectId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function FreeTimeDialog(props: DialogProps) {
|
||||||
|
const supabase = createSupabaseClient();
|
||||||
|
const timezone = getLocalTimeZone();
|
||||||
|
const [selectedDate, setSelectedDate] = useState<CalendarDate | undefined>(undefined);
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
|
||||||
|
const [deleteDateId, setDeleteDateId] = useState<number | null>(null);
|
||||||
|
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: freeDate,
|
||||||
|
error: freeDateError,
|
||||||
|
isLoading: isLoadingFreeDate,
|
||||||
|
refetch: refetchFreeDate,
|
||||||
|
} = useQuery(getFreeDate(supabase, props.projectId), { enabled: !!props.projectId });
|
||||||
|
|
||||||
|
const handleSpecifyFreeDate = async () => {
|
||||||
|
if (!selectedDate) {
|
||||||
|
toast.error("Please select a date.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSubmitting(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const formattedDate = selectedDate.toString().split("T")[0];
|
||||||
|
const { status, error } = await specifyFreeDate({
|
||||||
|
client: supabase,
|
||||||
|
meet_date: formattedDate,
|
||||||
|
projectId: props.projectId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!status || error) {
|
||||||
|
toast.error("Failed to save the free date. Please try again.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
refetchFreeDate();
|
||||||
|
toast.success("Free time specified successfully!");
|
||||||
|
props.onOpenChange?.(false);
|
||||||
|
} catch (error) {
|
||||||
|
toast.error("There was an error specifying the free date. Please try again.");
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteFreeDate = async () => {
|
||||||
|
if (deleteDateId === null) return;
|
||||||
|
|
||||||
|
setIsSubmitting(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { error } = await supabase.from("project_meeting_time").delete().eq("id", deleteDateId);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
toast.error("Failed to delete the free date. Please try again.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
refetchFreeDate();
|
||||||
|
toast.success("Free date deleted successfully!");
|
||||||
|
} catch (error) {
|
||||||
|
toast.error("There was an error deleting the free date. Please try again.");
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
setIsDeleteDialogOpen(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const meetingLogRanges = (freeDate || []).map((log) => {
|
||||||
|
const [year, month, day] = log.meet_date.split("-").map(Number);
|
||||||
|
const startDate = new CalendarDate(year, month, day);
|
||||||
|
const endDate = new CalendarDate(year, month, day);
|
||||||
|
return [startDate, endDate];
|
||||||
|
});
|
||||||
|
|
||||||
|
const disabledRanges = [...meetingLogRanges];
|
||||||
|
|
||||||
|
const isDateUnavailable = (date: DateValue) =>
|
||||||
|
disabledRanges.some((interval) => date.compare(interval[0]) >= 0 && date.compare(interval[1]) <= 0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog {...props}>
|
||||||
|
<DialogContent className="sm:max-w-md overflow-y-auto h-[80%]">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle className="flex gap-2 items-center">Specify Your Free Time</DialogTitle>
|
||||||
|
<DialogDescription>Select a date when you are available for a meeting with the investor.</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
|
{freeDateError ? (
|
||||||
|
<div>Error Loading data</div>
|
||||||
|
) : isLoadingFreeDate ? (
|
||||||
|
<LegacyLoader />
|
||||||
|
) : (
|
||||||
|
<div className="flex flex-col space-y-4 w-[90%] mt-4">
|
||||||
|
<div className="flex flex-col space-y-2">
|
||||||
|
<Label>Date</Label>
|
||||||
|
<Calendar
|
||||||
|
value={selectedDate}
|
||||||
|
onChange={setSelectedDate}
|
||||||
|
minValue={today(timezone)}
|
||||||
|
isDateUnavailable={isDateUnavailable}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col space-y-2 mt-4">
|
||||||
|
<Label>Current Free Dates</Label>
|
||||||
|
<div className="p-2 border rounded-md space-y-2">
|
||||||
|
{freeDate && freeDate.length > 0 ? (
|
||||||
|
freeDate.map((date) => (
|
||||||
|
<div
|
||||||
|
key={date.id}
|
||||||
|
className="bg-gray-100 p-2 rounded cursor-pointer hover:bg-red-400"
|
||||||
|
onClick={() => {
|
||||||
|
setDeleteDateId(date.id);
|
||||||
|
setIsDeleteDialogOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{date.meet_date || "No date specified"}
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<div>No free dates specified</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<DialogFooter className="sm:justify-start mt-4">
|
||||||
|
<Button onClick={handleSpecifyFreeDate} disabled={isSubmitting}>
|
||||||
|
{isSubmitting ? "Saving..." : "Save Free Date"}
|
||||||
|
</Button>
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button type="button" variant="secondary">
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
</DialogClose>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
|
||||||
|
<AlertDialog open={isDeleteDialogOpen} onOpenChange={setIsDeleteDialogOpen}>
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription>
|
||||||
|
This action cannot be undone. This will permanently delete the free date.
|
||||||
|
</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter>
|
||||||
|
<AlertDialogCancel onClick={() => setIsDeleteDialogOpen(false)}>Cancel</AlertDialogCancel>
|
||||||
|
<AlertDialogAction onClick={handleDeleteFreeDate}>Continue</AlertDialogAction>
|
||||||
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
101
src/app/calendar/manage/ManageMeetDialog.tsx
Normal file
101
src/app/calendar/manage/ManageMeetDialog.tsx
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React from "react";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import { Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||||
|
import { Clock } from "lucide-react";
|
||||||
|
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
||||||
|
|
||||||
|
import { getMeetingLog } from "../actions";
|
||||||
|
import { useQuery } from "@supabase-cache-helpers/postgrest-react-query";
|
||||||
|
import { LegacyLoader } from "@/components/loading/LegacyLoader";
|
||||||
|
|
||||||
|
interface DialogProps {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
open?: boolean;
|
||||||
|
defaultOpen?: boolean;
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
onOpenChange?(open: boolean): void;
|
||||||
|
modal?: boolean;
|
||||||
|
projectId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ManageMeetDialog(props: DialogProps) {
|
||||||
|
const supabase = createSupabaseClient();
|
||||||
|
const {
|
||||||
|
data: meetingLog,
|
||||||
|
error: meetingLogError,
|
||||||
|
isLoading: isLoadingMeetingLog,
|
||||||
|
} = useQuery(getMeetingLog(supabase, props.projectId), {
|
||||||
|
enabled: !!props.projectId,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog {...props}>
|
||||||
|
<DialogContent className="sm:max-w-md overflow-y-auto h-[80%]">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle className="flex gap-2 items-center">
|
||||||
|
<Clock />
|
||||||
|
Meeting Request
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogDescription>List of meeting you need to attend.</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
|
{meetingLogError ? (
|
||||||
|
<div>Error Loading data</div>
|
||||||
|
) : isLoadingMeetingLog ? (
|
||||||
|
<LegacyLoader />
|
||||||
|
) : meetingLog && meetingLog.length > 0 ? (
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead className="w-[100px]">Date</TableHead>
|
||||||
|
<TableHead>Start Time</TableHead>
|
||||||
|
<TableHead>End Time</TableHead>
|
||||||
|
<TableHead>User</TableHead>
|
||||||
|
<TableHead>Note</TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{meetingLog.map((log) => (
|
||||||
|
<TableRow key={log.id}>
|
||||||
|
<TableCell className="font-medium">{log.meet_date}</TableCell>
|
||||||
|
<TableCell>{log.start_time}</TableCell>
|
||||||
|
<TableCell>{log.end_time}</TableCell>
|
||||||
|
<TableCell>{log.user_id}</TableCell>
|
||||||
|
<TableCell>{log.note || "No note provided"}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
<TableFooter>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={5} className="text-right">
|
||||||
|
Total Meetings: {meetingLog.length}
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableFooter>
|
||||||
|
</Table>
|
||||||
|
) : (
|
||||||
|
<div>No meeting logs available</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<DialogFooter className="sm:justify-start mt-4">
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button type="button" variant="secondary">
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
</DialogClose>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
74
src/app/calendar/manage/ProjectCardSection.tsx
Normal file
74
src/app/calendar/manage/ProjectCardSection.tsx
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Separator } from "@/components/ui/separator";
|
||||||
|
import { Card, CardContent, CardDescription, CardTitle, CardHeader } from "@/components/ui/card";
|
||||||
|
import { Tooltip, TooltipProvider, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
|
import { ManageMeetDialog } from "./ManageMeetDialog";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import FreeTimeDialog from "./FreeTimeDialog";
|
||||||
|
|
||||||
|
type ProjectCardSectionProps = {
|
||||||
|
id: number;
|
||||||
|
project_name: string;
|
||||||
|
project_short_description: string;
|
||||||
|
business_id: {
|
||||||
|
user_id: string;
|
||||||
|
};
|
||||||
|
dataroom_id: number | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
type ProjectCardCalendarManageSectionProps = {
|
||||||
|
projectData: ProjectCardSectionProps[] | null;
|
||||||
|
};
|
||||||
|
export default function ProjectCardCalendarManageSection({ projectData }: ProjectCardCalendarManageSectionProps) {
|
||||||
|
const [showMeetModal, setShowMeetModal] = useState<boolean>(false);
|
||||||
|
const [showFreeTimeModal, setShowFreeTimeModal] = useState<boolean>(false);
|
||||||
|
const [currentProjectId, setCurrentProjectId] = useState<number | undefined>(undefined);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div id="content" className="grid grid-cols-2 space-x-2">
|
||||||
|
{projectData != null ? (
|
||||||
|
projectData.map((project) => (
|
||||||
|
<Card key={project.id} className="mb-3">
|
||||||
|
<CardHeader className="h-[55%]">
|
||||||
|
<CardTitle>{project.project_name}</CardTitle>
|
||||||
|
<TooltipProvider>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<CardDescription className="line-clamp-1">{project.project_short_description}</CardDescription>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>{project.project_short_description}</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
|
</CardHeader>
|
||||||
|
<Separator className="mb-3" />
|
||||||
|
<CardContent className="flex gap-3">
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentProjectId(project.id);
|
||||||
|
setTimeout(() => setShowMeetModal(true), 0);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Meeting List
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentProjectId(project.id);
|
||||||
|
setTimeout(() => setShowFreeTimeModal(true), 0);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Specify Free Time
|
||||||
|
</Button>
|
||||||
|
</CardContent>
|
||||||
|
{/* <CardFooter></CardFooter> */}
|
||||||
|
</Card>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<div>No project data</div>
|
||||||
|
)}
|
||||||
|
<ManageMeetDialog open={showMeetModal} onOpenChange={setShowMeetModal} projectId={currentProjectId!} />
|
||||||
|
<FreeTimeDialog open={showFreeTimeModal} onOpenChange={setShowFreeTimeModal} projectId={currentProjectId!} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
62
src/app/calendar/manage/page.tsx
Normal file
62
src/app/calendar/manage/page.tsx
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import { Separator } from "@/components/ui/separator";
|
||||||
|
import { Clock } from "lucide-react";
|
||||||
|
import { createSupabaseClient } from "@/lib/supabase/serverComponentClient";
|
||||||
|
import { getProjectByUserId } from "@/lib/data/projectQuery";
|
||||||
|
import { Suspense } from "react";
|
||||||
|
import { LegacyLoader } from "@/components/loading/LegacyLoader";
|
||||||
|
import { getUserRole } from "@/lib/data/userQuery";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import Link from "next/link";
|
||||||
|
import ProjectCardCalendarManageSection from "./ProjectCardSection";
|
||||||
|
|
||||||
|
export default async function ManageMeetingPage() {
|
||||||
|
const supabase = createSupabaseClient();
|
||||||
|
const { data: user, error: userError } = await supabase.auth.getUser();
|
||||||
|
|
||||||
|
if (userError) {
|
||||||
|
throw "Can't get user data!";
|
||||||
|
}
|
||||||
|
|
||||||
|
const userId = user.user?.id;
|
||||||
|
|
||||||
|
const { data: roleData, error: roleDataError } = await getUserRole(supabase, userId);
|
||||||
|
|
||||||
|
if (roleDataError) {
|
||||||
|
throw "Error fetching user data";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!roleData || roleData.role != "business") {
|
||||||
|
return (
|
||||||
|
<div className="container max-w-screen-xl">
|
||||||
|
<span className="flex gap-2 items-center mt-4">
|
||||||
|
<Clock />
|
||||||
|
<p className="text-2xl font-bold">Manage Meeting Request</p>
|
||||||
|
</span>
|
||||||
|
<Separator className="my-3" />
|
||||||
|
<div className="mb-3 mt-2">Please apply for business first to access functionalities of busienss account</div>
|
||||||
|
<Link href="/business/apply">
|
||||||
|
<Button>Apply for business</Button>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data: projectData, error: projectDataError } = await getProjectByUserId(supabase, userId);
|
||||||
|
|
||||||
|
if (projectDataError) {
|
||||||
|
throw "Can't get project data";
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container max-w-screen-xl">
|
||||||
|
<span className="flex gap-2 items-center mt-4">
|
||||||
|
<Clock />
|
||||||
|
<p className="text-2xl font-bold">Manage Meeting Request</p>
|
||||||
|
</span>
|
||||||
|
<Separator className="my-3" />
|
||||||
|
<Suspense fallback={<LegacyLoader />}>
|
||||||
|
<ProjectCardCalendarManageSection projectData={projectData} />
|
||||||
|
</Suspense>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
36
src/app/calendar/overlapEvent.ts
Normal file
36
src/app/calendar/overlapEvent.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { CalendarDate, getLocalTimeZone } from "@internationalized/date";
|
||||||
|
import { TimeValue } from "@react-types/datepicker";
|
||||||
|
|
||||||
|
export function isEventOverlapping(
|
||||||
|
eventDate: CalendarDate,
|
||||||
|
startTime: TimeValue,
|
||||||
|
endTime: TimeValue,
|
||||||
|
existingEvents: { meet_date: string; start_time: string; end_time: string }[]
|
||||||
|
): boolean {
|
||||||
|
const timezone = getLocalTimeZone();
|
||||||
|
|
||||||
|
const newStartDate = eventDate.toDate(timezone);
|
||||||
|
newStartDate.setHours(startTime.hour, startTime.minute);
|
||||||
|
|
||||||
|
const newEndDate = eventDate.toDate(timezone);
|
||||||
|
newEndDate.setHours(endTime.hour, endTime.minute);
|
||||||
|
|
||||||
|
for (const log of existingEvents) {
|
||||||
|
const [year, month, day] = log.meet_date.split("-").map(Number);
|
||||||
|
const existingStartDate = new Date(year, month - 1, day);
|
||||||
|
existingStartDate.setHours(parseInt(log.start_time.split(":")[0]), parseInt(log.start_time.split(":")[1]));
|
||||||
|
|
||||||
|
const existingEndDate = new Date(year, month - 1, day);
|
||||||
|
existingEndDate.setHours(parseInt(log.end_time.split(":")[0]), parseInt(log.end_time.split(":")[1]));
|
||||||
|
|
||||||
|
const isOverlapping =
|
||||||
|
(newStartDate < existingEndDate && newEndDate > existingStartDate) ||
|
||||||
|
(existingStartDate < newEndDate && existingEndDate > newStartDate);
|
||||||
|
|
||||||
|
if (isOverlapping) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@ -37,6 +37,7 @@ const DatetimePickerHourCycle = () => {
|
|||||||
const supabase = createSupabaseClient();
|
const supabase = createSupabaseClient();
|
||||||
const [showModal, setShowModal] = useState<boolean>(false);
|
const [showModal, setShowModal] = useState<boolean>(false);
|
||||||
const [currentProjectName, setCurrentProjectName] = useState<string>("");
|
const [currentProjectName, setCurrentProjectName] = useState<string>("");
|
||||||
|
const [currentProjectId, setCurrentProjectId] = useState<number | undefined>(undefined);
|
||||||
const { session, loading } = useSession();
|
const { session, loading } = useSession();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -125,7 +126,8 @@ const DatetimePickerHourCycle = () => {
|
|||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCurrentProjectName(projectInvestments[0].project_name);
|
setCurrentProjectName(projectInvestments[0].project_name);
|
||||||
setShowModal(true);
|
setCurrentProjectId(projectInvestments[0].project_id);
|
||||||
|
setTimeout(() => setShowModal(true), 0);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Schedule Meeting
|
Schedule Meeting
|
||||||
@ -136,9 +138,16 @@ const DatetimePickerHourCycle = () => {
|
|||||||
</div>
|
</div>
|
||||||
<MeetEventDialog
|
<MeetEventDialog
|
||||||
open={showModal}
|
open={showModal}
|
||||||
onOpenChange={setShowModal}
|
onOpenChange={(open) => {
|
||||||
|
setShowModal(open);
|
||||||
|
if (!open) {
|
||||||
|
setCurrentProjectId(undefined);
|
||||||
|
setCurrentProjectName("");
|
||||||
|
}
|
||||||
|
}}
|
||||||
session={session}
|
session={session}
|
||||||
projectName={currentProjectName}
|
projectName={currentProjectName}
|
||||||
|
projectId={currentProjectId!}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import Image from "next/image";
|
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { Overview } from "@/components/ui/overview";
|
import { Overview } from "@/components/ui/overview";
|
||||||
@ -16,6 +15,7 @@ import { overAllGraphData, fourYearGraphData, dayOftheWeekData } from "../portfo
|
|||||||
import CountUp from "react-countup";
|
import CountUp from "react-countup";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
import { Modal } from "@/components/modal";
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
const supabase = createSupabaseClient();
|
const supabase = createSupabaseClient();
|
||||||
@ -23,7 +23,13 @@ export default function Dashboard() {
|
|||||||
const { session, loading: isLoadingSession } = useSession();
|
const { session, loading: isLoadingSession } = useSession();
|
||||||
const userId = session?.user.id;
|
const userId = session?.user.id;
|
||||||
const [projects, setProjects] = useState<
|
const [projects, setProjects] = useState<
|
||||||
{ id: number; project_name: string; business_id: { user_id: number }[]; dataroom_id: number }[]
|
{
|
||||||
|
id: number;
|
||||||
|
project_name: string;
|
||||||
|
project_short_description: string;
|
||||||
|
business_id: { user_id: string };
|
||||||
|
dataroom_id: number | null;
|
||||||
|
}[]
|
||||||
>([]);
|
>([]);
|
||||||
const [latestInvestment, setLatestInvestment] = useState<
|
const [latestInvestment, setLatestInvestment] = useState<
|
||||||
{
|
{
|
||||||
@ -50,17 +56,17 @@ export default function Dashboard() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
let graphData = [];
|
let graphData = [];
|
||||||
const filteredData = (investmentDetail?.data || []).filter((deal) => deal.project_id === currentProjectId);
|
const filteredProject = (investmentDetail?.data || []).filter((deal) => deal.project_id === currentProjectId);
|
||||||
const handleTabChange = (tab: string) => {
|
const handleTabChange = (tab: string) => {
|
||||||
setActiveTab(tab);
|
setActiveTab(tab);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (activeTab === "daily") {
|
if (activeTab === "daily") {
|
||||||
graphData = dayOftheWeekData(filteredData);
|
graphData = dayOftheWeekData(filteredProject);
|
||||||
} else if (activeTab === "yearly") {
|
} else if (activeTab === "yearly") {
|
||||||
graphData = fourYearGraphData(filteredData);
|
graphData = fourYearGraphData(filteredProject);
|
||||||
} else {
|
} else {
|
||||||
graphData = overAllGraphData(filteredData);
|
graphData = overAllGraphData(filteredProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -116,23 +122,6 @@ export default function Dashboard() {
|
|||||||
return (
|
return (
|
||||||
<div className="container max-w-screen-xl">
|
<div className="container max-w-screen-xl">
|
||||||
<Loader isSuccess={!isLoadingSession && !isLoadingProjects} />{" "}
|
<Loader isSuccess={!isLoadingSession && !isLoadingProjects} />{" "}
|
||||||
<div className="md:hidden">
|
|
||||||
<Image
|
|
||||||
src="/examples/dashboard-light.png"
|
|
||||||
width={1280}
|
|
||||||
height={866}
|
|
||||||
alt="Dashboard"
|
|
||||||
className="block dark:hidden"
|
|
||||||
/>
|
|
||||||
<Image
|
|
||||||
src="/examples/dashboard-dark.png"
|
|
||||||
width={1280}
|
|
||||||
height={866}
|
|
||||||
alt="Dashboard"
|
|
||||||
className="hidden dark:block"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="hidden flex-col md:flex">
|
|
||||||
<div className="flex-1 space-y-4 p-8 pt-6">
|
<div className="flex-1 space-y-4 p-8 pt-6">
|
||||||
<div className="flex items-center justify-between space-y-2">
|
<div className="flex items-center justify-between space-y-2">
|
||||||
<h2 className="text-3xl font-bold tracking-tight">Business Dashboard</h2>
|
<h2 className="text-3xl font-bold tracking-tight">Business Dashboard</h2>
|
||||||
@ -173,7 +162,7 @@ export default function Dashboard() {
|
|||||||
<div className="text-2xl font-bold">
|
<div className="text-2xl font-bold">
|
||||||
$
|
$
|
||||||
<CountUp
|
<CountUp
|
||||||
end={filteredData
|
end={filteredProject
|
||||||
.filter((project) => project.deal_status === "Completed")
|
.filter((project) => project.deal_status === "Completed")
|
||||||
.reduce((sum, current) => sum + current.deal_amount, 0)}
|
.reduce((sum, current) => sum + current.deal_amount, 0)}
|
||||||
duration={1}
|
duration={1}
|
||||||
@ -278,11 +267,11 @@ export default function Dashboard() {
|
|||||||
</CardContent>
|
</CardContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Card>
|
</Card>
|
||||||
<Card className="col-span-3">
|
<Card className="col-span-4 md:col-span-3">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>Recent Funds</CardTitle>
|
<CardTitle>Recent Funds</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent className="grid grid-flow-dense w-full">
|
||||||
<RecentFunds
|
<RecentFunds
|
||||||
data={latestInvestment.map((item) => {
|
data={latestInvestment.map((item) => {
|
||||||
return {
|
return {
|
||||||
@ -295,6 +284,22 @@ export default function Dashboard() {
|
|||||||
};
|
};
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
<div className="flex justify-center mt-5">
|
||||||
|
{filteredProject && filteredProject.length > 1 ? (
|
||||||
|
<Modal
|
||||||
|
data={filteredProject.map((item) => {
|
||||||
|
return {
|
||||||
|
date: item.created_time,
|
||||||
|
name: item.username,
|
||||||
|
amount: item.deal_amount,
|
||||||
|
status: item.deal_status,
|
||||||
|
logoURL: Array.isArray(item.avatar_url) ? item.avatar_url[0] : item.avatar_url,
|
||||||
|
profileURL: `/profile/${item.investor_id}`,
|
||||||
|
};
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
) : undefined}
|
||||||
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
@ -304,6 +309,5 @@ export default function Dashboard() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import type { Metadata } from "next";
|
import type { Metadata, Viewport } from "next";
|
||||||
import { Montserrat } from "next/font/google";
|
import { Montserrat } from "next/font/google";
|
||||||
import { ThemeProvider } from "@/components/theme-provider";
|
import { ThemeProvider } from "@/components/theme-provider";
|
||||||
import { ReactQueryClientProvider } from "@/components/ReactQueryClientProvider";
|
import { ReactQueryClientProvider } from "@/components/ReactQueryClientProvider";
|
||||||
@ -22,6 +22,11 @@ export const metadata: Metadata = {
|
|||||||
description: "B2DVentures is a financial services company.",
|
description: "B2DVentures is a financial services company.",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const viewport: Viewport = {
|
||||||
|
initialScale: 1,
|
||||||
|
width: "device-width",
|
||||||
|
};
|
||||||
|
|
||||||
interface RootLayoutProps {
|
interface RootLayoutProps {
|
||||||
children: Readonly<React.ReactNode>;
|
children: Readonly<React.ReactNode>;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import { NoDataAlert } from "@/components/alert/noData/alert";
|
|||||||
import { error } from "console";
|
import { error } from "console";
|
||||||
import { UnAuthorizedAlert } from "@/components/alert/unauthorized/alert";
|
import { UnAuthorizedAlert } from "@/components/alert/unauthorized/alert";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { Modal } from "@/components/modal";
|
||||||
|
|
||||||
export default async function Portfolio({ params }: { params: { uid: string } }) {
|
export default async function Portfolio({ params }: { params: { uid: string } }) {
|
||||||
const supabase = createSupabaseClient();
|
const supabase = createSupabaseClient();
|
||||||
@ -53,6 +54,7 @@ export default async function Portfolio({ params }: { params: { uid: string } })
|
|||||||
if (investorDealError) {
|
if (investorDealError) {
|
||||||
console.error(investorDealError);
|
console.error(investorDealError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: localUser, error: localUserError } = await supabase.auth.getUser();
|
const { data: localUser, error: localUserError } = await supabase.auth.getUser();
|
||||||
if (localUserError) {
|
if (localUserError) {
|
||||||
console.error("Error while fetching user" + error);
|
console.error("Error while fetching user" + error);
|
||||||
@ -72,7 +74,16 @@ export default async function Portfolio({ params }: { params: { uid: string } })
|
|||||||
const tags = deals ? await getInvestorProjectTag(supabase, deals) : [];
|
const tags = deals ? await getInvestorProjectTag(supabase, deals) : [];
|
||||||
const latestDeals = deals
|
const latestDeals = deals
|
||||||
? await Promise.all(
|
? await Promise.all(
|
||||||
(await getLatestInvestment(supabase, deals)).map(async (deal) => ({
|
(
|
||||||
|
await getLatestInvestment(
|
||||||
|
supabase,
|
||||||
|
deals.map((deal) => ({
|
||||||
|
...deal,
|
||||||
|
status: deal.deal_status,
|
||||||
|
project_id: deal.project_id,
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
).map(async (deal) => ({
|
||||||
...deal,
|
...deal,
|
||||||
logo_url: await deal.logo_url,
|
logo_url: await deal.logo_url,
|
||||||
}))
|
}))
|
||||||
@ -96,7 +107,6 @@ export default async function Portfolio({ params }: { params: { uid: string } })
|
|||||||
<CountUpComponent end={totalInvestment} duration={1} />
|
<CountUpComponent end={totalInvestment} duration={1} />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flew-rows-3 gap-10 mt-5 w-full">
|
<div className="flex flew-rows-3 gap-10 mt-5 w-full">
|
||||||
<Tabs defaultValue="daily" className="space-y-4 w-full">
|
<Tabs defaultValue="daily" className="space-y-4 w-full">
|
||||||
<TabsList className="grid w-96 grid-cols-3">
|
<TabsList className="grid w-96 grid-cols-3">
|
||||||
@ -175,8 +185,8 @@ export default async function Portfolio({ params }: { params: { uid: string } })
|
|||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-cols-3 w-full gap-5 mt-5">
|
<div className="grid grid-cols-1 md:grid-cols-3 w-full gap-5 mt-5">
|
||||||
<Card className="w-1/3">
|
<Card className="w-full h-fit">
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||||
<CardTitle className="text-md font-bold">Categories of Invested Projects</CardTitle>
|
<CardTitle className="text-md font-bold">Categories of Invested Projects</CardTitle>
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
@ -201,7 +211,7 @@ export default async function Portfolio({ params }: { params: { uid: string } })
|
|||||||
/>
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
<Card className="w-1/3">
|
<Card className="w-full h-fit">
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||||
<CardTitle className="text-md font-bold">Types of Businesses Invested In</CardTitle>
|
<CardTitle className="text-md font-bold">Types of Businesses Invested In</CardTitle>
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
@ -226,12 +236,39 @@ export default async function Portfolio({ params }: { params: { uid: string } })
|
|||||||
/>
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
<Card className="w-1/3">
|
<Card className="w-full">
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||||
<CardTitle className="text-md font-bold">Recent investment</CardTitle>
|
<CardTitle className="text-md font-bold">Recent investment</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="mt-5">
|
<CardContent className="mt-5 grid grid-flow-row-dense">
|
||||||
<RecentFunds data={latestDeals} />
|
<RecentFunds
|
||||||
|
data={latestDeals.map((item) => {
|
||||||
|
return {
|
||||||
|
name: item.name,
|
||||||
|
amount: item.amount,
|
||||||
|
avatar: item.logo_url,
|
||||||
|
date: new Date(item.date),
|
||||||
|
status: item.status,
|
||||||
|
profile_url: `/deals/${item.projectId}`,
|
||||||
|
};
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<div className="mt-5 flex justify-center">
|
||||||
|
{deals && deals.length > 5 ? (
|
||||||
|
<Modal
|
||||||
|
data={deals.map((item) => {
|
||||||
|
return {
|
||||||
|
date: item.created_time,
|
||||||
|
name: item.project_name,
|
||||||
|
amount: item.deal_amount,
|
||||||
|
status: item.deal_status,
|
||||||
|
logoURL: Array.isArray(item.avatar_url) ? item.avatar_url[0] : item.avatar_url,
|
||||||
|
profileURL: `/deals/${item.project_id}`,
|
||||||
|
};
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
) : undefined}
|
||||||
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -26,7 +26,7 @@ function getTotalInvestment(deals: { deal_amount: number }[]) {
|
|||||||
}
|
}
|
||||||
async function getLatestInvestment(
|
async function getLatestInvestment(
|
||||||
supabase: SupabaseClient,
|
supabase: SupabaseClient,
|
||||||
deals: { project_id: number; deal_amount: number; created_time: Date;}[]
|
deals: { project_id: number; deal_amount: number; created_time: Date; status: string }[]
|
||||||
) {
|
) {
|
||||||
const llist = [];
|
const llist = [];
|
||||||
const count = 5;
|
const count = 5;
|
||||||
@ -43,6 +43,7 @@ async function getLatestInvestment(
|
|||||||
amount: deals[i].deal_amount,
|
amount: deals[i].deal_amount,
|
||||||
date: new Date(deals[i].created_time),
|
date: new Date(deals[i].created_time),
|
||||||
logo_url: url,
|
logo_url: url,
|
||||||
|
status: deals[i].status,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export function ProjectSection({ projectsData }: { projectsData: ProjectCardProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-4 gap-6">
|
<div className="grid grid-cols-1 sm:grid-cols-4 gap-6">
|
||||||
{projectsData.map((project) => (
|
{projectsData.map((project) => (
|
||||||
<div key={project.id}>
|
<div key={project.id}>
|
||||||
<Link href={`/deals/${project.id}`}>
|
<Link href={`/deals/${project.id}`}>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { useEffect, useState, useMemo } from "react";
|
import { useEffect, useState, useMemo, useCallback } from "react";
|
||||||
import { Carousel, CarouselContent, CarouselItem, type CarouselApi } from "./ui/carousel";
|
import { Carousel, CarouselContent, CarouselItem, type CarouselApi } from "./ui/carousel";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
|
||||||
@ -8,15 +8,40 @@ interface GalleryProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Gallery = ({ images }: GalleryProps) => {
|
const Gallery = ({ images }: GalleryProps) => {
|
||||||
const [mainApi, setMainApi] = useState<CarouselApi>();
|
const [mainApi, setMainApi] = useState<CarouselApi | null>(null);
|
||||||
const [thumbnailApi, setThumbnailApi] = useState<CarouselApi>();
|
const [thumbnailApi, setThumbnailApi] = useState<CarouselApi | null>(null);
|
||||||
const [current, setCurrent] = useState(0);
|
const [current, setCurrent] = useState(0);
|
||||||
|
const [isReady, setIsReady] = useState(false);
|
||||||
|
|
||||||
|
const syncCarousels = useCallback(
|
||||||
|
(index: number) => {
|
||||||
|
if (mainApi && thumbnailApi) {
|
||||||
|
setCurrent(index);
|
||||||
|
mainApi.scrollTo(index);
|
||||||
|
thumbnailApi.scrollTo(index);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[mainApi, thumbnailApi]
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleClick = useCallback(
|
||||||
|
(index: number) => {
|
||||||
|
syncCarousels(index);
|
||||||
|
},
|
||||||
|
[syncCarousels]
|
||||||
|
);
|
||||||
|
|
||||||
const mainImage = useMemo(
|
const mainImage = useMemo(
|
||||||
() =>
|
() =>
|
||||||
images.map((image, index) => (
|
images.map((image, index) => (
|
||||||
<CarouselItem key={index} className="relative aspect-video w-full border-8 border-b">
|
<CarouselItem key={index} className="relative aspect-video w-full border-8 border-b">
|
||||||
<Image src={image.src} alt={`Carousel Main Image ${index + 1}`} fill style={{ objectFit: "contain" }} />
|
<Image
|
||||||
|
src={image.src}
|
||||||
|
alt={`Carousel Main Image ${index + 1}`}
|
||||||
|
fill
|
||||||
|
style={{ objectFit: "contain" }}
|
||||||
|
priority={index === 0}
|
||||||
|
/>
|
||||||
</CarouselItem>
|
</CarouselItem>
|
||||||
)),
|
)),
|
||||||
[images]
|
[images]
|
||||||
@ -25,61 +50,60 @@ const Gallery = ({ images }: GalleryProps) => {
|
|||||||
const thumbnailImages = useMemo(
|
const thumbnailImages = useMemo(
|
||||||
() =>
|
() =>
|
||||||
images.map((image, index) => (
|
images.map((image, index) => (
|
||||||
<CarouselItem key={index} className="relative aspect-square basis-1/4" onClick={() => handleClick(index)}>
|
<CarouselItem
|
||||||
|
key={index}
|
||||||
|
className="relative aspect-square basis-1/4 cursor-pointer"
|
||||||
|
onClick={() => handleClick(index)}
|
||||||
|
>
|
||||||
<Image
|
<Image
|
||||||
className={`${index === current ? "border-2" : ""}`}
|
className={`transition-all duration-200 ${index === current ? "border-2 border-primary" : ""}`}
|
||||||
src={image.src}
|
src={image.src}
|
||||||
fill
|
fill
|
||||||
alt={`Carousel Thumbnail Image ${index + 1}`}
|
alt={`Carousel Thumbnail Image ${index + 1}`}
|
||||||
style={{ objectFit: "contain" }}
|
style={{ objectFit: "contain" }}
|
||||||
|
priority={index === 0}
|
||||||
/>
|
/>
|
||||||
</CarouselItem>
|
</CarouselItem>
|
||||||
)),
|
)),
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
[images, current, handleClick]
|
||||||
[images, current]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mainApi || !thumbnailApi) {
|
if (!mainApi || !thumbnailApi) return;
|
||||||
return;
|
if (isReady) return;
|
||||||
}
|
|
||||||
|
|
||||||
const handleTopSelect = () => {
|
const handleMainSelect = () => {
|
||||||
const selected = mainApi.selectedScrollSnap();
|
const selected = mainApi.selectedScrollSnap();
|
||||||
setCurrent(selected);
|
if (selected !== current) {
|
||||||
thumbnailApi.scrollTo(selected);
|
syncCarousels(selected);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBottomSelect = () => {
|
const handleThumbnailSelect = () => {
|
||||||
const selected = thumbnailApi.selectedScrollSnap();
|
const selected = thumbnailApi.selectedScrollSnap();
|
||||||
setCurrent(selected);
|
if (selected !== current) {
|
||||||
mainApi.scrollTo(selected);
|
syncCarousels(selected);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mainApi.on("select", handleTopSelect);
|
mainApi.on("select", handleMainSelect);
|
||||||
thumbnailApi.on("select", handleBottomSelect);
|
thumbnailApi.on("select", handleThumbnailSelect);
|
||||||
|
|
||||||
|
syncCarousels(0);
|
||||||
|
setIsReady(true);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
mainApi.off("select", handleTopSelect);
|
mainApi.off("select", handleMainSelect);
|
||||||
thumbnailApi.off("select", handleBottomSelect);
|
thumbnailApi.off("select", handleThumbnailSelect);
|
||||||
};
|
|
||||||
}, [mainApi, thumbnailApi]);
|
|
||||||
|
|
||||||
const handleClick = (index: number) => {
|
|
||||||
if (!mainApi || !thumbnailApi) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
thumbnailApi.scrollTo(index);
|
|
||||||
mainApi.scrollTo(index);
|
|
||||||
setCurrent(index);
|
|
||||||
};
|
};
|
||||||
|
}, [mainApi, thumbnailApi, current, syncCarousels, isReady]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full max-w-xl sm:w-auto">
|
<div className="w-full max-w-xl sm:w-auto">
|
||||||
<Carousel setApi={setMainApi}>
|
<Carousel setApi={setMainApi} className="mb-2">
|
||||||
<CarouselContent className="m-1">{mainImage}</CarouselContent>
|
<CarouselContent className="m-1">{mainImage}</CarouselContent>
|
||||||
</Carousel>
|
</Carousel>
|
||||||
<Carousel setApi={setThumbnailApi}>
|
<Carousel setApi={setThumbnailApi} className="cursor-pointer">
|
||||||
<CarouselContent className="m-1 h-16">{thumbnailImages}</CarouselContent>
|
<CarouselContent className="m-1 h-16">{thumbnailImages}</CarouselContent>
|
||||||
</Carousel>
|
</Carousel>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
293
src/components/dataTable.tsx
Normal file
293
src/components/dataTable.tsx
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import * as React from "react";
|
||||||
|
import {
|
||||||
|
ColumnDef,
|
||||||
|
ColumnFiltersState,
|
||||||
|
SortingState,
|
||||||
|
VisibilityState,
|
||||||
|
flexRender,
|
||||||
|
getCoreRowModel,
|
||||||
|
getFilteredRowModel,
|
||||||
|
getPaginationRowModel,
|
||||||
|
getSortedRowModel,
|
||||||
|
useReactTable,
|
||||||
|
} from "@tanstack/react-table";
|
||||||
|
import { ArrowUpDown, ChevronDown } from "lucide-react";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuCheckboxItem,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from "@/components/ui/dropdown-menu";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||||
|
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||||
|
|
||||||
|
export type ModalProps = {
|
||||||
|
date: Date;
|
||||||
|
amount: number;
|
||||||
|
name: string;
|
||||||
|
investorId?: string;
|
||||||
|
profileURL?: string;
|
||||||
|
logoURL?: string;
|
||||||
|
status?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const columns: ColumnDef<ModalProps>[] = [
|
||||||
|
{
|
||||||
|
id: "select",
|
||||||
|
header: ({ table }) => (
|
||||||
|
<Checkbox
|
||||||
|
checked={table.getIsAllPageRowsSelected() || (table.getIsSomePageRowsSelected() && "indeterminate")}
|
||||||
|
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
|
||||||
|
aria-label="Select all"
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<Checkbox
|
||||||
|
checked={row.getIsSelected()}
|
||||||
|
onCheckedChange={(value) => row.toggleSelected(!!value)}
|
||||||
|
aria-label="Select row"
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
enableSorting: false,
|
||||||
|
enableHiding: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "name",
|
||||||
|
header: ({ column }) => {
|
||||||
|
return (
|
||||||
|
<Button variant="ghost" onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}>
|
||||||
|
Name
|
||||||
|
<ArrowUpDown />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Button
|
||||||
|
className="bg-transparent hover:bg-transparent text-current"
|
||||||
|
onClick={() => {
|
||||||
|
window.location.href = row.getValue("profileURL");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Avatar className="h-9 w-9">
|
||||||
|
<AvatarImage src={row.getValue("logoURL")} />
|
||||||
|
<AvatarFallback>{(row.getValue("name") as string).slice(0, 2)}</AvatarFallback>
|
||||||
|
</Avatar>
|
||||||
|
<span className="ml-2">{row.getValue("name")}</span>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "date",
|
||||||
|
header: () => <div className="text-left">Date</div>,
|
||||||
|
cell: ({ row }) => {
|
||||||
|
const formatted = new Date(row.getValue("date")).toUTCString();
|
||||||
|
return <div className=" font-medium">{formatted}</div>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "status",
|
||||||
|
header: "Status",
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className="flex items-center space-x-1">
|
||||||
|
<span className="relative flex h-3 w-3">
|
||||||
|
<span
|
||||||
|
className={`animate-ping absolute inline-flex h-3 w-3 rounded-full opacity-75 ${
|
||||||
|
row.getValue("status") === "In Progress"
|
||||||
|
? "bg-sky-400"
|
||||||
|
: row.getValue("status") === "Completed"
|
||||||
|
? "bg-green-400"
|
||||||
|
: "bg-yellow-400"
|
||||||
|
}`}
|
||||||
|
></span>
|
||||||
|
<span
|
||||||
|
className={`relative inline-flex rounded-full h-2 w-2 mt-[2px] ml-0.5 ${
|
||||||
|
row.getValue("status") === "In Progress"
|
||||||
|
? "bg-sky-500"
|
||||||
|
: row.getValue("status") === "Completed"
|
||||||
|
? "bg-green-500"
|
||||||
|
: "bg-yellow-500"
|
||||||
|
}`}
|
||||||
|
></span>
|
||||||
|
</span>
|
||||||
|
<p
|
||||||
|
className={`text-xs m-0 ${
|
||||||
|
row.getValue("status") === "In Progress"
|
||||||
|
? "text-sky-500"
|
||||||
|
: row.getValue("status") === "Completed"
|
||||||
|
? "text-green-500"
|
||||||
|
: "text-yellow-500"
|
||||||
|
}`}
|
||||||
|
></p>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={`capitalize ${
|
||||||
|
row.getValue("status") === "In Progress"
|
||||||
|
? "text-sky-500"
|
||||||
|
: row.getValue("status") === "Completed"
|
||||||
|
? "text-green-500"
|
||||||
|
: "text-yellow-500"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{row.getValue("status")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "amount",
|
||||||
|
header: () => <div className="text-right">Amount</div>,
|
||||||
|
cell: ({ row }) => {
|
||||||
|
const amount = parseFloat(row.getValue("amount"));
|
||||||
|
|
||||||
|
// Format the amount as a dollar amount
|
||||||
|
const formatted = new Intl.NumberFormat("en-US", {
|
||||||
|
style: "currency",
|
||||||
|
currency: "USD",
|
||||||
|
}).format(amount);
|
||||||
|
|
||||||
|
return <div className="text-right font-medium">{formatted}</div>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "logoURL",
|
||||||
|
id: "logoURL",
|
||||||
|
header: () => null,
|
||||||
|
cell: () => null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "profileURL",
|
||||||
|
id: "profileURL",
|
||||||
|
header: () => null,
|
||||||
|
cell: () => null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function DataTable({ data }: { data: ModalProps[] }) {
|
||||||
|
const [sorting, setSorting] = React.useState<SortingState>([]);
|
||||||
|
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>([]);
|
||||||
|
const [columnVisibility, setColumnVisibility] = React.useState<VisibilityState>({});
|
||||||
|
const [rowSelection, setRowSelection] = React.useState({});
|
||||||
|
const [pagination, setPagination] = React.useState({
|
||||||
|
pageIndex: 0,
|
||||||
|
pageSize: 5,
|
||||||
|
});
|
||||||
|
|
||||||
|
const table = useReactTable({
|
||||||
|
data,
|
||||||
|
columns,
|
||||||
|
onSortingChange: setSorting,
|
||||||
|
onColumnFiltersChange: setColumnFilters,
|
||||||
|
getCoreRowModel: getCoreRowModel(),
|
||||||
|
getPaginationRowModel: getPaginationRowModel(),
|
||||||
|
getSortedRowModel: getSortedRowModel(),
|
||||||
|
getFilteredRowModel: getFilteredRowModel(),
|
||||||
|
onColumnVisibilityChange: setColumnVisibility,
|
||||||
|
onPaginationChange: setPagination,
|
||||||
|
onRowSelectionChange: setRowSelection,
|
||||||
|
state: {
|
||||||
|
sorting,
|
||||||
|
columnFilters,
|
||||||
|
columnVisibility,
|
||||||
|
rowSelection,
|
||||||
|
pagination,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-3/4 md:w-full">
|
||||||
|
<div className="flex items-center py-4">
|
||||||
|
<Input
|
||||||
|
placeholder="Filter names..."
|
||||||
|
value={(table.getColumn("name")?.getFilterValue() as string) ?? ""}
|
||||||
|
onChange={(event) => table.getColumn("name")?.setFilterValue(event.target.value)}
|
||||||
|
className="max-w-sm"
|
||||||
|
/>
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button variant="outline" className="ml-auto">
|
||||||
|
Columns <ChevronDown />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="end">
|
||||||
|
{table
|
||||||
|
.getAllColumns()
|
||||||
|
.filter((column) => column.getCanHide() && column.id != "logoURL" && column.id != "profileURL")
|
||||||
|
.map((column) => {
|
||||||
|
return (
|
||||||
|
<DropdownMenuCheckboxItem
|
||||||
|
key={column.id}
|
||||||
|
className="capitalize"
|
||||||
|
checked={column.getIsVisible()}
|
||||||
|
onCheckedChange={(value) => column.toggleVisibility(!!value)}
|
||||||
|
>
|
||||||
|
{column.id}
|
||||||
|
</DropdownMenuCheckboxItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
|
<div className="rounded-md border">
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
|
<TableRow key={headerGroup.id}>
|
||||||
|
{headerGroup.headers.map((header) => {
|
||||||
|
return (
|
||||||
|
<TableHead key={header.id}>
|
||||||
|
{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
|
||||||
|
</TableHead>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{table.getRowModel().rows?.length ? (
|
||||||
|
table.getRowModel().rows.map((row) => (
|
||||||
|
<TableRow key={row.id} data-state={row.getIsSelected() && "selected"}>
|
||||||
|
{row.getVisibleCells().map((cell) => (
|
||||||
|
<TableCell key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</TableCell>
|
||||||
|
))}
|
||||||
|
</TableRow>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={columns.length} className="h-24 text-center">
|
||||||
|
No results.
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center justify-end space-x-2 py-4">
|
||||||
|
<div className="flex-1 text-sm text-muted-foreground">
|
||||||
|
{table.getFilteredSelectedRowModel().rows.length} of {table.getFilteredRowModel().rows.length} row(s)
|
||||||
|
selected.
|
||||||
|
</div>
|
||||||
|
<div className="space-x-2">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => table.previousPage()}
|
||||||
|
disabled={!table.getCanPreviousPage()}
|
||||||
|
>
|
||||||
|
Previous
|
||||||
|
</Button>
|
||||||
|
<Button variant="outline" size="sm" onClick={() => table.nextPage()} disabled={!table.getCanNextPage()}>
|
||||||
|
Next
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
27
src/components/mobileMenu.tsx
Normal file
27
src/components/mobileMenu.tsx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
"use client";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Menu, X } from "lucide-react";
|
||||||
|
import { Button } from "./ui/button";
|
||||||
|
import { motion } from "framer-motion";
|
||||||
|
|
||||||
|
export function MobileMenu() {
|
||||||
|
const [isVisible, setIsVisible] = useState(false);
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Button onClick={() => setIsVisible((prev) => !prev)}>
|
||||||
|
<Menu />
|
||||||
|
</Button>
|
||||||
|
{isVisible && (
|
||||||
|
<motion.div
|
||||||
|
initial={{ x: "-100%" }}
|
||||||
|
animate={{ x: 0 }}
|
||||||
|
exit={{ x: "-100%" }}
|
||||||
|
transition={{ duration: 0.3 }}
|
||||||
|
className="fixed top-0 left-0 w-full bg-gray-800 text-white"
|
||||||
|
>
|
||||||
|
<X className="cursor-pointer" onClick={() => setIsVisible(false)} />
|
||||||
|
</motion.div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
29
src/components/modal.tsx
Normal file
29
src/components/modal.tsx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
"use client";
|
||||||
|
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
|
||||||
|
import { Button } from "./ui/button";
|
||||||
|
import { DataTable } from "./dataTable";
|
||||||
|
|
||||||
|
export type ModalProps = {
|
||||||
|
date: Date;
|
||||||
|
amount: number;
|
||||||
|
name: string;
|
||||||
|
investorId?: string;
|
||||||
|
profileURL?: string;
|
||||||
|
logoURL?: string;
|
||||||
|
status?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function Modal({ data }: { data: ModalProps[] }) {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Dialog>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button>View More</Button>
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent className="max-w-screen-md md:max-w-screen-lg ">
|
||||||
|
<DataTable data={data} />
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -34,9 +34,12 @@ export const AuthenticatedComponents = ({ uid, avatarUrl, notificationCount }: A
|
|||||||
<div className="relative inline-block">
|
<div className="relative inline-block">
|
||||||
<Bell className="h-6 w-6 " />
|
<Bell className="h-6 w-6 " />
|
||||||
{notificationCount >= 1 && (
|
{notificationCount >= 1 && (
|
||||||
<span className="absolute -top-1 -right-1 inline-flex items-center justify-center w-4 h-4 text-xs font-bold text-white bg-red-600 rounded-full animate-ping">
|
<div>
|
||||||
|
<span className="absolute -top-1 -right-1 inline-flex items-center justify-center w-4 h-4 text-xs font-bold text-white bg-red-600 rounded-full animate-ping"></span>
|
||||||
|
<span className="absolute -top-1 -right-1 inline-flex items-center justify-center w-4 h-4 text-xs font-bold text-white bg-red-600 rounded-full ">
|
||||||
{notificationCount}
|
{notificationCount}
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@ -21,6 +21,8 @@ import { createSupabaseClient } from "@/lib/supabase/serverComponentClient";
|
|||||||
import { getUserId } from "@/lib/supabase/actions/getUserId";
|
import { getUserId } from "@/lib/supabase/actions/getUserId";
|
||||||
import { getUnreadNotificationCountByUserId } from "@/lib/data/notificationQuery";
|
import { getUnreadNotificationCountByUserId } from "@/lib/data/notificationQuery";
|
||||||
|
|
||||||
|
import { MobileMenu } from "../mobileMenu";
|
||||||
|
|
||||||
const ListItem = React.forwardRef<React.ElementRef<"a">, React.ComponentPropsWithoutRef<"a">>(
|
const ListItem = React.forwardRef<React.ElementRef<"a">, React.ComponentPropsWithoutRef<"a">>(
|
||||||
({ className, title, children, ...props }, ref) => {
|
({ className, title, children, ...props }, ref) => {
|
||||||
return (
|
return (
|
||||||
@ -97,8 +99,10 @@ export async function NavigationBar() {
|
|||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="md:hidden">
|
||||||
<div className="flex items-center">
|
<MobileMenu />
|
||||||
|
</div>
|
||||||
|
<div className="hidden md:flex items-center ">
|
||||||
<NavigationMenu>
|
<NavigationMenu>
|
||||||
<NavigationMenuList>
|
<NavigationMenuList>
|
||||||
<NavigationMenuItem>
|
<NavigationMenuItem>
|
||||||
@ -146,7 +150,7 @@ export async function NavigationBar() {
|
|||||||
</NavigationMenuList>
|
</NavigationMenuList>
|
||||||
</NavigationMenu>
|
</NavigationMenu>
|
||||||
|
|
||||||
<div className="flex gap-2 pl-2">
|
<div className="hidden md:flex gap-2 pl-2">
|
||||||
<div className="mt-1">
|
<div className="mt-1">
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -115,14 +115,16 @@ const Carousel = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivEl
|
|||||||
scrollNext,
|
scrollNext,
|
||||||
canScrollPrev,
|
canScrollPrev,
|
||||||
canScrollNext,
|
canScrollNext,
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
onKeyDownCapture={handleKeyDown}
|
onKeyDownCapture={handleKeyDown}
|
||||||
className={cn("relative", className)}
|
className={cn("relative", className)}
|
||||||
role="region"
|
role="region"
|
||||||
aria-roledescription="carousel"
|
aria-roledescription="carousel"
|
||||||
{...props}>
|
{...props}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</CarouselContext.Provider>
|
</CarouselContext.Provider>
|
||||||
@ -183,7 +185,8 @@ const CarouselPrevious = React.forwardRef<HTMLButtonElement, React.ComponentProp
|
|||||||
)}
|
)}
|
||||||
disabled={!canScrollPrev}
|
disabled={!canScrollPrev}
|
||||||
onClick={scrollPrev}
|
onClick={scrollPrev}
|
||||||
{...props}>
|
{...props}
|
||||||
|
>
|
||||||
<ArrowLeft className="h-4 w-4" />
|
<ArrowLeft className="h-4 w-4" />
|
||||||
<span className="sr-only">Previous slide</span>
|
<span className="sr-only">Previous slide</span>
|
||||||
</Button>
|
</Button>
|
||||||
@ -210,7 +213,8 @@ const CarouselNext = React.forwardRef<HTMLButtonElement, React.ComponentProps<ty
|
|||||||
)}
|
)}
|
||||||
disabled={!canScrollNext}
|
disabled={!canScrollNext}
|
||||||
onClick={scrollNext}
|
onClick={scrollNext}
|
||||||
{...props}>
|
{...props}
|
||||||
|
>
|
||||||
<ArrowRight className="h-4 w-4" />
|
<ArrowRight className="h-4 w-4" />
|
||||||
<span className="sr-only">Next slide</span>
|
<span className="sr-only">Next slide</span>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -20,6 +20,9 @@ export const getInvestmentByProjectsIds = (client: SupabaseClient, projectIds: s
|
|||||||
deal_status:value
|
deal_status:value
|
||||||
),
|
),
|
||||||
project_id,
|
project_id,
|
||||||
|
...project_id (
|
||||||
|
project_name
|
||||||
|
),
|
||||||
deal_amount,
|
deal_amount,
|
||||||
created_time,
|
created_time,
|
||||||
...profiles (
|
...profiles (
|
||||||
@ -56,7 +59,25 @@ export const getInvestmentByUserId = (client: SupabaseClient, userId: string) =>
|
|||||||
export function getInvestorDeal(client: SupabaseClient, userId: string) {
|
export function getInvestorDeal(client: SupabaseClient, userId: string) {
|
||||||
return client
|
return client
|
||||||
.from("investment_deal")
|
.from("investment_deal")
|
||||||
.select("*")
|
.select(
|
||||||
|
`
|
||||||
|
id,
|
||||||
|
...deal_status_id(
|
||||||
|
deal_status:value
|
||||||
|
),
|
||||||
|
project_id,
|
||||||
|
...project_id (
|
||||||
|
project_name
|
||||||
|
),
|
||||||
|
deal_amount,
|
||||||
|
created_time,
|
||||||
|
...profiles (
|
||||||
|
investor_id:id,
|
||||||
|
username,
|
||||||
|
avatar_url
|
||||||
|
)
|
||||||
|
`
|
||||||
|
)
|
||||||
.in("investor_id", [userId])
|
.in("investor_id", [userId])
|
||||||
.order("created_time", { ascending: true });
|
.order("created_time", { ascending: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { SupabaseClient } from "@supabase/supabase-js";
|
import { SupabaseClient } from "@supabase/supabase-js";
|
||||||
import { ProjectCardProps } from "@/types/ProjectCard";
|
import { ProjectCardProps } from "@/types/ProjectCard";
|
||||||
|
import { Database } from "@/types/database.types";
|
||||||
|
|
||||||
async function getTopProjects(client: SupabaseClient, numberOfRecords: number = 4) {
|
async function getTopProjects(client: SupabaseClient, numberOfRecords: number = 4) {
|
||||||
try {
|
try {
|
||||||
@ -205,7 +206,7 @@ const getProjectByBusinessId = (client: SupabaseClient, businessIds: string[]) =
|
|||||||
.in("business_id", businessIds);
|
.in("business_id", businessIds);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getProjectByUserId = (client: SupabaseClient, userId: string) => {
|
const getProjectByUserId = (client: SupabaseClient<Database>, userId: string) => {
|
||||||
return client
|
return client
|
||||||
.from("project")
|
.from("project")
|
||||||
.select(
|
.select(
|
||||||
|
|||||||
Binary file not shown.
@ -1,12 +1,14 @@
|
|||||||
|
import {nextui} from '@nextui-org/theme';
|
||||||
import type { Config } from "tailwindcss"
|
import type { Config } from "tailwindcss"
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
darkMode: ["class"],
|
darkMode: ["class"],
|
||||||
content: [
|
content: [
|
||||||
'./pages/**/*.{ts,tsx}',
|
"./pages/**/*.{ts,tsx}",
|
||||||
'./components/**/*.{ts,tsx}',
|
"./components/**/*.{ts,tsx}",
|
||||||
'./app/**/*.{ts,tsx}',
|
"./app/**/*.{ts,tsx}",
|
||||||
'./src/**/*.{ts,tsx}',
|
"./src/**/*.{ts,tsx}",
|
||||||
|
"./node_modules/@nextui-org/theme/dist/components/(calendar|date-input|button|ripple|spinner).js"
|
||||||
],
|
],
|
||||||
prefix: "",
|
prefix: "",
|
||||||
theme: {
|
theme: {
|
||||||
@ -74,7 +76,7 @@ const config = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [require("tailwindcss-animate"), require('@tailwindcss/typography'),],
|
plugins: [require('tailwindcss-animate'),require('@tailwindcss/typography'),nextui()],
|
||||||
} satisfies Config
|
} satisfies Config
|
||||||
|
|
||||||
export default config
|
export default config
|
||||||
Loading…
Reference in New Issue
Block a user