hey-pharmacist-ecommerce 1.0.1 → 1.0.3
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 +45 -212
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,71 +1,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Hey Pharmacist E-commerce Package
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A multi-tenant e-commerce package for Next.js applications with stunning design and full functionality.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
- 💳 **Stripe Integration
|
|
11
|
-
-
|
|
12
|
-
- 📱 **Responsive
|
|
13
|
-
- ⚡ **
|
|
14
|
-
- 🎭 **Animations** - Smooth transitions with Framer Motion
|
|
7
|
+
- 🛒 **Complete E-commerce Flow**: Shop, cart, checkout, orders
|
|
8
|
+
- 🎨 **Stunning Design**: Modern UI with smooth animations
|
|
9
|
+
- 🔐 **Authentication**: Login, register, profile management
|
|
10
|
+
- 💳 **Stripe Integration**: Secure payment processing
|
|
11
|
+
- 🏪 **Multi-tenant**: Single package, multiple stores
|
|
12
|
+
- 📱 **Responsive**: Works on all devices
|
|
13
|
+
- ⚡ **Fast**: Optimized for performance
|
|
15
14
|
|
|
16
15
|
## Installation
|
|
17
16
|
|
|
18
17
|
```bash
|
|
19
|
-
npm install hey-pharmacist-ecommerce
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Peer Dependencies
|
|
23
|
-
|
|
24
|
-
Make sure you have these installed in your project:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install react@^18.0.0 react-dom@^18.0.0 next@^14.0.0
|
|
18
|
+
npm install hey-pharmacist-ecommerce react-hook-form @hookform/resolvers
|
|
28
19
|
```
|
|
29
20
|
|
|
30
21
|
## Quick Start
|
|
31
22
|
|
|
32
|
-
### 1.
|
|
23
|
+
### 1. Configure Your Store
|
|
33
24
|
|
|
34
|
-
Create a
|
|
25
|
+
Create a config file for your store:
|
|
35
26
|
|
|
36
27
|
```typescript
|
|
37
28
|
// ecommerce.config.ts
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
storeName: 'Your Store Name',
|
|
43
|
-
logo: '/logo.png',
|
|
29
|
+
export const ecommerceConfig = {
|
|
30
|
+
storeId: "your-store-id",
|
|
31
|
+
storeName: "Your Store Name",
|
|
32
|
+
logo: "/path/to/logo.png",
|
|
44
33
|
colors: {
|
|
45
|
-
primary:
|
|
46
|
-
secondary:
|
|
47
|
-
accent:
|
|
34
|
+
primary: "#3B82F6",
|
|
35
|
+
secondary: "#1E40AF",
|
|
36
|
+
accent: "#F59E0B",
|
|
48
37
|
},
|
|
49
|
-
apiBaseUrl:
|
|
50
|
-
stripePublicKey:
|
|
38
|
+
apiBaseUrl: "https://your-api.com",
|
|
39
|
+
stripePublicKey: "pk_test_...",
|
|
51
40
|
};
|
|
52
41
|
```
|
|
53
42
|
|
|
54
43
|
### 2. Wrap Your App
|
|
55
44
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
// app/layout.tsx (App Router)
|
|
45
|
+
```tsx
|
|
46
|
+
// app/layout.tsx
|
|
60
47
|
import { EcommerceProvider } from 'hey-pharmacist-ecommerce';
|
|
61
|
-
import {
|
|
62
|
-
import 'hey-pharmacist-ecommerce/styles/globals.css';
|
|
48
|
+
import { ecommerceConfig } from './ecommerce.config';
|
|
63
49
|
|
|
64
|
-
export default function RootLayout({
|
|
50
|
+
export default function RootLayout({
|
|
51
|
+
children,
|
|
52
|
+
}: {
|
|
53
|
+
children: React.ReactNode;
|
|
54
|
+
}) {
|
|
65
55
|
return (
|
|
66
56
|
<html lang="en">
|
|
67
57
|
<body>
|
|
68
|
-
<EcommerceProvider config={
|
|
58
|
+
<EcommerceProvider config={ecommerceConfig}>
|
|
69
59
|
{children}
|
|
70
60
|
</EcommerceProvider>
|
|
71
61
|
</body>
|
|
@@ -74,9 +64,9 @@ export default function RootLayout({ children }) {
|
|
|
74
64
|
}
|
|
75
65
|
```
|
|
76
66
|
|
|
77
|
-
### 3. Use Screens
|
|
67
|
+
### 3. Use the Screens
|
|
78
68
|
|
|
79
|
-
```
|
|
69
|
+
```tsx
|
|
80
70
|
// app/shop/page.tsx
|
|
81
71
|
import { ShopScreen } from 'hey-pharmacist-ecommerce';
|
|
82
72
|
|
|
@@ -87,183 +77,26 @@ export default function ShopPage() {
|
|
|
87
77
|
|
|
88
78
|
## Available Screens
|
|
89
79
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
- `<
|
|
93
|
-
- `<
|
|
94
|
-
- `<CartScreen />` - Shopping cart management
|
|
95
|
-
- `<CheckoutScreen />` - Checkout form with Stripe integration
|
|
80
|
+
- `<ShopScreen />` - Product listing with filters
|
|
81
|
+
- `<ProductDetailScreen />` - Individual product page
|
|
82
|
+
- `<CartScreen />` - Shopping cart
|
|
83
|
+
- `<CheckoutScreen />` - Checkout flow
|
|
96
84
|
- `<LoginScreen />` - User login
|
|
97
85
|
- `<RegisterScreen />` - User registration
|
|
98
|
-
- `<ProfileScreen />` - User profile
|
|
86
|
+
- `<ProfileScreen />` - User profile
|
|
99
87
|
- `<OrdersScreen />` - Order history
|
|
100
|
-
- `<CurrentOrdersScreen />` - Active orders
|
|
101
|
-
|
|
102
|
-
## Components
|
|
103
|
-
|
|
104
|
-
Reusable components for custom pages:
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
import {
|
|
108
|
-
Header,
|
|
109
|
-
Footer,
|
|
110
|
-
ProductCard,
|
|
111
|
-
CartItem,
|
|
112
|
-
OrderCard,
|
|
113
|
-
Button,
|
|
114
|
-
Input,
|
|
115
|
-
Badge,
|
|
116
|
-
Modal,
|
|
117
|
-
} from 'hey-pharmacist-ecommerce';
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Hooks
|
|
121
|
-
|
|
122
|
-
Custom hooks for data fetching:
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
import {
|
|
126
|
-
useAuth,
|
|
127
|
-
useCart,
|
|
128
|
-
useProducts,
|
|
129
|
-
useProduct,
|
|
130
|
-
useFeaturedProducts,
|
|
131
|
-
useCategories,
|
|
132
|
-
useOrders,
|
|
133
|
-
useCurrentOrders,
|
|
134
|
-
} from 'hey-pharmacist-ecommerce';
|
|
135
|
-
|
|
136
|
-
function MyComponent() {
|
|
137
|
-
const { user, login, logout } = useAuth();
|
|
138
|
-
const { cart, addToCart, removeFromCart } = useCart();
|
|
139
|
-
const { products, isLoading } = useProducts();
|
|
140
|
-
|
|
141
|
-
// ... your component logic
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## API Integration
|
|
146
|
-
|
|
147
|
-
The package automatically handles:
|
|
148
|
-
- Store ID injection in all requests
|
|
149
|
-
- Authentication tokens
|
|
150
|
-
- Token refresh
|
|
151
|
-
- Error handling
|
|
152
|
-
|
|
153
|
-
### Expected Backend Endpoints
|
|
154
|
-
|
|
155
|
-
Your backend should implement these endpoints:
|
|
156
|
-
|
|
157
|
-
**Products**
|
|
158
|
-
- `GET /products` - List products (with pagination, filters)
|
|
159
|
-
- `GET /products/:id` - Get product details
|
|
160
|
-
- `GET /products/featured` - Get featured products
|
|
161
|
-
- `GET /categories` - List categories
|
|
162
|
-
|
|
163
|
-
**Cart**
|
|
164
|
-
- `GET /cart` - Get user's cart
|
|
165
|
-
- `POST /cart/items` - Add item to cart
|
|
166
|
-
- `PUT /cart/items/:productId` - Update item quantity
|
|
167
|
-
- `DELETE /cart/items/:productId` - Remove item from cart
|
|
168
|
-
|
|
169
|
-
**Orders**
|
|
170
|
-
- `GET /orders` - List user's orders
|
|
171
|
-
- `GET /orders/current` - Get active orders
|
|
172
|
-
- `GET /orders/:id` - Get order details
|
|
173
|
-
- `POST /orders` - Create new order (returns Stripe checkout URL)
|
|
174
|
-
|
|
175
|
-
**Auth**
|
|
176
|
-
- `POST /auth/register` - Register new user
|
|
177
|
-
- `POST /auth/login` - Login user
|
|
178
|
-
- `GET /auth/me` - Get current user
|
|
179
|
-
- `PUT /auth/profile` - Update profile
|
|
180
|
-
- `POST /auth/logout` - Logout
|
|
181
|
-
|
|
182
|
-
All requests include:
|
|
183
|
-
- Header: `X-Store-Id: your-store-id`
|
|
184
|
-
- Header: `Authorization: Bearer <token>` (when authenticated)
|
|
88
|
+
- `<CurrentOrdersScreen />` - Active orders
|
|
185
89
|
|
|
186
|
-
##
|
|
90
|
+
## Customization
|
|
187
91
|
|
|
188
|
-
The package uses
|
|
92
|
+
The package uses CSS variables for theming. Your colors are automatically applied throughout the interface.
|
|
189
93
|
|
|
190
|
-
|
|
191
|
-
import 'hey-pharmacist-ecommerce/styles/globals.css';
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Customize Tailwind
|
|
195
|
-
|
|
196
|
-
Extend the default Tailwind config if needed:
|
|
197
|
-
|
|
198
|
-
```javascript
|
|
199
|
-
// tailwind.config.js
|
|
200
|
-
module.exports = {
|
|
201
|
-
content: [
|
|
202
|
-
'./app/**/*.{js,ts,jsx,tsx}',
|
|
203
|
-
'./node_modules/hey-pharmacist-ecommerce/**/*.{js,ts,jsx,tsx}',
|
|
204
|
-
],
|
|
205
|
-
// ... your config
|
|
206
|
-
};
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## Example Routes
|
|
94
|
+
## Requirements
|
|
210
95
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
/shop → <ShopScreen />
|
|
215
|
-
/products/[id] → <ProductDetailScreen productId={id} />
|
|
216
|
-
/cart → <CartScreen />
|
|
217
|
-
/checkout → <CheckoutScreen />
|
|
218
|
-
/login → <LoginScreen />
|
|
219
|
-
/register → <RegisterScreen />
|
|
220
|
-
/account → <ProfileScreen />
|
|
221
|
-
/orders → <OrdersScreen />
|
|
222
|
-
/orders/current → <CurrentOrdersScreen />
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
## TypeScript Support
|
|
226
|
-
|
|
227
|
-
Full TypeScript support with exported types:
|
|
228
|
-
|
|
229
|
-
```typescript
|
|
230
|
-
import type {
|
|
231
|
-
EcommerceConfig,
|
|
232
|
-
Product,
|
|
233
|
-
Cart,
|
|
234
|
-
Order,
|
|
235
|
-
User,
|
|
236
|
-
} from 'hey-pharmacist-ecommerce';
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
## Advanced Usage
|
|
240
|
-
|
|
241
|
-
### Custom API Client
|
|
242
|
-
|
|
243
|
-
If you need to make custom API calls:
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
import { getApiClient } from 'hey-pharmacist-ecommerce';
|
|
247
|
-
|
|
248
|
-
const apiClient = getApiClient();
|
|
249
|
-
const response = await apiClient.get('/custom-endpoint');
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
### Direct API Access
|
|
253
|
-
|
|
254
|
-
```typescript
|
|
255
|
-
import { productsApi, authApi, cartApi, ordersApi } from 'hey-pharmacist-ecommerce';
|
|
256
|
-
|
|
257
|
-
// Use API methods directly
|
|
258
|
-
const products = await productsApi.getProducts({ category: 'electronics' });
|
|
259
|
-
const order = await ordersApi.getOrder('order-id');
|
|
260
|
-
```
|
|
96
|
+
- React 18+
|
|
97
|
+
- Next.js 14+
|
|
98
|
+
- react-hook-form 7+
|
|
261
99
|
|
|
262
100
|
## License
|
|
263
101
|
|
|
264
|
-
MIT
|
|
265
|
-
|
|
266
|
-
## Support
|
|
267
|
-
|
|
268
|
-
For issues and questions, please open an issue on GitHub.
|
|
269
|
-
|
|
102
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hey-pharmacist-ecommerce",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Multi-tenant e-commerce package for Next.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"@hookform/resolvers": "^3.3.0",
|
|
24
24
|
"sonner": "^1.2.0",
|
|
25
25
|
"zustand": "^4.4.0",
|
|
26
|
-
"cookies-next": "^4.0.0"
|
|
26
|
+
"cookies-next": "^4.0.0",
|
|
27
|
+
"react-hook-form": "^7.48.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@types/node": "^20.0.0",
|
|
@@ -38,8 +39,7 @@
|
|
|
38
39
|
"eslint-config-next": "^14.0.0",
|
|
39
40
|
"react": "^18.2.0",
|
|
40
41
|
"react-dom": "^18.2.0",
|
|
41
|
-
"next": "^14.0.0"
|
|
42
|
-
"react-hook-form": "^7.48.0"
|
|
42
|
+
"next": "^14.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "^18.0.0",
|