Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apps/client/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/styles/globals.css",
"baseColor": "neutral",
"cssVariables": false,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"iconLibrary": "lucide"
}
6 changes: 6 additions & 0 deletions apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
"@ckeditor/ckeditor5-build-classic": "^41.2.1",
"@ckeditor/ckeditor5-react": "^6.2.0",
"@plaiceholder/next": "^3.0.0",
"@radix-ui/react-slot": "^1.1.0",
"aos": "^2.3.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"dayjs": "^1.11.10",
"firebase": "workspace:*",
"form-data": "^4.0.0",
"framer-motion": "^11.1.7",
"helper": "workspace:*",
"lucide-react": "^0.438.0",
"next": "14.1.2",
"nuqs": "^1.17.4",
"plaiceholder": "^3.0.0",
Expand All @@ -31,6 +35,8 @@
"react-query": "^3.39.3",
"react-toastify": "^10.0.5",
"swiper": "^11.0.7",
"tailwind-merge": "^2.2.1",
"tailwindcss-animate": "^1.0.7",
"ui": "workspace:*"
},
"devDependencies": {
Expand Down
5 changes: 2 additions & 3 deletions apps/client/src/api/homeWorship.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { IGetHomeWorshipResponse, IGetHomeWorshipsResponse } from "@/types/homeWorship/response";
import { api } from ".";

export const getHomeWorships = async () => {
export const getHomeWorships = async ({ page }: { page: number }) => {
const { data } = await api.get<IGetHomeWorshipsResponse>("/homeWorships", {
params: {
// lastVisibleCreatedAt: JSON.stringify(lastVisibleCreatedAt) || {},
// isGetPinned,
page,
},
});

Expand Down
30 changes: 30 additions & 0 deletions apps/client/src/components/homeWorship/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { useGetHomeWorships } from "@/query/homeWorship";
import { useRouter } from "next/navigation";
import { Spinner, Table } from "ui";
import {
Pagination,
PaginationContent,
PaginationItem,
PaginationLink,
PaginationNext,
PaginationPrevious,
} from "../ui/pagination";

const HomeWorships = () => {
const { push } = useRouter();
Expand Down Expand Up @@ -36,6 +44,28 @@ const HomeWorships = () => {
}
onClickRow={(rowId) => push(`/homeworship/${rowId}`)}
/>
<Pagination />
{/* <Pagination>
<PaginationContent>
<PaginationItem>
<PaginationPrevious href="#" />
</PaginationItem>
<PaginationItem>
<PaginationLink href="#">1</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink href="#" isActive>
2
</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink href="#">3</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationNext href="#" />
</PaginationItem>
</PaginationContent>
</Pagination> */}
</div>
</div>
);
Expand Down
57 changes: 57 additions & 0 deletions apps/client/src/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "@/lib/utils"

const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-neutral-950 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 dark:focus-visible:ring-neutral-300",
{
variants: {
variant: {
default:
"bg-neutral-900 text-neutral-50 shadow hover:bg-neutral-900/90 dark:bg-neutral-50 dark:text-neutral-900 dark:hover:bg-neutral-50/90",
destructive:
"bg-red-500 text-neutral-50 shadow-sm hover:bg-red-500/90 dark:bg-red-900 dark:text-neutral-50 dark:hover:bg-red-900/90",
outline:
"border border-neutral-200 bg-white shadow-sm hover:bg-neutral-100 hover:text-neutral-900 dark:border-neutral-800 dark:bg-neutral-950 dark:hover:bg-neutral-800 dark:hover:text-neutral-50",
secondary:
"bg-neutral-100 text-neutral-900 shadow-sm hover:bg-neutral-100/80 dark:bg-neutral-800 dark:text-neutral-50 dark:hover:bg-neutral-800/80",
ghost: "hover:bg-neutral-100 hover:text-neutral-900 dark:hover:bg-neutral-800 dark:hover:text-neutral-50",
link: "text-neutral-900 underline-offset-4 hover:underline dark:text-neutral-50",
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
)
}
)
Button.displayName = "Button"

export { Button, buttonVariants }
82 changes: 82 additions & 0 deletions apps/client/src/components/ui/pagination.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import * as React from "react";
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react";

import { cn } from "@/lib/utils";
import { ButtonProps, buttonVariants } from "@/components/ui/button";
import Link from "next/link";

const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
<nav
role="navigation"
aria-label="pagination"
className={cn("mx-auto flex w-full justify-center", className)}
{...props}
/>
);
Pagination.displayName = "Pagination";

const PaginationContent = React.forwardRef<HTMLUListElement, React.ComponentProps<"ul">>(
({ className, ...props }, ref) => (
<ul ref={ref} className={cn("flex flex-row items-center gap-1", className)} {...props} />
),
);
PaginationContent.displayName = "PaginationContent";

const PaginationItem = React.forwardRef<HTMLLIElement, React.ComponentProps<"li">>(({ className, ...props }, ref) => (
<li ref={ref} className={cn("", className)} {...props} />
));
PaginationItem.displayName = "PaginationItem";

type PaginationLinkProps = {
isActive?: boolean;
} & Pick<ButtonProps, "size"> &
React.ComponentProps<typeof Link>;

const PaginationLink = ({ className, isActive, size = "icon", ...props }: PaginationLinkProps) => (
<Link
aria-current={isActive ? "page" : undefined}
className={cn(
buttonVariants({
variant: isActive ? "outline" : "ghost",
size,
}),
className,
)}
{...props}
/>
);
PaginationLink.displayName = "PaginationLink";

const PaginationPrevious = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => (
<PaginationLink aria-label="Go to previous page" size="default" className={cn("gap-1 pl-2.5", className)} {...props}>
<ChevronLeft className="h-4 w-4" />
<span>Previous</span>
</PaginationLink>
);
PaginationPrevious.displayName = "PaginationPrevious";

const PaginationNext = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => (
<PaginationLink aria-label="Go to next page" size="default" className={cn("gap-1 pr-2.5", className)} {...props}>
<span>Next</span>
<ChevronRight className="h-4 w-4" />
</PaginationLink>
);
PaginationNext.displayName = "PaginationNext";

const PaginationEllipsis = ({ className, ...props }: React.ComponentProps<"span">) => (
<span aria-hidden className={cn("flex h-9 w-9 items-center justify-center", className)} {...props}>
<MoreHorizontal className="h-4 w-4" />
<span className="sr-only">More pages</span>
</span>
);
PaginationEllipsis.displayName = "PaginationEllipsis";

export {
Pagination,
PaginationContent,
PaginationLink,
PaginationItem,
PaginationPrevious,
PaginationNext,
PaginationEllipsis,
};
2 changes: 2 additions & 0 deletions apps/client/src/hooks/usePagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const usePagination = ({ totalCount, pageSize = 10 }: IUsePaginationProps) => {

const expectedCount = page * pageSize;
const notPinnedCount = totalCount;
const totalPages = Math.ceil(totalCount / pageSize);
const setNextPage = () => {
setPage(page + 1);
};
Expand All @@ -20,6 +21,7 @@ const usePagination = ({ totalCount, pageSize = 10 }: IUsePaginationProps) => {
setNextPage,
page,
onSetPage: setPage,
totalPages,
};
};

Expand Down
6 changes: 6 additions & 0 deletions apps/client/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
2 changes: 1 addition & 1 deletion apps/client/src/query/homeWorship/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import homeWorshipKeys from "./keys";

const useGetHomeWorships = () => {
return useQuery({
queryFn: () => getHomeWorships(),
queryFn: () => getHomeWorships({ page }),
queryKey: homeWorshipKeys.list(),
});
};
Expand Down
6 changes: 6 additions & 0 deletions apps/client/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@
* {
font-family: "Pretendard", sans-serif;
}

@layer base {
:root {
--radius: 0.5rem;
}
}
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading