diff --git a/bun.lockb b/bun.lockb
index 9045f2d..1bae1f3 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/next.config.mjs b/next.config.mjs
index d5456a1..61cd5ed 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
- reactStrictMode: true,
+ reactStrictMode: false,
};
export default nextConfig;
diff --git a/package.json b/package.json
index e2ee7ae..48e8c91 100644
--- a/package.json
+++ b/package.json
@@ -12,8 +12,11 @@
"@radix-ui/react-avatar": "^1.1.0",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-icons": "^1.3.0",
+ "@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.1",
+ "@radix-ui/react-scroll-area": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
+ "@radix-ui/react-switch": "^1.1.0",
"@tanstack/react-table": "^8.20.1",
"@types/qs": "^6.9.15",
"axios": "^1.7.4",
diff --git a/src/components/layouts/RootLayout.tsx b/src/components/layouts/RootLayout.tsx
index 4b5e578..90ac2eb 100644
--- a/src/components/layouts/RootLayout.tsx
+++ b/src/components/layouts/RootLayout.tsx
@@ -1,11 +1,6 @@
-import { Inter as FontSans } from "next/font/google"
import { cn } from "@/lib/utils"
-const fontSans = FontSans({
- subsets: ["latin"],
- variable: "--font-sans",
-})
type RootLayoutProps = {
children: React.ReactNode
@@ -15,7 +10,6 @@ export default function RootLayout({ children }: RootLayoutProps) {
return (
{children}
diff --git a/src/components/people/PeopleList.tsx b/src/components/people/PeopleList.tsx
index 6a3c48e..975af48 100644
--- a/src/components/people/PeopleList.tsx
+++ b/src/components/people/PeopleList.tsx
@@ -1,5 +1,4 @@
import { listPeople } from "@/handlers/api/people.handler";
-import { IListData } from "@/types/common";
import { IPerson } from "@/types/person";
import React, { useEffect, useState } from "react";
import Loader from "../ui/loader";
@@ -9,6 +8,9 @@ import { Table } from "../ui/table";
import PersonBirthdayCell from "./PersonBirthdayCell";
import Link from "next/link";
import { ENV } from "@/config/environment";
+import PersonHideCell from "./PersonHideCell";
+import { PeoplePagination } from "./PeoplePagination";
+import { useRouter } from "next/router";
const columns: ColumnDef[] = [
{
@@ -25,7 +27,7 @@ const columns: ColumnDef[] = [
header: "Hidden",
accessorKey: "isHidden",
cell: ({ row }) => (
- {row.original.isHidden ? "Yes" : "No"}
+
),
},
{
@@ -46,15 +48,18 @@ const columns: ColumnDef[] = [
},
];
-
-
export default function PeopleList() {
+ const router = useRouter()
+ const { page = 1 } = router.query as { page: string }
const [people, setPeople] = useState([]);
const [loading, setLoading] = useState(false);
const [errorMessage, setErrorMessage] = useState(null);
const fetchData = async () => {
- return listPeople()
+ setLoading(true);
+ return listPeople({
+ page
+ })
.then((response) => {
setPeople(response.people);
})
@@ -67,17 +72,28 @@ export default function PeopleList() {
};
useEffect(() => {
+ if (!router.isReady) return;
fetchData();
- }, []);
+ }, [page]);
+
+ const renderContent = () => {
if (loading) return ;
-
if (errorMessage) return {errorMessage}
;
+ return (
+
+ {people.map((person) => (
+
+ ))}
+
+ )
+}
return (
-
-
columns={columns} data={people} />
+ {renderContent()}
+
);
diff --git a/src/components/people/PeoplePagination.tsx b/src/components/people/PeoplePagination.tsx
new file mode 100644
index 0000000..caf264c
--- /dev/null
+++ b/src/components/people/PeoplePagination.tsx
@@ -0,0 +1,47 @@
+
+import { useRouter } from "next/router"
+import { useMemo } from "react"
+import { Button } from "../ui/button"
+import { ArrowLeft, ArrowRight } from "lucide-react"
+import Link from "next/link"
+
+export function PeoplePagination() {
+ const router = useRouter()
+ const { pathname } = router;
+ const { page = 1 } = router.query as { page: string }
+
+ const [nextPage, prevPage] = useMemo(() => {
+ const pageNum = parseInt(page.toString() || "1", 10)
+ return [pageNum + 1, pageNum - 1]
+
+ }, [page])
+
+ return (
+
+
+
+
+
+
+
+
+
+ )
+}
diff --git a/src/components/people/PersonBirthdayCell.tsx b/src/components/people/PersonBirthdayCell.tsx
index 2b9da47..2004952 100644
--- a/src/components/people/PersonBirthdayCell.tsx
+++ b/src/components/people/PersonBirthdayCell.tsx
@@ -33,9 +33,5 @@ export default function PersonBirthdayCell(
- return (
-
-
-
- )
+ return
}
diff --git a/src/components/people/PersonHideCell.tsx b/src/components/people/PersonHideCell.tsx
new file mode 100644
index 0000000..3bf43ce
--- /dev/null
+++ b/src/components/people/PersonHideCell.tsx
@@ -0,0 +1,45 @@
+import { IPerson } from "@/types/person";
+import React, { useState } from "react";
+import { DatePicker } from "../ui/datepicker";
+import { updatePerson } from "@/handlers/api/people.handler";
+import { formatDate } from "@/helpers/date.helper";
+import { Button } from "../ui/button";
+import { Switch } from "../ui/switch";
+import { Label } from "../ui/label";
+
+interface IProps {
+ person: IPerson;
+ onUpdate?: (person: IPerson) => any;
+}
+
+export default function PersonHideCell({ person, onUpdate }: IProps) {
+ const [loading, setLoading] = useState(false);
+ const [hidden, setHidden] = useState(person.isHidden);
+
+ const handleEdit = (hidden: boolean) => {
+ setLoading(true);
+ return updatePerson(person.id, {
+ isHidden: hidden,
+ })
+ .then(() => {
+ setHidden(hidden);
+ onUpdate?.({
+ ...person,
+ isHidden: hidden,
+ })
+ })
+ .catch(() => {})
+ .finally(() => {
+ setLoading(false);
+ });
+ };
+
+ return (
+
+ );
+}
diff --git a/src/components/people/PersonItem.tsx b/src/components/people/PersonItem.tsx
index 29ddc86..0d52b67 100644
--- a/src/components/people/PersonItem.tsx
+++ b/src/components/people/PersonItem.tsx
@@ -3,6 +3,9 @@ import React, { useState } from "react";
import { Avatar } from "../ui/avatar";
import { updatePerson } from "@/handlers/api/people.handler";
import { PersonMergeDropdown } from "./PersonMergeDropdown";
+import PersonBirthdayCell from "./PersonBirthdayCell";
+import PersonHideCell from "./PersonHideCell";
+import clsx from "clsx";
interface IProps {
person: IPerson;
@@ -27,25 +30,44 @@ export default function PersonItem({ person }: IProps) {
};
return (
-
-
+
+
+
+
+
{
+ setFormData(newData);
+ }}
+ />
+
+
{!editMode ? (
{
setEditMode((prev) => !prev);
}}
>
- {formData.name ? formData.name : Unknown}
+ {formData.name ? (
+ formData.name
+ ) : (
+ Unknown
+ )}
) : (
{
@@ -56,6 +78,7 @@ export default function PersonItem({ person }: IProps) {
/>
)}
+
);
}
diff --git a/src/components/people/PersonMergeDropdown.tsx b/src/components/people/PersonMergeDropdown.tsx
index dfec675..118fa41 100644
--- a/src/components/people/PersonMergeDropdown.tsx
+++ b/src/components/people/PersonMergeDropdown.tsx
@@ -90,7 +90,6 @@ export function PersonMergeDropdown(
})
};
- console.log(searchedPeople);
return (
diff --git a/src/components/ui/datepicker.tsx b/src/components/ui/datepicker.tsx
index 6ccd136..3053e3e 100644
--- a/src/components/ui/datepicker.tsx
+++ b/src/components/ui/datepicker.tsx
@@ -32,7 +32,7 @@ export function DatePicker(