Skip to content

Commit b0be71a

Browse files
committed
feat: refactor ui
1 parent 79bd5a2 commit b0be71a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+144
-238
lines changed

apps/web/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
"html-react-parser": "^5.0.11",
4646
"isomorphic-dompurify": "^2.14.0",
4747
"lowlight": "^3.1.0",
48-
"lucide-react": "^0.427.0",
48+
"lucide-react": "^0.469.0",
4949
"negotiator": "^0.6.3",
50-
"next": "15.0.4",
50+
"next": "^15.0.4",
5151
"next-auth": "5.0.0-beta.25",
5252
"next-intl": "^3.26.0",
5353
"next-themes": "^0.2.1",
@@ -56,10 +56,10 @@
5656
"postcss": "^8.4.28",
5757
"prismjs": "^1.29.0",
5858
"qs": "^6.11.2",
59-
"react": "19.0.0-rc.1",
59+
"react": "^19.0.0-rc.1",
6060
"react-dnd": "^16.0.1",
6161
"react-dnd-html5-backend": "^16.0.1",
62-
"react-dom": "19.0.0-rc.1",
62+
"react-dom": "^19.0.0-rc.1",
6363
"react-dropzone": "^14.2.3",
6464
"react-editor-js": "^2.1.0",
6565
"react-email": "^3.0.1",
@@ -88,8 +88,8 @@
8888
"devDependencies": {
8989
"@svgr/webpack": "^8.1.0",
9090
"@types/node": "^17.0.12",
91-
"@types/react": "19.0.1",
92-
"@types/react-dom": "19.0.1",
91+
"@types/react": "^19.0.1",
92+
"@types/react-dom": "^19.0.1",
9393
"database": "workspace:^",
9494
"eslint-config-custom": "workspace:*",
9595
"postcss-import": "^15.1.0",
@@ -100,8 +100,8 @@
100100
},
101101
"pnpm": {
102102
"overrides": {
103-
"@types/react": "19.0.1",
104-
"@types/react-dom": "19.0.1"
103+
"@types/react": "^19.0.1",
104+
"@types/react-dom": "^19.0.1"
105105
}
106106
}
107107
}

apps/web/src/actions/protect/postAction.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,7 @@ export const onToggleLikePostWithUser = async (
244244
}
245245
}
246246

