Skip to content

Commit 9b66530

Browse files
committed
fix(package.json): fixing vercel import error
1 parent 54619f2 commit 9b66530

File tree

2 files changed

+73
-75
lines changed

2 files changed

+73
-75
lines changed
Lines changed: 55 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,28 @@
11
"use client";
22

3-
import { useSession } from "@/hooks/useSession";
4-
import { Card, CardContent, CardHeader, CardTitle } from "@call/ui/components/card";
5-
import { Avatar, AvatarFallback, AvatarImage } from "@call/ui/components/avatar";
6-
import { Label } from "@call/ui/components/label";
7-
import { Input } from "@call/ui/components/input";
3+
import { useSession } from "@/components/providers/session";
4+
import { authClient } from "@call/auth/auth-client";
85
import { Button } from "@call/ui/components/button";
9-
import { useState, useRef } from "react";
6+
import {
7+
Card,
8+
CardContent,
9+
CardHeader,
10+
CardTitle,
11+
} from "@call/ui/components/card";
12+
import { Input } from "@call/ui/components/input";
13+
import { Label } from "@call/ui/components/label";
14+
import { UserProfile } from "@call/ui/components/use-profile";
15+
import { useRef, useState } from "react";
1016
import { toast } from "sonner";
11-
import { authClient } from "@call/auth/auth-client";
12-
import { Camera } from "lucide-react";
1317

