hey-pharmacist-ecommerce 1.0.5 → 1.0.7
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.
- package/README.md +157 -17
- package/dist/index.d.mts +3636 -316
- package/dist/index.d.ts +3636 -316
- package/dist/index.js +6802 -3866
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6756 -3818
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -15
- package/src/components/AddressFormModal.tsx +171 -0
- package/src/components/CartItem.tsx +17 -12
- package/src/components/FilterChips.tsx +195 -0
- package/src/components/Header.tsx +121 -71
- package/src/components/OrderCard.tsx +18 -25
- package/src/components/ProductCard.tsx +209 -72
- package/src/components/ui/Button.tsx +13 -5
- package/src/components/ui/Card.tsx +46 -0
- package/src/hooks/useAddresses.ts +83 -0
- package/src/hooks/useOrders.ts +37 -19
- package/src/hooks/useProducts.ts +55 -63
- package/src/hooks/useWishlistProducts.ts +75 -0
- package/src/index.ts +3 -19
- package/src/lib/Apis/api.ts +1 -0
- package/src/lib/Apis/apis/cart-api.ts +3 -3
- package/src/lib/Apis/apis/inventory-api.ts +0 -108
- package/src/lib/Apis/apis/stores-api.ts +70 -0
- package/src/lib/Apis/apis/wishlist-api.ts +447 -0
- package/src/lib/Apis/models/cart-item-populated.ts +0 -1
- package/src/lib/Apis/models/create-single-variant-product-dto.ts +3 -10
- package/src/lib/Apis/models/create-variant-dto.ts +26 -33
- package/src/lib/Apis/models/extended-product-dto.ts +20 -24
- package/src/lib/Apis/models/index.ts +2 -1
- package/src/lib/Apis/models/order-time-line-dto.ts +49 -0
- package/src/lib/Apis/models/order.ts +3 -8
- package/src/lib/Apis/models/populated-order.ts +3 -8
- package/src/lib/Apis/models/product-variant.ts +29 -0
- package/src/lib/Apis/models/update-product-variant-dto.ts +16 -23
- package/src/lib/Apis/models/wishlist.ts +51 -0
- package/src/lib/Apis/wrapper.ts +18 -7
- package/src/lib/api-adapter/index.ts +0 -12
- package/src/lib/types/index.ts +16 -61
- package/src/lib/utils/colors.ts +7 -4
- package/src/lib/utils/format.ts +1 -1
- package/src/lib/validations/address.ts +14 -0
- package/src/providers/AuthProvider.tsx +61 -31
- package/src/providers/CartProvider.tsx +18 -28
- package/src/providers/EcommerceProvider.tsx +7 -0
- package/src/providers/FavoritesProvider.tsx +86 -0
- package/src/providers/ThemeProvider.tsx +16 -1
- package/src/providers/WishlistProvider.tsx +174 -0
- package/src/screens/AddressesScreen.tsx +484 -0
- package/src/screens/CartScreen.tsx +120 -84
- package/src/screens/CategoriesScreen.tsx +120 -0
- package/src/screens/CheckoutScreen.tsx +919 -241
- package/src/screens/CurrentOrdersScreen.tsx +125 -61
- package/src/screens/HomeScreen.tsx +209 -0
- package/src/screens/LoginScreen.tsx +133 -88
- package/src/screens/NewAddressScreen.tsx +187 -0
- package/src/screens/OrdersScreen.tsx +162 -50
- package/src/screens/ProductDetailScreen.tsx +641 -190
- package/src/screens/ProfileScreen.tsx +192 -116
- package/src/screens/RegisterScreen.tsx +193 -144
- package/src/screens/SearchResultsScreen.tsx +165 -0
- package/src/screens/ShopScreen.tsx +1110 -146
- package/src/screens/WishlistScreen.tsx +428 -0
- package/src/lib/Apis/models/inventory-paginated-response.ts +0 -75
- package/src/lib/api/auth.ts +0 -81
- package/src/lib/api/cart.ts +0 -42
- package/src/lib/api/orders.ts +0 -53
- package/src/lib/api/products.ts +0 -51
- package/src/lib/api-adapter/auth-adapter.ts +0 -196
- package/src/lib/api-adapter/cart-adapter.ts +0 -193
- package/src/lib/api-adapter/mappers.ts +0 -152
- package/src/lib/api-adapter/orders-adapter.ts +0 -195
- package/src/lib/api-adapter/products-adapter.ts +0 -194
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
# Hey Pharmacist E
|
|
1
|
+
# Hey Pharmacist E‑commerce
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Production‑ready, multi‑tenant e‑commerce UI + API adapter for Next.js. It ships with end‑to‑end flows (browse, cart, checkout, orders), robust authentication, typed SDKs, and a polished pharmacist‑grade UX. Drop it into a Next.js app, point it at your API, and ship a beautiful store in hours—not weeks.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Highlights
|
|
6
6
|
|
|
7
|
-
- 🛒 **Complete
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
7
|
+
- 🛒 **Complete flows**: Shop, product details, wishlist, cart, checkout, orders (history + current)
|
|
8
|
+
- 🔐 **Auth built‑in**: Sign up/in, profile, token persistence, background rehydration
|
|
9
|
+
- 💳 **Payments**: Card/Cash/Credit modes; Stripe‑ready checkout handoff
|
|
10
|
+
- 🧩 **Typed API adapters**: Generated axios SDK under `src/lib/Apis` with bearer + store key headers
|
|
11
|
+
- 🎨 **Themeable**: Brand colors + configurable header gradient via `EcommerceConfig`
|
|
12
|
+
- 🧠 **Smart UX**: Skeletons, optimistic UI, searchable overflow filters, and mobile‑first layouts
|
|
13
|
+
- 🧱 **Composable**: Use our screens, or import atomic components and hooks
|
|
14
|
+
- ⚡ **Production‑grade**: Tree‑shakable build, types, sourcemaps, React 18, Next 14
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
16
17
|
|
|
@@ -20,7 +21,7 @@ npm install hey-pharmacist-ecommerce react-hook-form @hookform/resolvers
|
|
|
20
21
|
|
|
21
22
|
## Quick Start
|
|
22
23
|
|
|
23
|
-
### 1
|
|
24
|
+
### 1) Configure your store
|
|
24
25
|
|
|
25
26
|
Create a config file for your store:
|
|
26
27
|
|
|
@@ -40,7 +41,7 @@ export const ecommerceConfig = {
|
|
|
40
41
|
};
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
### 2
|
|
44
|
+
### 2) Wrap your app
|
|
44
45
|
|
|
45
46
|
```tsx
|
|
46
47
|
// app/layout.tsx
|
|
@@ -64,7 +65,7 @@ export default function RootLayout({
|
|
|
64
65
|
}
|
|
65
66
|
```
|
|
66
67
|
|
|
67
|
-
### 3
|
|
68
|
+
### 3) Use the screens
|
|
68
69
|
|
|
69
70
|
```tsx
|
|
70
71
|
// app/shop/page.tsx
|
|
@@ -75,7 +76,7 @@ export default function ShopPage() {
|
|
|
75
76
|
}
|
|
76
77
|
```
|
|
77
78
|
|
|
78
|
-
## Available
|
|
79
|
+
## Available screens
|
|
79
80
|
|
|
80
81
|
- `<ShopScreen />` - Product listing with filters
|
|
81
82
|
- `<ProductDetailScreen />` - Individual product page
|
|
@@ -87,9 +88,26 @@ export default function ShopPage() {
|
|
|
87
88
|
- `<OrdersScreen />` - Order history
|
|
88
89
|
- `<CurrentOrdersScreen />` - Active orders
|
|
89
90
|
|
|
90
|
-
##
|
|
91
|
+
## Theming and customization
|
|
91
92
|
|
|
92
|
-
The package
|
|
93
|
+
The package exposes CSS variables for theme colors and a dynamic header gradient. Update via `EcommerceConfig`:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
headerGradient?: { from: string; via: string; to: string } // hex colors
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Under the hood, `ThemeProvider` sets `--color-<brand>-<shade>` and:
|
|
100
|
+
|
|
101
|
+
```css
|
|
102
|
+
from: rgb(var(--header-from));
|
|
103
|
+
via: rgb(var(--header-via));
|
|
104
|
+
to: rgb(var(--header-to));
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Update colors/gradient at runtime and the UI updates automatically.
|
|
108
|
+
|
|
109
|
+
### Using individual components
|
|
110
|
+
You can import components like `Header`, `Footer`, `ProductCard`, `OrderCard`, and UI primitives (`Button`, `Input`, `Modal`, etc.) for bespoke pages.
|
|
93
111
|
|
|
94
112
|
## Requirements
|
|
95
113
|
|
|
@@ -97,6 +115,128 @@ The package uses CSS variables for theming. Your colors are automatically applie
|
|
|
97
115
|
- Next.js 14+
|
|
98
116
|
- react-hook-form 7+
|
|
99
117
|
|
|
118
|
+
## Architecture
|
|
119
|
+
|
|
120
|
+
- Screens (page‑level flows) under `src/screens`
|
|
121
|
+
- Providers for Auth, Cart, Wishlist, Theme under `src/providers`
|
|
122
|
+
- Hooks for products, orders, wishlist, addresses under `src/hooks`
|
|
123
|
+
- Generated API SDK under `src/lib/Apis` (axios + typed models)
|
|
124
|
+
- API adapter bridge under `src/lib/api-adapter`
|
|
125
|
+
|
|
126
|
+
Auth persists access token using `localStorage` and rehydrates on load. Requests attach `x-store-key` and `Authorization: Bearer` automatically.
|
|
127
|
+
|
|
128
|
+
## Local development & testing
|
|
129
|
+
|
|
130
|
+
### Testing locally before publishing
|
|
131
|
+
|
|
132
|
+
You can test the package locally in your frontend project using npm link:
|
|
133
|
+
|
|
134
|
+
#### Step 1: Build and Link the Package
|
|
135
|
+
|
|
136
|
+
In this package directory:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Build the package
|
|
140
|
+
npm run build
|
|
141
|
+
|
|
142
|
+
# Create a global symlink
|
|
143
|
+
npm link
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
For active development with auto-rebuild:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Watch mode - rebuilds on file changes
|
|
150
|
+
npm run build:watch
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Step 2: Link in Your Frontend Project
|
|
154
|
+
|
|
155
|
+
In your frontend project directory:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Link to the local package
|
|
159
|
+
npm link hey-pharmacist-ecommerce
|
|
160
|
+
|
|
161
|
+
# Install peer dependencies if not already installed
|
|
162
|
+
npm install react react-dom next react-hook-form @hookform/resolvers
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### Step 3: Use the Package
|
|
166
|
+
|
|
167
|
+
Now you can use the package in your frontend as if it were installed from npm:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
// app/ecommerce.config.ts
|
|
171
|
+
import { EcommerceConfig } from 'hey-pharmacist-ecommerce';
|
|
172
|
+
|
|
173
|
+
export const config: EcommerceConfig = {
|
|
174
|
+
storeId: '68e3b34ca07948e882f9418f',
|
|
175
|
+
storeName: 'Briarmill Pharmacy',
|
|
176
|
+
logo: '/logo.png',
|
|
177
|
+
colors: {
|
|
178
|
+
primary: '#EF821F',
|
|
179
|
+
secondary: '#8B5CF6',
|
|
180
|
+
accent: '#10B981',
|
|
181
|
+
},
|
|
182
|
+
apiBaseUrl: 'https://api.heypharmacist.com',
|
|
183
|
+
stripePublicKey: 'pk_test_...',
|
|
184
|
+
};
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
// app/layout.tsx
|
|
189
|
+
import { EcommerceProvider } from 'hey-pharmacist-ecommerce';
|
|
190
|
+
import { config } from './ecommerce.config';
|
|
191
|
+
|
|
192
|
+
export default function RootLayout({ children }) {
|
|
193
|
+
return (
|
|
194
|
+
<html lang="en">
|
|
195
|
+
<body>
|
|
196
|
+
<EcommerceProvider config={config}>
|
|
197
|
+
{children}
|
|
198
|
+
</EcommerceProvider>
|
|
199
|
+
</body>
|
|
200
|
+
</html>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### Step 4: Test Your Changes
|
|
206
|
+
|
|
207
|
+
Make changes to the package source code, and:
|
|
208
|
+
- If using `npm run build:watch`, changes rebuild automatically
|
|
209
|
+
- If not, run `npm run build` after each change
|
|
210
|
+
- Refresh your frontend to see the changes
|
|
211
|
+
|
|
212
|
+
#### Step 5: Unlink When Done
|
|
213
|
+
|
|
214
|
+
When you're ready to use the published version:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# In your frontend project
|
|
218
|
+
npm unlink hey-pharmacist-ecommerce
|
|
219
|
+
npm install hey-pharmacist-ecommerce@latest
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Publishing to npm
|
|
223
|
+
|
|
224
|
+
When everything works as expected:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Update version (will auto-build before publish)
|
|
228
|
+
npm version patch # or minor, or major
|
|
229
|
+
|
|
230
|
+
# Publish to npm
|
|
231
|
+
npm publish
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Troubleshooting
|
|
235
|
+
|
|
236
|
+
- Types not emitted: ensure `tsup` dts is enabled and `tsconfig` does not use incremental for dts build.
|
|
237
|
+
- 401 after refresh: confirm `AuthProvider` calls `setAuthToken` on login/register and that `initializeApiAdapter` runs at app boot.
|
|
238
|
+
- Filters not working server‑side: pass `orderStatus` and `paymentStatus` to `useOrders` to forward to `getAllOrders`.
|
|
239
|
+
|
|
100
240
|
## License
|
|
101
241
|
|
|
102
|
-
MIT
|
|
242
|
+
MIT
|