hey-pharmacist-ecommerce 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,7 @@ import { Input } from '@/components/ui/Input';
24
24
  import { useAuth } from '@/providers/AuthProvider';
25
25
  import { toast } from 'sonner';
26
26
  import { getInitials } from '@/lib/utils/format';
27
+ import { useBasePath } from '@/providers/BasePathProvider';
27
28
 
28
29
  const profileSchema = z.object({
29
30
  firstName: z.string().min(2, 'First name is required'),
@@ -37,6 +38,7 @@ type ProfileFormData = z.infer<typeof profileSchema>;
37
38
  export function ProfileScreen() {
38
39
  const router = useRouter();
39
40
  const { user, updateUser, logout } = useAuth();
41
+ const { buildPath } = useBasePath();
40
42
  const [isSubmitting, setIsSubmitting] = useState(false);
41
43
 
42
44
  const {
@@ -68,11 +70,11 @@ export function ProfileScreen() {
68
70
  const handleLogout = async () => {
69
71
  await logout();
70
72
  toast.success('Logged out successfully');
71
- router.push('/');
73
+ router.push(buildPath('/'));
72
74
  };
73
75
 
74
76
  if (!user) {
75
- router.push('/login');
77
+ router.push(buildPath('/login'));
76
78
  return null;
77
79
  }
78
80
 
@@ -81,19 +83,19 @@ export function ProfileScreen() {
81
83
  icon: Package,
82
84
  label: 'Order history',
83
85
  description: 'Track shipments and download invoices',
84
- href: '/orders',
86
+ href: buildPath('/orders'),
85
87
  },
86
88
  {
87
89
  icon: Heart,
88
90
  label: 'Wishlist',
89
91
  description: 'Curate go-to remedies and favorites',
90
- href: '/wishlist',
92
+ href: buildPath('/wishlist'),
91
93
  },
92
94
  {
93
95
  icon: MapPin,
94
96
  label: 'Delivery addresses',
95
97
  description: 'Manage saved delivery locations',
96
- href: '/account/addresses',
98
+ href: buildPath('/account/addresses'),
97
99
  },
98
100
  ];
99
101
 
@@ -134,7 +136,7 @@ export function ProfileScreen() {
134
136
  <Button
135
137
  variant="ghost"
136
138
  className="text-white hover:bg-white/20"
137
- onClick={() => router.push('/account/change-password')}
139
+ onClick={() => router.push(buildPath('/account/change-password'))}
138
140
  >
139
141
  Change password
140
142
  </Button>
@@ -211,7 +213,7 @@ export function ProfileScreen() {
211
213
  type="button"
212
214
  variant="outline"
213
215
  size="lg"
214
- onClick={() => router.push('/orders')}
216
+ onClick={() => router.push(buildPath('/orders'))}
215
217
  >
216
218
  View recent orders
217
219
  </Button>
@@ -257,7 +259,7 @@ export function ProfileScreen() {
257
259
  <Button
258
260
  variant="outline"
259
261
  className="mt-4 w-full"
260
- onClick={() => router.push('/account/preferences')}
262
+ onClick={() => router.push(buildPath('/account/preferences'))}
261
263
  >
262
264
  Manage preferences
263
265
  </Button>
@@ -21,6 +21,7 @@ import { Button } from '@/components/ui/Button';
21
21
  import { useAuth } from '@/providers/AuthProvider';
22
22
  import { toast } from 'sonner';
23
23
  import { CreateUserDtoCustomerTypeEnum, CreateUserDtoRoleEnum } from '@/lib/Apis/models';
24
+ import { useBasePath } from '@/providers/BasePathProvider';
24
25
 
25
26
  const registerSchema = z
26
27
  .object({
@@ -47,6 +48,7 @@ const BENEFITS = [
47
48
  export function RegisterScreen() {
48
49
  const router = useRouter();
49
50
  const { register: registerUser } = useAuth();
51
+ const { buildPath } = useBasePath();
50
52
  const [showPassword, setShowPassword] = useState(false);
51
53
  const [showConfirmPassword, setShowConfirmPassword] = useState(false);
52
54
  const [isSubmitting, setIsSubmitting] = useState(false);
@@ -70,7 +72,7 @@ export function RegisterScreen() {
70
72
  role: CreateUserDtoRoleEnum.User,
71
73
  });
72
74
  toast.success('Account created successfully!');
73
- router.push('/');
75
+ router.push(buildPath('/'));
74
76
  } catch (error: any) {
75
77
  toast.error(error.response?.data?.message || 'Failed to create account');
76
78
  } finally {
@@ -65,7 +65,7 @@ export function ShopScreen({ initialFilters = {}, categoryName }: ShopScreenProp
65
65
  e.preventDefault();
66
66
  if (searchQuery.trim()) {
67
67
  setIsSearching(true);
68
- router.push(`/search?q=${encodeURIComponent(searchQuery.trim())}`);
68
+ router.push(buildPath(`/search?q=${encodeURIComponent(searchQuery.trim())}`));
69
69
  }
70
70
  };
71
71
 
@@ -79,7 +79,7 @@ export function ShopScreen({ initialFilters = {}, categoryName }: ShopScreenProp
79
79
  if (e.key === 'Enter' && searchQuery.trim()) {
80
80
  e.preventDefault();
81
81
  setIsSearching(true);
82
- router.push(`/search?q=${encodeURIComponent(searchQuery.trim())}`);
82
+ router.push(buildPath(`/search?q=${encodeURIComponent(searchQuery.trim())}`));
83
83
  }
84
84
  };
85
85
 
@@ -183,7 +183,7 @@ export default function WishlistScreen() {
183
183
  <p className="mt-3 text-slate-500">
184
184
  Create your curated shelf of products and we&apos;ll keep them ready whenever you return.
185
185
  </p>
186
- <Button className="mt-6" onClick={() => router.push('/login')}>
186
+ <Button className="mt-6" onClick={() => router.push(buildPath('/login'))}>
187
187
  Sign In
188
188
  </Button>
189
189
  </div>
@@ -287,8 +287,8 @@ export default function WishlistScreen() {
287
287
  Bookmark pharmacy essentials, supplements, or skincare picks and we&apos;ll keep them safe until you&apos;re ready to checkout.
288
288
  </p>
289
289
  <div className="mt-8 flex flex-wrap justify-center gap-3">
290
- <Button onClick={() => router.push('/shop')}>Discover products</Button>
291
- <Button variant="outline" onClick={() => router.push('/categories')}>
290
+ <Button onClick={() => router.push(buildPath('/shop'))}>Discover products</Button>
291
+ <Button variant="outline" onClick={() => router.push(buildPath('/categories'))}>
292
292
  Browse categories
293
293
  </Button>
294
294
  </div>
@@ -381,7 +381,7 @@ export default function WishlistScreen() {
381
381
  <div className="flex flex-wrap gap-2">
382
382
  <Button
383
383
  size="sm"
384
- onClick={() => router.push(`/products/${product.id}`)}
384
+ onClick={() => router.push(buildPath(`/products/${product.id}`))}
385
385
  >
386
386
  View details
387
387
  </Button>