1418
export default function ProfilePage() {
15-
const { session, isLoading } = useSession();
19+
const { user } = useSession();
1620
const [isEditing, setIsEditing] = useState(false);
17-
const [name, setName] = useState(session?.user?.name || "");
21+
const [name, setName] = useState(user.name || "");
1822
const [loading, setLoading] = useState(false);
1923
const [imageLoading, setImageLoading] = useState(false);
2024
const fileInputRef = useRef<HTMLInputElement>(null);
2125

22-
if (isLoading) {
23-
return (
24-
<div className="flex items-center justify-center h-[calc(100vh-4rem)]">
25-
<p className="text-muted-foreground">Loading...</p>
26-
</div>
27-
);
28-
}
29-
30-
if (!session?.user) {
31-
return (
32-
<div className="flex items-center justify-center h-[calc(100vh-4rem)]">
33-
<p className="text-muted-foreground">Please sign in to view your profile.</p>
34-
</div>
35-
);
36-
}
37-
3826
const handleUpdateProfile = async () => {
3927
if (!name.trim()) {
4028
toast.error("Name cannot be empty");
@@ -43,26 +31,25 @@ export default function ProfilePage() {
4331

4432
setLoading(true);
4533
try {
46-
const res = await fetch(`http://${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/update-profile`, {
47-
method: "PATCH",
48-
headers: {
49-
"Content-Type": "application/json",
50-
},
51-
credentials: "include",
52-
body: JSON.stringify({ name }),
53-
});
34+
const res = await fetch(
35+
`http://${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/update-profile`,
36+
{
37+
method: "PATCH",
38+
headers: {
39+
"Content-Type": "application/json",
40+
},
41+
credentials: "include",
42+
body: JSON.stringify({ name }),
43+
}
44+
);
5445

5546
if (!res.ok) {
5647
throw new Error("Failed to update profile");
5748
}
58-
59-
// Refresh the session to get the updated user data
6049
await authClient.getSession();
61-
50+
6251
toast.success("Profile updated successfully");
6352
setIsEditing(false);
64-
65-
// Force a page refresh to update all components with new session data
6653
window.location.reload();
6754
} catch (error) {
6855
toast.error("Failed to update profile");
@@ -96,21 +83,24 @@ export default function ProfilePage() {
9683
const formData = new FormData();
9784
formData.append("image", file);
9885

99-
const res = await fetch(`http://${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/update-profile-image`, {
100-
method: "PATCH",
101-
credentials: "include",
102-
body: formData,
103-
});
86+
const res = await fetch(
87+
`http://${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/update-profile-image`,
88+
{
89+
method: "PATCH",
90+
credentials: "include",
91+
body: formData,
92+
}
93+
);
10494

10595
if (!res.ok) {
10696
throw new Error("Failed to update profile image");
10797
}
10898

10999
// Refresh the session to get the updated user data
110100
await authClient.getSession();
111-
101+
112102
toast.success("Profile image updated successfully");
113-
103+
114104
// Force a page refresh to update all components with new session data
115105
window.location.reload();
116106
} catch (error) {
@@ -121,23 +111,15 @@ export default function ProfilePage() {
121111
};
122112

123113
return (
124-
<div className="max-w-2xl mx-auto mt-8">
114+
<div className="mx-auto mt-8 max-w-2xl">
125115
<Card>
126116
<CardHeader>
127117
<CardTitle>Profile</CardTitle>
128118
</CardHeader>
129119
<CardContent className="space-y-6">
130120
<div className="flex items-center gap-4">
131-
<div className="relative group">
132-
<Avatar className="h-20 w-20 cursor-pointer transition-opacity group-hover:opacity-75" onClick={handleImageClick}>
133-
<AvatarImage src={session.user.image || undefined} />
134-
<AvatarFallback>
135-
{session.user.name?.charAt(0).toUpperCase() || "U"}
136-
</AvatarFallback>
137-
<div className="absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100 rounded-full">
138-
<Camera className="h-6 w-6 text-white" />
139-
</div>
140-
</Avatar>
121+
<div className="group relative">
122+
<UserProfile name={user.name} url={user.image} />
141123
<input
142124
type="file"
143125
ref={fileInputRef}
@@ -147,22 +129,22 @@ export default function ProfilePage() {
147129
disabled={imageLoading}
148130
/>
149131
{imageLoading && (
150-
<div className="absolute inset-0 flex items-center justify-center bg-black/40 rounded-full">
132+
<div className="absolute inset-0 flex items-center justify-center rounded-full bg-black/40">
151133
<div className="h-5 w-5 animate-spin rounded-full border-2 border-white border-t-transparent" />
152134
</div>
153135
)}
154136
</div>
155137
<div>
156-
<h2 className="text-xl font-semibold">{session.user.name}</h2>
157-
<p className="text-sm text-muted-foreground">{session.user.email}</p>
138+
<h2 className="text-xl font-semibold">{user.name}</h2>
139+
<p className="text-muted-foreground text-sm">{user.email}</p>
158140
</div>
159141
</div>
160142

161143
<div className="space-y-4">
162144
<div>
163145
<Label htmlFor="name">Name</Label>
164146
{isEditing ? (
165-
<div className="flex gap-2 mt-1">
147+
<div className="mt-1 flex gap-2">
166148
<Input
167149
id="name"
168150
value={name}
@@ -176,16 +158,16 @@ export default function ProfilePage() {
176158
variant="outline"
177159
onClick={() => {
178160
setIsEditing(false);
179-
setName(session.user.name);
161+
setName(user.name);
180162
}}
181163
disabled={loading}
182164
>
183165
Cancel
184166
</Button>
185167
</div>
186168
) : (
187-
<div className="flex items-center justify-between mt-1">
188-
<p className="text-sm">{session.user.name}</p>
169+
<div className="mt-1 flex items-center justify-between">
170+
<p className="text-sm">{user.name}</p>
189171
<Button variant="outline" onClick={() => setIsEditing(true)}>
190172
Edit
191173
</Button>
@@ -195,10 +177,12 @@ export default function ProfilePage() {
195177

196178
<div>
197179
<Label htmlFor="email">Email</Label>
198-
<div className="flex items-center justify-between mt-1">
199-
<p className="text-sm">{session.user.email}</p>
200-
{session.user.emailVerified ? (
201-
<span className="text-xs text-green-600 font-medium">Verified</span>
180+
<div className="mt-1 flex items-center justify-between">
181+
<p className="text-sm">{user.email}</p>
182+
{user.emailVerified ? (
183+
<span className="text-xs font-medium text-green-600">
184+
Verified
185+
</span>
202186
) : (
203187
<Button variant="outline" size="sm">
204188
Verify Email
@@ -209,13 +193,13 @@ export default function ProfilePage() {
209193

210194
<div>
211195
<Label>Account Created</Label>
212-
<p className="text-sm mt-1">
213-
{new Date(session.user.createdAt).toLocaleDateString()}
196+
<p className="mt-1 text-sm">
197+
{new Date(user.createdAt).toLocaleDateString()}
214198
</p>
215199
</div>
216200
</div>
217201
</CardContent>
218202
</Card>
219203
</div>
220204
);
221-
}
205+
}

packages/auth/package.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
{
22
"name": "@call/auth",
3-
"module": "index.ts",
3+
"main": "./dist/auth.cjs",
4+
"module": "./dist/auth.js",
5+
"types": "./dist/auth.d.ts",
46
"type": "module",
57
"private": true,
68
"scripts": {
79
"build": "tsup src/auth.ts src/auth-client.ts src/utils/send-mail.ts --format esm,cjs --dts -d dist --tsconfig tsconfig.build.json",
810
"dev": "tsup src/auth.ts src/auth-client.ts src/utils/send-mail.ts --format esm,cjs --dts -d dist --watch --tsconfig tsconfig.build.json"
911
},
1012
"exports": {
11-
"./auth-client": "./dist/auth-client.js",
12-
"./auth": "./dist/auth.js",
13-
"./utils/send-mail": "./dist/utils/send-mail.js"
13+
"./auth-client": {
14+
"types": "./dist/auth-client.d.ts",
15+
"import": "./dist/auth-client.js",
16+
"require": "./dist/auth-client.cjs"
17+
},
18+
"./auth": {
19+
"types": "./dist/auth.d.ts",
20+
"import": "./dist/auth.js",
21+
"require": "./dist/auth.cjs"
22+
},
23+
"./utils/send-mail": {
24+
"types": "./dist/utils/send-mail.d.ts",
25+
"import": "./dist/utils/send-mail.js",
26+
"require": "./dist/utils/send-mail.cjs"
27+
}
1428
},
1529
"devDependencies": {
1630
"@call/typescript-config": "workspace:*",

0 commit comments

Comments
 (0)