Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create waitlist page for superadmin user - team starlight #872

Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import clsx from "clsx";
import { EllipsisVertical } from "lucide-react";
import { useState } from "react";

import { Button } from "~/components/ui/button";
import { Checkbox } from "~/components/ui/checkbox";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuTrigger,
} from "~/components/ui/dropdown-menu";
import { Switch } from "~/components/ui/switch";
import { waitListData } from "../data/waitlist-dummy";
import DeleteDialog from "./waitListModal";

const tableHeadData: string[] = [
"name",
"email",
"status",
"activate",
"created at",
"action",
];
const WaitListPage = () => {
const [isDialogOpen, setIsDialogOpen] = useState(false);
const handleOpenDialog = () => setIsDialogOpen(true);
const handleCloseDialog = () => setIsDialogOpen(false);

return (
<>
<thead>
<tr className="bg-[#FFF7F2]">
{tableHeadData.map((data, index) => {
return (
<th
key={index}
className={`whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2 ${data === "name" ? "w-[300px]" : data === "action" ? "w-[86px]" : "w-[202px]"}`}
>
{data}
</th>
);
})}
</tr>
</thead>
<tbody className="user-table z-10">
{waitListData.map((data, index) => {
const { activate, createdDate, pageTitle, status, urlSlug } = data;

return (
<tr key={index} className="w-full border-b border-b-border">
<td
className={`whitespace-nowrap p-4 text-left text-base font-normal capitalize leading-4 text-neutral-dark-2`}
>
<div className="flex flex-row items-center gap-2">
<Checkbox className="border-2 border-gray-300 data-[state=checked]:border-primary data-[state=checked]:bg-primary" />

<div>
<h3 className="text-sm font-[500] leading-6 text-neutral-dark-2">
{pageTitle}
</h3>
<div className="text-xs font-normal lowercase leading-4 text-neutral-dark-1"></div>
</div>
</div>
</td>

<td>
<div className="whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2">
{urlSlug}
</div>
</td>

<td
className={`whitespace-nowrap p-4 text-left text-sm font-normal leading-4 text-neutral-dark-2`}
>
<div
className={clsx(
status === "active"
? "border-lime-500 text-lime-500"
: "border-black text-black",
"inline-flex h-[27px] w-[85px] items-center justify-center gap-2.5 rounded-[80px] border",
)}
>
<span className="text-xs">{status}</span>
</div>
</td>

<td
className={`whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2`}
>
<Switch
className="scale-[0.75] transform"
defaultChecked={activate}
/>
</td>
<td
className={`gap-2 whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2`}
>
{createdDate}
</td>

<td className="whitespace-nowrap p-4 text-center text-base font-normal capitalize leading-4 text-neutral-dark-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
className="bg-transparent text-neutral-dark-2 hover:bg-transparent focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0"
size={"icon"}
>
<EllipsisVertical size={16} color="#09090b" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel className="sr-only">
Actions
</DropdownMenuLabel>
<DropdownMenuItem>Edit</DropdownMenuItem>
<DropdownMenuItem onClick={handleOpenDialog}>
Delete
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</td>
</tr>
);
})}
</tbody>
{isDialogOpen && <DeleteDialog onClose={handleCloseDialog} />}
</>
);
};

export default WaitListPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Button } from "~/components/common/common-button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "~/components/ui/dialog";

const DeleteDialog = ({ onClose }: { onClose: () => void }) => {
return (
<Dialog open onOpenChange={onClose}>
<DialogContent>
<DialogHeader>
<DialogTitle className="text-lg font-semibold leading-7 text-slate-900">
Are you absolutely sure?
</DialogTitle>
<DialogDescription className="text-sm font-normal leading-tight text-slate-500">
This action cannot be undone. This will permanently delete this
product from the database.
</DialogDescription>
</DialogHeader>
<div className="flex w-full">
<Button
variant="outline"
className="ml-auto flex items-center justify-center gap-2.5 rounded-md px-4 py-2 text-sm font-medium leading-normal"
onClick={onClose}
>
Cancel
</Button>
<Button
onClick={onClose}
className="ml-2 flex items-center justify-center gap-2.5 rounded-md bg-red-600 px-4 py-2 text-sm font-medium leading-normal text-white"
>
Delete
</Button>
</div>
</DialogContent>
</Dialog>
);
};