247-
export const handleBookmark = async (
248-
prevState: { postId: string; postSlug: string; isBookmarked: boolean },
249-
_: FormData
250-
) => {
247+
export const handleBookmark = async (prevState: ActionState, _: FormData) => {
251248
try {
252249
await (prevState.isBookmarked ? removeRelation : addRelation)({
253250
postId: prevState.postId,

apps/web/src/libs/validationAction/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,15 @@ export function validatedActionWithUser<S extends z.ZodType<any, any>, T>({
6363
return action(result.data, formData, session)
6464
}
6565
}
66+
67+
export function withUser<T>(action: (prevState: ActionState, formData: FormData) => Promise<T>) {
68+
return async (prevState: ActionState, formData: FormData): Promise<T> => {
69+
const session = await auth()
70+
71+
if (!session) {
72+
throw new Error("User is not authenticated")
73+
}
74+
75+
return action(prevState, formData)
76+
}
77+
}

apps/web/src/molecules/posts/post-item/bookmark-button/BookmarkButton.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import React, { useActionState } from "react"
44

5-
import { addRelation, handleBookmark, removeRelation } from "actions/protect/postAction"
6-
import { PostOnUserType, TPostItem } from "database"
5+
import { handleBookmark } from "actions/protect/postAction"
6+
import { TPostItem } from "database"
7+
import { ActionState } from "libs/validationAction"
78
import { BookmarkCheck, BookmarkIcon } from "lucide-react"
89
import { Button, cn, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "ui"
910

@@ -20,7 +21,7 @@ const BookmarkButton: React.FC<BookmarkButtonProps> = ({
2021
isBookmarked,
2122
post,
2223
}) => {
23-
const [state, formAction, pending] = useActionState(handleBookmark, {
24+
const [state, formAction, pending] = useActionState<ActionState, FormData>(handleBookmark, {
2425
postId: post?.id,
2526
postSlug: post?.slug,
2627
isBookmarked: false,

packages/ui/index.ts

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
import "./app/globals.css"
22

3-
export { Typography } from "./@/components/ui/typography"
3+
export { Typography } from "./src/components/ui/typography"
44

5-
export { Input } from "./@/components/ui/input"
5+
export { Input } from "./src/components/ui/input"
66

7-
export { useToast, toast } from "./@/components/ui/use-toast"
7+
export { useToast, toast } from "./src/components/ui/use-toast"
88

9-
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from "./@/components/ui/tooltip"
9+
export {
10+
Tooltip,
11+
TooltipTrigger,
12+
TooltipContent,
13+
TooltipProvider,
14+
} from "./src/components/ui/tooltip"
1015

11-
export { ToggleGroup, ToggleGroupItem } from "./@/components/ui/toggle-group"
16+
export { ToggleGroup, ToggleGroupItem } from "./src/components/ui/toggle-group"
1217

13-
export { Collapsible, CollapsibleTrigger, CollapsibleContent } from "./@/components/ui/collapsible"
18+
export {
19+
Collapsible,
20+
CollapsibleTrigger,
21+
CollapsibleContent,
22+
} from "./src/components/ui/collapsible"
1423

15-
export { Toaster } from "./@/components/ui/toaster"
24+
export { Toaster } from "./src/components/ui/toaster"
1625

1726
export {
1827
type ToastProps,
@@ -24,11 +33,11 @@ export {
2433
ToastDescription,
2534
ToastClose,
2635
ToastAction,
27-
} from "./@/components/ui/toast"
36+
} from "./src/components/ui/toast"
2837

29-
export { Textarea } from "./@/components/ui/textarea"
38+
export { Textarea } from "./src/components/ui/textarea"
3039

31-
export { Tabs, TabsList, TabsTrigger, TabsContent } from "./@/components/ui/tabs"
40+
export { Tabs, TabsList, TabsTrigger, TabsContent } from "./src/components/ui/tabs"
3241

3342
export {
3443
Table,
@@ -39,13 +48,13 @@ export {
3948
TableRow,
4049
TableCell,
4150
TableCaption,
42-
} from "./@/components/ui/table"
51+
} from "./src/components/ui/table"
4352

44-
export { Switch } from "./@/components/ui/switch"
53+
export { Switch } from "./src/components/ui/switch"
4554

46-
export { Skeleton } from "./@/components/ui/skeleton"
55+
export { Skeleton } from "./src/components/ui/skeleton"
4756

48-
export { Separator } from "./@/components/ui/separator"
57+
export { Separator } from "./src/components/ui/separator"
4958

5059
export {
5160
Select,
@@ -58,13 +67,13 @@ export {
5867
SelectSeparator,
5968
SelectScrollUpButton,
6069
SelectScrollDownButton,
61-
} from "./@/components/ui/select"
70+
} from "./src/components/ui/select"
6271

63-
export { RadioGroup, RadioGroupItem } from "./@/components/ui/radio-group"
72+
export { RadioGroup, RadioGroupItem } from "./src/components/ui/radio-group"
6473

65-
export { Progress } from "./@/components/ui/progress"
74+
export { Progress } from "./src/components/ui/progress"
6675

67-
export { Popover, PopoverTrigger, PopoverContent } from "./@/components/ui/popover"
76+
export { Popover, PopoverTrigger, PopoverContent } from "./src/components/ui/popover"
6877

6978
export {
7079
Pagination,
@@ -74,7 +83,7 @@ export {
7483
PaginationLink,
7584
PaginationNext,
7685
PaginationPrevious,
77-
} from "./@/components/ui/pagination"
86+
} from "./src/components/ui/pagination"
7887

7988
export {
8089
navigationMenuTriggerStyle,
@@ -86,7 +95,7 @@ export {
8695
NavigationMenuLink,
8796
NavigationMenuIndicator,
8897
NavigationMenuViewport,
89-
} from "./@/components/ui/navigation-menu"
98+
} from "./src/components/ui/navigation-menu"
9099

91100
export {
92101
Menubar,
@@ -105,11 +114,11 @@ export {
105114
MenubarGroup,
106115
MenubarSub,
107116
MenubarShortcut,
108-
} from "./@/components/ui/menubar"
117+
} from "./src/components/ui/menubar"
109118

110-
export { Label } from "./@/components/ui/label"
119+
export { Label } from "./src/components/ui/label"
111120

112-
export { HoverCard, HoverCardTrigger, HoverCardContent } from "./@/components/ui/hover-card"
121+
export { HoverCard, HoverCardTrigger, HoverCardContent } from "./src/components/ui/hover-card"
113122

114123
export {
115124
useFormField,
@@ -120,7 +129,7 @@ export {
120129
FormDescription,
121130
FormMessage,
122131
FormField,
123-
} from "./@/components/ui/form"
132+
} from "./src/components/ui/form"
124133

125134
export {
126135
DropdownMenu,
@@ -138,7 +147,7 @@ export {
138147
DropdownMenuSubContent,
139148
DropdownMenuSubTrigger,
140149
DropdownMenuRadioGroup,
141-
} from "./@/components/ui/dropdown-menu"
150+
} from "./src/components/ui/dropdown-menu"
142151

143152
export {
144153
Drawer,
@@ -151,7 +160,7 @@ export {
151160
DrawerFooter,
152161
DrawerTitle,
153162
DrawerDescription,
154-
} from "./@/components/ui/drawer"
163+
} from "./src/components/ui/drawer"
155164

156165
export {
157166
Dialog,
@@ -164,9 +173,9 @@ export {
164173
DialogFooter,
165174
DialogTitle,
166175
DialogDescription,
167-
} from "./@/components/ui/dialog"
176+
} from "./src/components/ui/dialog"
168177

169-
export { Checkbox } from "./@/components/ui/checkbox"
178+
export { Checkbox } from "./src/components/ui/checkbox"
170179

171180
export {
172181
type CarouselApi,
@@ -175,7 +184,7 @@ export {
175184
CarouselItem,
176185
CarouselPrevious,
177186
CarouselNext,
178-
} from "./@/components/ui/carousel"
187+
} from "./src/components/ui/carousel"
179188

180189
export {
181190
Card,
@@ -184,11 +193,11 @@ export {
184193
CardTitle,
185194
CardDescription,
186195
CardContent,
187-
} from "./@/components/ui/card"
196+
} from "./src/components/ui/card"
188197

189-
export { Calendar } from "./@/components/ui/calendar"
198+
export { Calendar } from "./src/components/ui/calendar"
190199

191-
export { Button, buttonVariants } from "./@/components/ui/button"
200+
export { Button, buttonVariants } from "./src/components/ui/button"
192201

193202
export {
194203
Breadcrumb,
@@ -198,11 +207,11 @@ export {
198207
BreadcrumbPage,
199208
BreadcrumbSeparator,
200209
BreadcrumbEllipsis,
201-
} from "./@/components/ui/breadcrumb"
210+
} from "./src/components/ui/breadcrumb"
202211

203-
export { Badge, badgeVariants } from "./@/components/ui/badge"
212+
export { Badge, badgeVariants } from "./src/components/ui/badge"
204213

205-
export { Avatar, AvatarImage, AvatarFallback } from "./@/components/ui/avatar"
214+
export { Avatar, AvatarImage, AvatarFallback } from "./src/components/ui/avatar"
206215

207216
export {
208217
AlertDialog,
@@ -216,19 +225,19 @@ export {
216225
AlertDialogDescription,
217226
AlertDialogAction,
218227
AlertDialogCancel,
219-
} from "./@/components/ui/alert-dialog"
228+
} from "./src/components/ui/alert-dialog"
220229

221-
export { Alert, AlertDescription, AlertTitle } from "./@/components/ui/alert"
230+
export { Alert, AlertDescription, AlertTitle } from "./src/components/ui/alert"
222231

223232
export {
224233
Accordion,
225234
AccordionItem,
226235
AccordionTrigger,
227236
AccordionContent,
228-
} from "./@/components/ui/accordion"
237+
} from "./src/components/ui/accordion"
229238

230-
export { cn } from "././@/lib/utils"
239+
export { cn } from "./src/lib/utils"
231240

232-
export { LoadingButton } from "./@/components/ui/loading-button"
241+
export { LoadingButton } from "./src/components/ui/loading-button"
233242

234-
export { PostSkeleton } from "./@/molecules/skeleton/posts"
243+
export { PostSkeleton } from "./src/components/molecules/skeleton/posts"

packages/ui/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@
2929
"typescript": "^5.1.6"
3030
},
3131
"peerDependencies": {
32-
"next": "14.2.0-canary.50",
33-
"react": "19.0.0-rc.1",
34-
"react-dom": "19.0.0-rc.1"
32+
"next": "^15.0.4",
33+
"react": "^19.0.0-rc.1",
34+
"react-dom": "^19.0.0-rc.1"
3535
},
3636
"dependencies": {
37-
"@hookform/resolvers": "^3.3.4",
37+
"@hookform/resolvers": "^3.9.0",
3838
"@radix-ui/react-accordion": "^1.1.2",
3939
"@radix-ui/react-alert-dialog": "^1.0.5",
4040
"@radix-ui/react-avatar": "^1.0.4",
4141
"@radix-ui/react-checkbox": "^1.0.4",
4242
"@radix-ui/react-collapsible": "^1.0.3",
4343
"@radix-ui/react-dialog": "^1.1.1",
44-
"@radix-ui/react-dropdown-menu": "^2.0.5",
44+
"@radix-ui/react-dropdown-menu": "^2.1.1",
4545
"@radix-ui/react-hover-card": "^1.0.7",
46-
"@radix-ui/react-label": "^2.0.2",
46+
"@radix-ui/react-label": "^2.1.0",
4747
"@radix-ui/react-menubar": "^1.1.1",
4848
"@radix-ui/react-navigation-menu": "^1.1.4",
4949
"@radix-ui/react-popover": "^1.0.7",
@@ -64,14 +64,14 @@
6464
"cmdk": "^0.2.0",
6565
"date-fns": "^3.6.0",
6666
"embla-carousel-react": "^8.0.4",
67-
"lucide-react": "^0.270.0",
67+
"lucide-react": "^0.469.0",
6868
"postcss": "^8.4.28",
6969
"react-day-picker": "^8.10.1",
70-
"react-hook-form": "^7.51.4",
70+
"react-hook-form": "^7.53.0",
7171
"tailwind-merge": "^1.14.0",
7272
"tailwindcss": "3.4.4",
7373
"tailwindcss-animate": "^1.0.7",
7474
"vaul": "^0.9.0",
75-
"zod": "^3.23.6"
75+
"zod": "^3.23.8"
7676
}
7777
}

packages/ui/@/molecules/skeleton/posts.tsx renamed to packages/ui/src/components/molecules/skeleton/posts.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react"
22

3-
import { Skeleton } from "../../components/ui/skeleton"
4-
import { cn } from "../../lib/utils"
3+
import { Skeleton } from "@/components/ui/skeleton"
4+
import { cn } from "@/lib/utils"
55

66
interface PostSkeletonProps extends React.HTMLAttributes<HTMLDivElement> {
77
total?: number
File renamed without changes.

0 commit comments

Comments
 (0)