export default DeleteDialog;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import WaitListTableBody from "./waitListTableBody";
import WaitListTableHead from "./waitListTableHead";

const WaitListTable = () => {
return (
<>
<table className="user-table z-10 h-full w-full overflow-hidden">
<WaitListTableHead />
<WaitListTableBody />
</table>
</>
);
};

export default WaitListTable;
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import clsx from "clsx";
import { EllipsisVertical } from "lucide-react";
import { useState } from "react";

import { Button } from "~/components/ui/button";
import { Checkbox } from "~/components/ui/checkbox";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuTrigger,
} from "~/components/ui/dropdown-menu";
import { dummyUsers } from "../data/waitlist-dummy";
import DeleteDialog from "./waitListModal";

const WaitListTableBody = () => {
const [isDialogOpen, setIsDialogOpen] = useState(false);
const handleOpenDialog = () => setIsDialogOpen(true);
const handleCloseDialog = () => setIsDialogOpen(false);

return (
<>
<tbody className="user-table z-10">
{dummyUsers.map((data, index) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

allow 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

backend no gree send endpoint........so i was like i will push this first when the endpoint is ready i willl update it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure brother. my backend are on it

const { name, date, email, notes, status } = data;

return (
<tr key={index} className="w-full border-b border-b-border">
<td
className={`whitespace-nowrap p-4 text-left text-base font-normal capitalize leading-4 text-neutral-dark-2`}
>
<div className="flex flex-row items-center gap-2">
<Checkbox className="border-2 border-gray-300 data-[state=checked]:border-primary data-[state=checked]:bg-primary" />

<div>
<h3 className="text-sm font-[500] leading-6 text-neutral-dark-2">
{name}
</h3>
<div className="text-xs font-normal lowercase leading-4 text-neutral-dark-1"></div>
</div>
</div>
</td>

<td>
<div className="whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2">
{email}
</div>
</td>

<td
className={`gap-2 whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2`}
>
{notes}
</td>
<td
className={`whitespace-nowrap p-4 text-left text-sm font-normal leading-4 text-neutral-dark-2`}
>
<div
className={clsx(
status === "Online"
? "border-lime-500 text-lime-500"
: "border-black text-black",
"inline-flex h-[27px] w-[85px] items-center justify-center gap-2.5 rounded-[80px] border",
)}
>
<span className="text-xs">{status}</span>
</div>
</td>

<td
className={`whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2`}
>
{date}
</td>

<td className="whitespace-nowrap p-4 text-center text-base font-normal capitalize leading-4 text-neutral-dark-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
className="bg-transparent text-neutral-dark-2 hover:bg-transparent focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0"
size={"icon"}
>
<EllipsisVertical size={16} color="#09090b" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel className="sr-only">
Actions
</DropdownMenuLabel>
<DropdownMenuItem>Edit</DropdownMenuItem>
<DropdownMenuItem onClick={handleOpenDialog}>
Delete
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</td>
</tr>
);
})}
</tbody>
{isDialogOpen && <DeleteDialog onClose={handleCloseDialog} />}
</>
);
};

export default WaitListTableBody;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const tableHeadData: string[] = [
"name",
"email",
"notes",
"status",
"created at",
"action",
];

const WaitListTableHead = () => {
return (
<>
<thead>
<tr className="bg-[#FFF7F2]">
{tableHeadData.map((data, index) => {
return (
<th
key={index}
className={`whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2 ${data === "name" ? "w-[300px]" : data === "action" ? "w-[86px]" : "w-[202px]"}`}
>
{data}
</th>
);
})}
</tr>
</thead>
</>
);
};

export default WaitListTableHead;
Loading
Loading