hey-pharmacist-ecommerce 1.1.20 → 1.1.23

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/dist/index.js CHANGED
@@ -61,6 +61,21 @@ var init_configuration = __esm({
61
61
  }
62
62
  });
63
63
 
64
+ // src/lib/Apis/sharedConfig.ts
65
+ var AXIOS_CONFIG;
66
+ var init_sharedConfig = __esm({
67
+ "src/lib/Apis/sharedConfig.ts"() {
68
+ init_configuration();
69
+ AXIOS_CONFIG = new Configuration({
70
+ basePath: "https://api.heypharmacist.com",
71
+ // Default fallback
72
+ baseOptions: {
73
+ timeout: 2e4
74
+ }
75
+ });
76
+ }
77
+ });
78
+
64
79
  // src/lib/api-adapter/config.ts
65
80
  var config_exports = {};
66
81
  __export(config_exports, {
@@ -73,13 +88,10 @@ __export(config_exports, {
73
88
  });
74
89
  function initializeApiAdapter(config) {
75
90
  currentConfig = config;
76
- apiConfiguration = new Configuration({
77
- basePath: config.apiBaseUrl,
78
- apiKey: () => config.storeId,
79
- // x-store-key header
80
- accessToken: () => getAuthToken() || ""
81
- // Bearer token
82
- });
91
+ AXIOS_CONFIG.basePath = config.apiBaseUrl;
92
+ AXIOS_CONFIG.apiKey = config.storeId;
93
+ AXIOS_CONFIG.accessToken = () => getAuthToken() || "";
94
+ apiConfiguration = AXIOS_CONFIG;
83
95
  return apiConfiguration;
84
96
  }
85
97
  function getApiConfiguration() {
@@ -104,6 +116,7 @@ function setAuthToken(token) {
104
116
  if (apiConfiguration) {
105
117
  apiConfiguration.accessToken = () => token;
106
118
  }
119
+ AXIOS_CONFIG.accessToken = () => token;
107
120
  }
108
121
  }
109
122
  function getAuthToken() {
@@ -118,12 +131,13 @@ function clearAuthToken() {
118
131
  if (apiConfiguration) {
119
132
  apiConfiguration.accessToken = () => "";
120
133
  }
134
+ AXIOS_CONFIG.accessToken = () => "";
121
135
  }
122
136
  }
123
137
  var apiConfiguration, currentConfig;
124
138
  var init_config = __esm({
125
139
  "src/lib/api-adapter/config.ts"() {
126
- init_configuration();
140
+ init_sharedConfig();
127
141
  apiConfiguration = null;
128
142
  currentConfig = null;
129
143
  }
@@ -5314,6 +5328,45 @@ var ProductsApiAxiosParamCreator = function(configuration) {
5314
5328
  options: localVarRequestOptions
5315
5329
  };
5316
5330
  },
5331
+ /**
5332
+ *
5333
+ * @summary Get the featured product for home screen
5334
+ * @param {*} [options] Override http request option.
5335
+ * @throws {RequiredError}
5336
+ */
5337
+ getFeaturedProduct: async (options = {}) => {
5338
+ const localVarPath = `/products/featured`;
5339
+ const localVarUrlObj = new URL(localVarPath, "https://example.com");
5340
+ let baseOptions;
5341
+ if (configuration) {
5342
+ baseOptions = configuration.baseOptions;
5343
+ }
5344
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
5345
+ const localVarHeaderParameter = {};
5346
+ const localVarQueryParameter = {};
5347
+ if (configuration && configuration.accessToken) {
5348
+ const accessToken = typeof configuration.accessToken === "function" ? await configuration.accessToken() : await configuration.accessToken;
5349
+ localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
5350
+ }
5351
+ if (configuration && configuration.apiKey) {
5352
+ const localVarApiKeyValue = typeof configuration.apiKey === "function" ? await configuration.apiKey("x-store-key") : await configuration.apiKey;
5353
+ localVarHeaderParameter["x-store-key"] = localVarApiKeyValue;
5354
+ }
5355
+ const query = new URLSearchParams(localVarUrlObj.search);
5356
+ for (const key in localVarQueryParameter) {
5357
+ query.set(key, localVarQueryParameter[key]);
5358
+ }
5359
+ for (const key in options.params) {
5360
+ query.set(key, options.params[key]);
5361
+ }
5362
+ localVarUrlObj.search = new URLSearchParams(query).toString();
5363
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
5364
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
5365
+ return {
5366
+ url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
5367
+ options: localVarRequestOptions
5368
+ };
5369
+ },
5317
5370
  /**
5318
5371
  *
5319
5372
  * @summary Get insights on store Products
@@ -5494,6 +5547,56 @@ var ProductsApiAxiosParamCreator = function(configuration) {
5494
5547
  options: localVarRequestOptions
5495
5548
  };
5496
5549
  },
5550
+ /**
5551
+ *
5552
+ * @summary Set or unset a product as featured for home screen
5553
+ * @param {string} id Product ID
5554
+ * @param {boolean} featured Whether to set the product as featured
5555
+ * @param {*} [options] Override http request option.
5556
+ * @throws {RequiredError}
5557
+ */
5558
+ setFeaturedProduct: async (id, featured, options = {}) => {
5559
+ if (id === null || id === void 0) {
5560
+ throw new RequiredError("id", "Required parameter id was null or undefined when calling setFeaturedProduct.");
5561
+ }
5562
+ if (featured === null || featured === void 0) {
5563
+ throw new RequiredError("featured", "Required parameter featured was null or undefined when calling setFeaturedProduct.");
5564
+ }
5565
+ const localVarPath = `/products/{id}/featured`.replace(`{${"id"}}`, encodeURIComponent(String(id)));
5566
+ const localVarUrlObj = new URL(localVarPath, "https://example.com");
5567
+ let baseOptions;
5568
+ if (configuration) {
5569
+ baseOptions = configuration.baseOptions;
5570
+ }
5571
+ const localVarRequestOptions = { method: "PATCH", ...baseOptions, ...options };
5572
+ const localVarHeaderParameter = {};
5573
+ const localVarQueryParameter = {};
5574
+ if (configuration && configuration.accessToken) {
5575
+ const accessToken = typeof configuration.accessToken === "function" ? await configuration.accessToken() : await configuration.accessToken;
5576
+ localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
5577
+ }
5578
+ if (configuration && configuration.apiKey) {
5579
+ const localVarApiKeyValue = typeof configuration.apiKey === "function" ? await configuration.apiKey("x-store-key") : await configuration.apiKey;
5580
+ localVarHeaderParameter["x-store-key"] = localVarApiKeyValue;
5581
+ }
5582
+ if (featured !== void 0) {
5583
+ localVarQueryParameter["featured"] = featured;
5584
+ }
5585
+ const query = new URLSearchParams(localVarUrlObj.search);
5586
+ for (const key in localVarQueryParameter) {
5587
+ query.set(key, localVarQueryParameter[key]);
5588
+ }
5589
+ for (const key in options.params) {
5590
+ query.set(key, options.params[key]);
5591
+ }
5592
+ localVarUrlObj.search = new URLSearchParams(query).toString();
5593
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
5594
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
5595
+ return {
5596
+ url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
5597
+ options: localVarRequestOptions
5598
+ };
5599
+ },
5497
5600
  /**
5498
5601
  *
5499
5602
  * @summary Update a product
@@ -5677,6 +5780,19 @@ var ProductsApiFp = function(configuration) {
5677
5780
  return axios.request(axiosRequestArgs);
5678
5781
  };
5679
5782
  },
5783
+ /**
5784
+ *
5785
+ * @summary Get the featured product for home screen
5786
+ * @param {*} [options] Override http request option.
5787
+ * @throws {RequiredError}
5788
+ */
5789
+ async getFeaturedProduct(options) {
5790
+ const localVarAxiosArgs = await ProductsApiAxiosParamCreator(configuration).getFeaturedProduct(options);
5791
+ return (axios = globalAxios4__default.default, basePath = BASE_PATH) => {
5792
+ const axiosRequestArgs = { ...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url };
5793
+ return axios.request(axiosRequestArgs);
5794
+ };
5795
+ },
5680
5796
  /**
5681
5797
  *
5682
5798
  * @summary Get insights on store Products
@@ -5735,6 +5851,21 @@ var ProductsApiFp = function(configuration) {
5735
5851
  return axios.request(axiosRequestArgs);
5736
5852
  };
5737
5853
  },
5854
+ /**
5855
+ *
5856
+ * @summary Set or unset a product as featured for home screen
5857
+ * @param {string} id Product ID
5858
+ * @param {boolean} featured Whether to set the product as featured
5859
+ * @param {*} [options] Override http request option.
5860
+ * @throws {RequiredError}
5861
+ */
5862
+ async setFeaturedProduct(id, featured, options) {
5863
+ const localVarAxiosArgs = await ProductsApiAxiosParamCreator(configuration).setFeaturedProduct(id, featured, options);
5864
+ return (axios = globalAxios4__default.default, basePath = BASE_PATH) => {
5865
+ const axiosRequestArgs = { ...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url };
5866
+ return axios.request(axiosRequestArgs);
5867
+ };
5868
+ },
5738
5869
  /**
5739
5870
  *
5740
5871
  * @summary Update a product
@@ -5861,6 +5992,16 @@ var ProductsApi = class extends BaseAPI {
5861
5992
  async getAllProductsForStore(searchTerm, productType, categoryId, maxPrice, minPrice, brandFilter, availability, sort, includeNoVariantProducts, isActive, limit, page, options) {
5862
5993
  return ProductsApiFp(this.configuration).getAllProductsForStore(searchTerm, productType, categoryId, maxPrice, minPrice, brandFilter, availability, sort, includeNoVariantProducts, isActive, limit, page, options).then((request) => request(this.axios, this.basePath));
5863
5994
  }
5995
+ /**
5996
+ *
5997
+ * @summary Get the featured product for home screen
5998
+ * @param {*} [options] Override http request option.
5999
+ * @throws {RequiredError}
6000
+ * @memberof ProductsApi
6001
+ */
6002
+ async getFeaturedProduct(options) {
6003
+ return ProductsApiFp(this.configuration).getFeaturedProduct(options).then((request) => request(this.axios, this.basePath));
6004
+ }
5864
6005
  /**
5865
6006
  *
5866
6007
  * @summary Get insights on store Products
@@ -5907,6 +6048,18 @@ var ProductsApi = class extends BaseAPI {
5907
6048
  async getTopSellingProducts(limit, page, isActive, includeNoVariantProducts, options) {
5908
6049
  return ProductsApiFp(this.configuration).getTopSellingProducts(limit, page, isActive, includeNoVariantProducts, options).then((request) => request(this.axios, this.basePath));
5909
6050
  }
6051
+ /**
6052
+ *
6053
+ * @summary Set or unset a product as featured for home screen
6054
+ * @param {string} id Product ID
6055
+ * @param {boolean} featured Whether to set the product as featured
6056
+ * @param {*} [options] Override http request option.
6057
+ * @throws {RequiredError}
6058
+ * @memberof ProductsApi
6059
+ */
6060
+ async setFeaturedProduct(id, featured, options) {
6061
+ return ProductsApiFp(this.configuration).setFeaturedProduct(id, featured, options).then((request) => request(this.axios, this.basePath));
6062
+ }
5910
6063
  /**
5911
6064
  *
5912
6065
  * @summary Update a product
@@ -6924,6 +7077,10 @@ function CartProvider({ children }) {
6924
7077
  const [isLoading, setIsLoading] = React8.useState(false);
6925
7078
  const { isAuthenticated } = useAuth();
6926
7079
  const notification = useNotification();
7080
+ const cartRef = React8.useRef(cart);
7081
+ React8.useEffect(() => {
7082
+ cartRef.current = cart;
7083
+ }, [cart]);
6927
7084
  const refreshCart = React8.useCallback(async () => {
6928
7085
  if (!isAuthenticated) {
6929
7086
  setCart(null);
@@ -6931,7 +7088,9 @@ function CartProvider({ children }) {
6931
7088
  }
6932
7089
  try {
6933
7090
  const response = await new CartApi(getApiConfiguration()).getUserCart();
6934
- setCart(response.data);
7091
+ if (response.data) {
7092
+ setCart(response.data);
7093
+ }
6935
7094
  } catch (error) {
6936
7095
  console.error("Failed to fetch cart:", error);
6937
7096
  }
@@ -6939,99 +7098,159 @@ function CartProvider({ children }) {
6939
7098
  React8.useEffect(() => {
6940
7099
  refreshCart();
6941
7100
  }, [refreshCart]);
6942
- const addToCart = async (productId, quantity = 1, variantId) => {
7101
+ const addToCart = React8.useCallback(async (productId, quantity = 1, variantId) => {
7102
+ if (!isAuthenticated) return;
6943
7103
  setIsLoading(true);
6944
7104
  try {
6945
- const currentItems = cart?.cartBody?.items || [];
7105
+ const currentCart = cartRef.current;
7106
+ const currentItems = currentCart?.cartBody?.items || [];
6946
7107
  const targetVariantId = variantId || productId;
6947
- const existingItemIndex = currentItems.findIndex(
6948
- (item) => item.productVariantId === targetVariantId
6949
- );
6950
- const items = [...currentItems];
6951
- if (existingItemIndex >= 0) {
6952
- items[existingItemIndex] = {
6953
- ...items[existingItemIndex],
6954
- quantity: (items[existingItemIndex].quantity || 0) + quantity
7108
+ let itemsFound = false;
7109
+ const simplifiedItems = currentItems.map((item) => {
7110
+ let q = Number(item.quantity) || 0;
7111
+ if (String(item.productVariantId) === String(targetVariantId)) {
7112
+ itemsFound = true;
7113
+ q += Number(quantity);
7114
+ }
7115
+ return {
7116
+ _id: item._id,
7117
+ productVariantId: item.productVariantId,
7118
+ quantity: q
6955
7119
  };
6956
- } else {
6957
- items.push({
7120
+ });
7121
+ if (!itemsFound) {
7122
+ simplifiedItems.push({
6958
7123
  productVariantId: targetVariantId,
6959
- quantity
7124
+ quantity: Number(quantity)
6960
7125
  });
6961
7126
  }
6962
- const response = await new CartApi(getApiConfiguration()).handleUserCart({ items });
6963
- setCart(response.data);
6964
- notification.success(
6965
- "Added to cart",
6966
- "The item was added to your cart."
6967
- );
7127
+ const payload = {
7128
+ _id: currentCart?.cartBody?._id,
7129
+ items: simplifiedItems
7130
+ };
7131
+ const response = await new CartApi(getApiConfiguration()).handleUserCart(payload);
7132
+ if (response.data) {
7133
+ setCart(response.data);
7134
+ notification.success("Added to cart", "The item was added to your cart.");
7135
+ }
6968
7136
  } catch (error) {
6969
- notification.error(
6970
- "Could not add to cart",
6971
- error.response?.data?.message || "Something went wrong while adding this item to your cart."
6972
- );
6973
- throw error;
7137
+ console.error("Add to cart error:", error);
7138
+ notification.error("Could not add to cart", error.response?.data?.message || "Something went wrong.");
6974
7139
  } finally {
6975
7140
  setIsLoading(false);
6976
7141
  }
6977
- };
6978
- const updateQuantity = async (productId, quantity) => {
7142
+ }, [isAuthenticated, notification]);
7143
+ const updateQuantity = React8.useCallback(async (productId, quantity) => {
7144
+ const currentCart = cartRef.current;
7145
+ if (!currentCart) return;
6979
7146
  setIsLoading(true);
6980
- try {
6981
- const currentItems = cart?.cartBody?.items || [];
6982
- const items = currentItems.map((item) => {
6983
- if (item.productVariantId === productId) {
6984
- return {
6985
- ...item,
6986
- quantity
6987
- };
7147
+ const targetQ = Number(quantity);
7148
+ const oldCart = currentCart;
7149
+ setCart((prev) => {
7150
+ if (!prev) return null;
7151
+ const newItems = prev.cartBody.items.map((item) => {
7152
+ if (String(item.productVariantId) === String(productId)) {
7153
+ return { ...item, quantity: targetQ };
6988
7154
  }
6989
7155
  return item;
6990
7156
  });
6991
- const response = await new CartApi(getApiConfiguration()).handleUserCart({ items });
6992
- setCart(response.data);
7157
+ const newSubtotal = newItems.reduce((acc, item) => acc + (item.productVariantData.finalPrice || 0) * item.quantity, 0);
7158
+ return {
7159
+ ...prev,
7160
+ subTotal: newSubtotal,
7161
+ total: newSubtotal + (prev.shipping || 0) + (prev.tax || 0),
7162
+ cartBody: { ...prev.cartBody, items: newItems }
7163
+ };
7164
+ });
7165
+ try {
7166
+ const simplifiedItems = oldCart.cartBody.items.map((item) => ({
7167
+ _id: item._id,
7168
+ productVariantId: item.productVariantId,
7169
+ quantity: String(item.productVariantId) === String(productId) ? targetQ : item.quantity
7170
+ }));
7171
+ const payload = {
7172
+ _id: oldCart.cartBody._id,
7173
+ items: simplifiedItems
7174
+ };
7175
+ console.log("payload", payload);
7176
+ const response = await new CartApi(getApiConfiguration()).handleUserCart(payload);
7177
+ if (response.data) {
7178
+ setCart(response.data);
7179
+ } else {
7180
+ await refreshCart();
7181
+ }
6993
7182
  } catch (error) {
6994
- notification.error(
6995
- "Could not update cart",
6996
- error.response?.data?.message || "There was a problem updating the item quantity. Please try again."
6997
- );
6998
- throw error;
7183
+ console.error("Update quantity error:", error);
7184
+ setCart(oldCart);
7185
+ notification.error("Could not update cart", error.response?.data?.message || "Failed to update quantity.");
6999
7186
  } finally {
7000
7187
  setIsLoading(false);
7001
7188
  }
7002
- };
7003
- const removeFromCart = async (productId) => {
7189
+ }, [notification, refreshCart]);
7190
+ const removeFromCart = React8.useCallback(async (productId) => {
7191
+ const currentCart = cartRef.current;
7192
+ if (!currentCart) return;
7004
7193
  setIsLoading(true);
7194
+ const oldCart = currentCart;
7195
+ setCart((prev) => {
7196
+ if (!prev) return null;
7197
+ const newItems = prev.cartBody.items.filter((item) => String(item.productVariantId) !== String(productId));
7198
+ const newSubtotal = newItems.reduce((acc, item) => acc + (item.productVariantData.finalPrice || 0) * item.quantity, 0);
7199
+ return {
7200
+ ...prev,
7201
+ subTotal: newSubtotal,
7202
+ total: newSubtotal + (prev.shipping || 0) + (prev.tax || 0),
7203
+ cartBody: { ...prev.cartBody, items: newItems }
7204
+ };
7205
+ });
7005
7206
  try {
7006
- const currentItems = cart?.cartBody?.items || [];
7007
- const items = currentItems.filter((item) => item.productVariantId !== productId);
7008
- const response = await new CartApi(getApiConfiguration()).handleUserCart({ items });
7009
- setCart(response.data);
7207
+ console.log("Removing item with productVariantId:", productId);
7208
+ const itemsToKeep = currentCart.cartBody.items.filter((item) => String(item.productVariantId) !== String(productId));
7209
+ console.log("Items to keep count:", itemsToKeep.length);
7210
+ const simplifiedItems = itemsToKeep.map((item) => ({
7211
+ _id: item._id,
7212
+ productVariantId: item.productVariantId,
7213
+ quantity: item.quantity
7214
+ }));
7215
+ if (simplifiedItems.length === 0) {
7216
+ console.log("Cart will be empty, calling clearCart");
7217
+ await new CartApi(getApiConfiguration()).clearCart();
7218
+ setCart(null);
7219
+ } else {
7220
+ const payload = {
7221
+ _id: currentCart.cartBody._id,
7222
+ items: simplifiedItems
7223
+ };
7224
+ console.log("Remove from cart payload:", JSON.stringify(payload, null, 2));
7225
+ const response = await new CartApi(getApiConfiguration()).handleUserCart(payload);
7226
+ console.log("Remove from cart response:", response.status, response.data);
7227
+ if (response.data) {
7228
+ setCart(response.data);
7229
+ }
7230
+ }
7010
7231
  } catch (error) {
7011
- notification.error(
7012
- "Could not remove item",
7013
- error.response?.data?.message || "There was a problem removing this item from your cart."
7014
- );
7015
- throw error;
7232
+ console.error("Remove from cart error:", error);
7233
+ if (error.response) {
7234
+ console.error("Error response data:", error.response.data);
7235
+ }
7236
+ setCart(oldCart);
7237
+ notification.error("Could not remove item", error.response?.data?.message || "Failed to remove item.");
7016
7238
  } finally {
7017
7239
  setIsLoading(false);
7018
7240
  }
7019
- };
7020
- const clearCart = async () => {
7241
+ }, [notification]);
7242
+ const clearCart = React8.useCallback(async () => {
7021
7243
  setIsLoading(true);
7022
7244
  try {
7023
- const response = await new CartApi(getApiConfiguration()).clearCart();
7245
+ await new CartApi(getApiConfiguration()).clearCart();
7024
7246
  setCart(null);
7025
7247
  } catch (error) {
7026
- notification.error(
7027
- "Could not clear cart",
7028
- error.response?.data?.message || "We could not clear your cart. Please try again."
7029
- );
7030
- throw error;
7248
+ console.error("Clear cart error:", error);
7249
+ notification.error("Could not clear cart", error.response?.data?.message || "Failed to clear cart.");
7031
7250
  } finally {
7032
7251
  setIsLoading(false);
7033
7252
  }
7034
- };
7253
+ }, [notification]);
7035
7254
  const value = {
7036
7255
  cart,
7037
7256
  isLoading,
@@ -7045,10 +7264,10 @@ function CartProvider({ children }) {
7045
7264
  }
7046
7265
 
7047
7266
  // src/lib/Apis/wrapper.ts
7048
- init_configuration();
7049
7267
  init_config();
7050
7268
  init_config();
7051
- var BaseUrl = "https://api.heypharmacist.com";
7269
+ init_sharedConfig();
7270
+ init_sharedConfig();
7052
7271
  globalAxios4__default.default.interceptors.request.use(async (config) => {
7053
7272
  if (!config?.headers) {
7054
7273
  throw new Error(
@@ -7066,22 +7285,16 @@ globalAxios4__default.default.interceptors.request.use(async (config) => {
7066
7285
  config.headers["X-Store-Key"] = ecommerceConfig.storeId;
7067
7286
  }
7068
7287
  } catch (error) {
7069
- console.warn("API configuration not initialized yet:", error);
7070
7288
  }
7071
7289
  }
7072
7290
  return config;
7073
7291
  });
7074
- var abortController;
7075
7292
  if (typeof window !== "undefined") {
7076
- abortController = new AbortController();
7077
- }
7078
- var AXIOS_CONFIG = new Configuration({
7079
- basePath: BaseUrl,
7080
- baseOptions: {
7081
- signal: abortController?.signal,
7082
- timeout: 2e4
7293
+ const abortController = new AbortController();
7294
+ if (AXIOS_CONFIG.baseOptions) {
7295
+ AXIOS_CONFIG.baseOptions.signal = abortController.signal;
7083
7296
  }
7084
- });
7297
+ }
7085
7298
  var WishlistContext = React8.createContext(void 0);
7086
7299
  function WishlistProvider({ children }) {
7087
7300
  const [state, setState] = React8.useState({
@@ -7250,7 +7463,7 @@ function useBasePath() {
7250
7463
  return ctx;
7251
7464
  }
7252
7465
  function EcommerceProvider({ config, children, withToaster = true, basePath = "" }) {
7253
- React8.useEffect(() => {
7466
+ React8__default.default.useMemo(() => {
7254
7467
  initializeApiAdapter(config);
7255
7468
  }, [config]);
7256
7469
  const [client] = React8__default.default.useState(
@@ -8977,6 +9190,7 @@ function ProductDetailScreen({ productId }) {
8977
9190
  const { buildPath } = useBasePath();
8978
9191
  const { product: productData, isLoading } = useProduct(productId);
8979
9192
  const { addToCart } = useCart();
9193
+ const { isAuthenticated } = useAuth();
8980
9194
  const notification = useNotification();
8981
9195
  const [selectedVariant, setSelectedVariant] = React8.useState(null);
8982
9196
  const [quantity, setQuantity] = React8.useState(1);
@@ -9095,6 +9309,14 @@ function ProductDetailScreen({ productId }) {
9095
9309
  setActiveImageIndex(0);
9096
9310
  };
9097
9311
  const handleAddToCart = async () => {
9312
+ if (!isAuthenticated) {
9313
+ notification.error(
9314
+ "Sign-in required",
9315
+ "Please sign in to add items to your cart."
9316
+ );
9317
+ router.push(buildPath(`/login?redirect=${encodeURIComponent(window.location.pathname + window.location.search)}`));
9318
+ return;
9319
+ }
9098
9320
  if (!product || !selectedVariant) return;
9099
9321
  setIsAddingToCart(true);
9100
9322
  try {
@@ -9367,7 +9589,7 @@ function ProductDetailScreen({ productId }) {
9367
9589
  )
9368
9590
  ] }),
9369
9591
  selectedVariant && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm text-slate-500", children: [
9370
- selectedVariant.inventoryCount || product.inventoryCount || 0,
9592
+ selectedVariant.inventoryCount || 0,
9371
9593
  " available"
9372
9594
  ] })
9373
9595
  ] })
@@ -9489,6 +9711,7 @@ function ProductDetailScreen({ productId }) {
9489
9711
  function CartItem({ item }) {
9490
9712
  const { updateQuantity, removeFromCart } = useCart();
9491
9713
  const [isUpdating, setIsUpdating] = React8.useState(false);
9714
+ const [isRemoving, setIsRemoving] = React8.useState(false);
9492
9715
  const handleUpdateQuantity = async (newQuantity) => {
9493
9716
  if (newQuantity < 1) return;
9494
9717
  setIsUpdating(true);
@@ -9499,7 +9722,12 @@ function CartItem({ item }) {
9499
9722
  }
9500
9723
  };
9501
9724
  const handleRemove = async () => {
9502
- await removeFromCart(item.productVariantId);
9725
+ setIsRemoving(true);
9726
+ try {
9727
+ await removeFromCart(item.productVariantId);
9728
+ } finally {
9729
+ setIsRemoving(false);
9730
+ }
9503
9731
  };
9504
9732
  const itemTotal = item.productVariantData.finalPrice * item.quantity;
9505
9733
  const unitPrice = item.productVariantData.finalPrice;
@@ -9544,9 +9772,10 @@ function CartItem({ item }) {
9544
9772
  "button",
9545
9773
  {
9546
9774
  onClick: handleRemove,
9547
- className: "p-2 hover:bg-red-50 rounded-full transition-colors group",
9775
+ disabled: isRemoving || isUpdating,
9776
+ className: `p-2 rounded-full transition-colors group ${isRemoving ? "bg-red-50 cursor-not-allowed" : "hover:bg-red-50"}`,
9548
9777
  "aria-label": "Remove item",
9549
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "size-5 text-[#676c80] group-hover:text-red-500 transition-colors" })
9778
+ children: isRemoving ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block h-5 w-5 animate-spin rounded-full border-2 border-red-500 border-t-transparent" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "size-5 text-[#676c80] group-hover:text-red-500 transition-colors" })
9550
9779
  }
9551
9780
  )
9552
9781
  ] }),
@@ -9711,7 +9940,7 @@ function CartScreen() {
9711
9940
  {
9712
9941
  type: "submit",
9713
9942
  onClick: handleSubmit,
9714
- className: "w-full rounded-full border-2 border-primary-500 bg-primary-500 hover:bg-primary-600 text-white px-4 py-3 text-sm font-medium transition-colors flex items-center justify-center gap-2",
9943
+ className: "w-full rounded-full border-2 border-[#E67E50] bg-[#E67E50] hover:bg-[#E67E50]/80 text-white px-4 py-3 text-sm font-medium transition-colors flex items-center justify-center gap-2",
9715
9944
  children: [
9716
9945
  "Proceed to Checkout",
9717
9946
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRight, { className: "h-5 w-5" })
@@ -10362,7 +10591,13 @@ function CheckoutScreen() {
10362
10591
  router.push(buildPath(`/orders/${response.data?.id}`));
10363
10592
  }
10364
10593
  } catch (err) {
10365
- const msg = err?.message || err?.response?.data?.message || "Failed to place order";
10594
+ console.error("Checkout error:", err);
10595
+ let msg = err?.response?.data?.message || err?.message || "Failed to place order";
10596
+ if (msg.toLowerCase().includes("insufficient balance")) {
10597
+ msg = "Insufficient balance in your account to complete this order.";
10598
+ } else if (msg.toLowerCase().includes("browser was not found")) {
10599
+ msg = "A temporary server error occurred while processing your invoice. Please contact support.";
10600
+ }
10366
10601
  setError(msg);
10367
10602
  notification.error(
10368
10603
  "Could not place order",
@@ -10380,444 +10615,444 @@ function CheckoutScreen() {
10380
10615
  const tax = 0;
10381
10616
  const total = subtotal + shippingPrice + tax;
10382
10617
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-h-screen bg-white pb-16", children: [
10383
- /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit(onSubmit), children: [
10384
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 text-red-600 font-semibold", children: error }),
10385
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-12 container mx-auto grid gap-10 px-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]", children: [
10386
- /* @__PURE__ */ jsxRuntime.jsxs(
10387
- framerMotion.motion.div,
10388
- {
10389
- initial: { opacity: 0, y: 24 },
10390
- animate: { opacity: 1, y: 0 },
10391
- className: "space-y-8",
10392
- children: [
10393
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-12", children: [
10394
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "font-['Poppins',sans-serif] font-semibold text-[#2B4B7C] mb-2 text-3xl", children: "Checkout" }),
10395
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-['Poppins',sans-serif] text-[14px] text-[#676c80] text-md leading-relaxed", children: "Complete your order information below" })
10618
+ /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit: handleSubmit(onSubmit), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-12 container mx-auto grid gap-10 px-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]", children: [
10619
+ /* @__PURE__ */ jsxRuntime.jsxs(
10620
+ framerMotion.motion.div,
10621
+ {
10622
+ initial: { opacity: 0, y: 24 },
10623
+ animate: { opacity: 1, y: 0 },
10624
+ className: "space-y-8",
10625
+ children: [
10626
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-12", children: [
10627
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "font-['Poppins',sans-serif] font-semibold text-[#2B4B7C] mb-2 text-3xl", children: "Checkout" }),
10628
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-['Poppins',sans-serif] text-[14px] text-[#676c80] text-md leading-relaxed", children: "Complete your order information below" })
10629
+ ] }),
10630
+ /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "bg-white border-2 border-gray-100 rounded-[24px] p-8 text-[#2B4B7C]", children: [
10631
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-between gap-4", children: [
10632
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10633
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-['Poppins',sans-serif] font-semibold text-[#2B4B7C] mb-2 text-2xl", children: "Contact Information" }),
10634
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-500", children: "We use temperature-aware packaging and real-time tracking on every shipment." })
10635
+ ] }),
10636
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-2 rounded-full bg-primary-50 px-3 py-1 text-xs font-semibold uppercase tracking-wide text-primary-700", children: [
10637
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: "h-4 w-4" }),
10638
+ "Dispatch in 12h"
10639
+ ] })
10396
10640
  ] }),
10397
- /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "bg-white border-2 border-gray-100 rounded-[24px] p-8 text-[#2B4B7C]", children: [
10398
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-between gap-4", children: [
10399
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10400
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-['Poppins',sans-serif] font-semibold text-[#2B4B7C] mb-2 text-2xl", children: "Contact Information" }),
10401
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-500", children: "We use temperature-aware packaging and real-time tracking on every shipment." })
10641
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-6 grid grid-cols-1 gap-4 md:grid-cols-2", children: [
10642
+ isDelivery && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:col-span-2 space-y-4", children: [
10643
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10644
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "block font-semibold", children: "Select Address" }),
10645
+ /* @__PURE__ */ jsxRuntime.jsxs(
10646
+ Button,
10647
+ {
10648
+ type: "button",
10649
+ variant: "outline-solid",
10650
+ size: "sm",
10651
+ onClick: () => {
10652
+ setEditingAddress(null);
10653
+ setIsAddressModalOpen(true);
10654
+ },
10655
+ children: [
10656
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }),
10657
+ "Add New Address"
10658
+ ]
10659
+ }
10660
+ )
10402
10661
  ] }),
10403
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-2 rounded-full bg-primary-50 px-3 py-1 text-xs font-semibold uppercase tracking-wide text-primary-700", children: [
10404
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: "h-4 w-4" }),
10405
- "Dispatch in 12h"
10662
+ userAddresses.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4", children: userAddresses.map((addr) => /* @__PURE__ */ jsxRuntime.jsxs(
10663
+ "label",
10664
+ {
10665
+ className: `group relative flex items-start gap-3 p-4 rounded-2xl border ${selectedAddressId === addr.id ? "border-primary-500 bg-primary-50 shadow-xs" : "border-slate-200 bg-white"} cursor-pointer hover:border-primary-300 transition-colors`,
10666
+ children: [
10667
+ /* @__PURE__ */ jsxRuntime.jsx(
10668
+ "input",
10669
+ {
10670
+ type: "radio",
10671
+ name: "selectedAddress",
10672
+ value: addr.id,
10673
+ checked: selectedAddressId === addr.id,
10674
+ onChange: () => {
10675
+ setSelectedAddressId(addr.id);
10676
+ setValue("shipping.name", addr.name);
10677
+ setValue("shipping.phone", addr.phone || void 0);
10678
+ setValue("shipping.street1", addr.street1);
10679
+ setValue("shipping.street2", addr.street2 || "");
10680
+ setValue("shipping.city", addr.city);
10681
+ setValue("shipping.state", addr.state);
10682
+ setValue("shipping.zip", addr.zip);
10683
+ setValue("shipping.country", addr.country);
10684
+ },
10685
+ className: "mt-1"
10686
+ }
10687
+ ),
10688
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
10689
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-slate-900", children: addr.name }),
10690
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-600", children: addr.street1 }),
10691
+ addr.street2 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-600", children: addr.street2 }),
10692
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-slate-600", children: [
10693
+ addr.city,
10694
+ ", ",
10695
+ addr.state,
10696
+ " ",
10697
+ addr.zip
10698
+ ] }),
10699
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-600", children: addr.country }),
10700
+ addr.phone && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-600 mt-1", children: addr.phone }),
10701
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 flex items-center gap-2", children: [
10702
+ addr.isDefault && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex items-center gap-1 rounded-full bg-primary-100 px-2.5 py-0.5 text-xs font-semibold text-primary-700", children: "Default" }),
10703
+ /* @__PURE__ */ jsxRuntime.jsxs(
10704
+ "button",
10705
+ {
10706
+ type: "button",
10707
+ onClick: (e) => {
10708
+ e.preventDefault();
10709
+ setEditingAddress(addr);
10710
+ setIsAddressModalOpen(true);
10711
+ },
10712
+ className: "inline-flex items-center gap-1 rounded-full border border-slate-200 px-2.5 py-0.5 text-xs font-medium text-slate-600 hover:border-primary-300 hover:text-primary-600",
10713
+ children: [
10714
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Edit3, { className: "h-3.5 w-3.5" }),
10715
+ " Edit"
10716
+ ]
10717
+ }
10718
+ ),
10719
+ /* @__PURE__ */ jsxRuntime.jsxs(
10720
+ "button",
10721
+ {
10722
+ type: "button",
10723
+ onClick: async (e) => {
10724
+ e.preventDefault();
10725
+ const yes = window.confirm("Delete this address?");
10726
+ if (!yes) return;
10727
+ try {
10728
+ await removeAddress(addr.id);
10729
+ if (selectedAddressId === addr.id) setSelectedAddressId(null);
10730
+ notification.success("Address deleted");
10731
+ } catch (e2) {
10732
+ notification.error("Failed to delete address");
10733
+ }
10734
+ },
10735
+ className: "inline-flex items-center gap-1 rounded-full border border-red-200 px-2.5 py-0.5 text-xs font-semibold text-red-600 hover:border-red-300 hover:text-red-700",
10736
+ children: [
10737
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "h-3.5 w-3.5" }),
10738
+ " Delete"
10739
+ ]
10740
+ }
10741
+ )
10742
+ ] })
10743
+ ] })
10744
+ ]
10745
+ },
10746
+ addr.id
10747
+ )) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-8 bg-slate-50 rounded-lg", children: [
10748
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "h-12 w-12 mx-auto text-slate-400" }),
10749
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-slate-600", children: "No addresses found" }),
10750
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-500", children: "Add a new address to continue" })
10406
10751
  ] })
10407
10752
  ] }),
10408
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-6 grid grid-cols-1 gap-4 md:grid-cols-2", children: [
10409
- isDelivery && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:col-span-2 space-y-4", children: [
10410
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10411
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "block font-semibold", children: "Select Address" }),
10412
- /* @__PURE__ */ jsxRuntime.jsxs(
10413
- Button,
10414
- {
10415
- type: "button",
10416
- variant: "outline-solid",
10417
- size: "sm",
10418
- onClick: () => {
10419
- setEditingAddress(null);
10420
- setIsAddressModalOpen(true);
10421
- },
10422
- children: [
10423
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }),
10424
- "Add New Address"
10425
- ]
10426
- }
10427
- )
10428
- ] }),
10429
- userAddresses.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4", children: userAddresses.map((addr) => /* @__PURE__ */ jsxRuntime.jsxs(
10430
- "label",
10431
- {
10432
- className: `group relative flex items-start gap-3 p-4 rounded-2xl border ${selectedAddressId === addr.id ? "border-primary-500 bg-primary-50 shadow-xs" : "border-slate-200 bg-white"} cursor-pointer hover:border-primary-300 transition-colors`,
10433
- children: [
10434
- /* @__PURE__ */ jsxRuntime.jsx(
10435
- "input",
10753
+ !isDelivery && storeAddresses.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:col-span-2", children: [
10754
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "block mb-2 font-semibold", children: "Select Pickup Location" }),
10755
+ /* @__PURE__ */ jsxRuntime.jsx(
10756
+ "select",
10757
+ {
10758
+ className: "w-full border rounded-sm p-2",
10759
+ value: selectedStoreAddressId || "",
10760
+ onChange: (e) => setSelectedStoreAddressId(e.target.value),
10761
+ children: storeAddresses.map((addr) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: addr.id, children: [
10762
+ addr.name,
10763
+ " - ",
10764
+ addr.street1,
10765
+ ", ",
10766
+ addr.city
10767
+ ] }, addr.id))
10768
+ }
10769
+ )
10770
+ ] })
10771
+ ] })
10772
+ ] }),
10773
+ isDelivery && selectedAddressId && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white border-2 border-gray-100 rounded-[24px] p-8 text-[#2B4B7C]", children: [
10774
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 text-xl font-semibold text-gray-900 pb-4 mb-8 border-b", children: [
10775
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: "text-accent w-8 h-8 flex items-center justify-center text-[#2B4B7C]" }),
10776
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-['Poppins',sans-serif] font-semibold text-[#2B4B7C] text-2xl", children: "Shipping Options" })
10777
+ ] }),
10778
+ shippingRatesLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center py-12", children: [
10779
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-accent" }),
10780
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-3 text-gray-600", children: "Loading shipping options..." })
10781
+ ] }) : shippingRatesError ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-12", children: [
10782
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 mx-auto mb-4 bg-red-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-8 h-8 text-red-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }) }),
10783
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-500 text-lg font-medium", children: "Error loading shipping options" }),
10784
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-400 text-sm mt-1", children: shippingRatesError })
10785
+ ] }) : shippingRates && shippingRates.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: shippingRates.map((rate) => {
10786
+ const isSelected = !!selectedShippingRateId && selectedShippingRateId === rate.objectId;
10787
+ const isTest = rate.test;
10788
+ const hasAttributes = rate.attributes && rate.attributes.length > 0;
10789
+ return /* @__PURE__ */ jsxRuntime.jsxs(
10790
+ "div",
10791
+ {
10792
+ onClick: () => {
10793
+ setSelectedShippingRateId(rate.objectId);
10794
+ setShippingPrice(parseFloat(rate.amount));
10795
+ },
10796
+ className: `relative p-5 border-2 rounded-xl cursor-pointer transition-all duration-200 hover:shadow-md ${isSelected ? "border-primary-500 bg-primary-50 ring-2 ring-primary-200" : "border-gray-200 hover:border-gray-300"}`,
10797
+ children: [
10798
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between", children: [
10799
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-4 flex-1", children: [
10800
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(
10801
+ Image4__default.default,
10436
10802
  {
10437
- type: "radio",
10438
- name: "selectedAddress",
10439
- value: addr.id,
10440
- checked: selectedAddressId === addr.id,
10441
- onChange: () => {
10442
- setSelectedAddressId(addr.id);
10443
- setValue("shipping.name", addr.name);
10444
- setValue("shipping.phone", addr.phone || void 0);
10445
- setValue("shipping.street1", addr.street1);
10446
- setValue("shipping.street2", addr.street2 || "");
10447
- setValue("shipping.city", addr.city);
10448
- setValue("shipping.state", addr.state);
10449
- setValue("shipping.zip", addr.zip);
10450
- setValue("shipping.country", addr.country);
10803
+ src: rate.providerImage75 || "/placeholder-product.jpg",
10804
+ alt: rate.provider,
10805
+ className: "w-12 h-12 rounded-lg object-contain bg-white border border-gray-200 p-1",
10806
+ onError: (e) => {
10807
+ const target = e.target;
10808
+ target.style.display = "none";
10451
10809
  },
10452
- className: "mt-1"
10810
+ width: 48,
10811
+ height: 48
10453
10812
  }
10454
- ),
10455
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
10456
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-slate-900", children: addr.name }),
10457
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-600", children: addr.street1 }),
10458
- addr.street2 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-600", children: addr.street2 }),
10459
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-slate-600", children: [
10460
- addr.city,
10461
- ", ",
10462
- addr.state,
10463
- " ",
10464
- addr.zip
10813
+ ) }),
10814
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
10815
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-2", children: [
10816
+ /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-lg font-semibold text-gray-900", children: [
10817
+ rate.provider,
10818
+ " ",
10819
+ rate.servicelevel?.name
10820
+ ] }),
10821
+ isTest && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-2 py-1 text-xs font-medium bg-primary-100 text-primary-800 rounded-full", children: "TEST" })
10465
10822
  ] }),
10466
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-600", children: addr.country }),
10467
- addr.phone && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-600 mt-1", children: addr.phone }),
10468
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 flex items-center gap-2", children: [
10469
- addr.isDefault && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex items-center gap-1 rounded-full bg-primary-100 px-2.5 py-0.5 text-xs font-semibold text-primary-700", children: "Default" }),
10470
- /* @__PURE__ */ jsxRuntime.jsxs(
10471
- "button",
10472
- {
10473
- type: "button",
10474
- onClick: (e) => {
10475
- e.preventDefault();
10476
- setEditingAddress(addr);
10477
- setIsAddressModalOpen(true);
10478
- },
10479
- className: "inline-flex items-center gap-1 rounded-full border border-slate-200 px-2.5 py-0.5 text-xs font-medium text-slate-600 hover:border-primary-300 hover:text-primary-600",
10480
- children: [
10481
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Edit3, { className: "h-3.5 w-3.5" }),
10482
- " Edit"
10483
- ]
10484
- }
10485
- ),
10486
- /* @__PURE__ */ jsxRuntime.jsxs(
10487
- "button",
10488
- {
10489
- type: "button",
10490
- onClick: async (e) => {
10491
- e.preventDefault();
10492
- const yes = window.confirm("Delete this address?");
10493
- if (!yes) return;
10494
- try {
10495
- await removeAddress(addr.id);
10496
- if (selectedAddressId === addr.id) setSelectedAddressId(null);
10497
- notification.success("Address deleted");
10498
- } catch (e2) {
10499
- notification.error("Failed to delete address");
10500
- }
10501
- },
10502
- className: "inline-flex items-center gap-1 rounded-full border border-red-200 px-2.5 py-0.5 text-xs font-semibold text-red-600 hover:border-red-300 hover:text-red-700",
10503
- children: [
10504
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "h-3.5 w-3.5" }),
10505
- " Delete"
10506
- ]
10507
- }
10508
- )
10823
+ hasAttributes && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2 mb-3", children: rate.attributes.map((attr) => /* @__PURE__ */ jsxRuntime.jsx(
10824
+ "span",
10825
+ {
10826
+ className: `px-2 py-1 text-xs font-medium rounded-full ${attr === "FASTEST" ? "bg-green-100 text-green-800" : attr === "BESTVALUE" ? "bg-blue-100 text-blue-800" : attr === "CHEAPEST" ? "bg-purple-100 text-purple-800" : "bg-gray-100 text-gray-800"}`,
10827
+ children: attr
10828
+ },
10829
+ attr
10830
+ )) }),
10831
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 text-sm text-gray-600", children: [
10832
+ rate.durationTerms && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10833
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4 text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
10834
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: rate.durationTerms })
10835
+ ] }),
10836
+ rate.estimatedDays && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10837
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4 text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
10838
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
10839
+ "Estimated ",
10840
+ rate.estimatedDays,
10841
+ " day",
10842
+ rate.estimatedDays !== 1 ? "s" : ""
10843
+ ] })
10844
+ ] }),
10845
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10846
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4 text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" }) }),
10847
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
10848
+ "Carrier: ",
10849
+ rate.provider
10850
+ ] })
10851
+ ] }),
10852
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10853
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4 text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1" }) }),
10854
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
10855
+ "Currency: ",
10856
+ rate.currency
10857
+ ] })
10858
+ ] })
10509
10859
  ] })
10510
10860
  ] })
10511
- ]
10512
- },
10513
- addr.id
10514
- )) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-8 bg-slate-50 rounded-lg", children: [
10515
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "h-12 w-12 mx-auto text-slate-400" }),
10516
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-slate-600", children: "No addresses found" }),
10517
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-slate-500", children: "Add a new address to continue" })
10518
- ] })
10519
- ] }),
10520
- !isDelivery && storeAddresses.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:col-span-2", children: [
10521
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "block mb-2 font-semibold", children: "Select Pickup Location" }),
10522
- /* @__PURE__ */ jsxRuntime.jsx(
10523
- "select",
10524
- {
10525
- className: "w-full border rounded-sm p-2",
10526
- value: selectedStoreAddressId || "",
10527
- onChange: (e) => setSelectedStoreAddressId(e.target.value),
10528
- children: storeAddresses.map((addr) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: addr.id, children: [
10529
- addr.name,
10530
- " - ",
10531
- addr.street1,
10532
- ", ",
10533
- addr.city
10534
- ] }, addr.id))
10535
- }
10536
- )
10537
- ] })
10538
- ] })
10539
- ] }),
10540
- isDelivery && selectedAddressId && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white border-2 border-gray-100 rounded-[24px] p-8 text-[#2B4B7C]", children: [
10541
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 text-xl font-semibold text-gray-900 pb-4 mb-8 border-b", children: [
10542
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: "text-accent w-8 h-8 flex items-center justify-center text-[#2B4B7C]" }),
10543
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-['Poppins',sans-serif] font-semibold text-[#2B4B7C] text-2xl", children: "Shipping Options" })
10861
+ ] }),
10862
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-end", children: [
10863
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-2xl font-bold text-gray-900", children: formatPrice(parseFloat(rate.amount)) }),
10864
+ rate.amount !== rate.amountLocal && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-gray-500", children: [
10865
+ rate.amountLocal,
10866
+ " ",
10867
+ rate.currencyLocal
10868
+ ] })
10869
+ ] })
10870
+ ] }),
10871
+ isSelected && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute top-3 right-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-6 h-6 bg-primary-500 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "w-4 h-4 text-white" }) }) })
10872
+ ]
10873
+ },
10874
+ rate.objectId
10875
+ );
10876
+ }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-12", children: [
10877
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 mx-auto mb-4 bg-gray-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: "w-8 h-8 text-gray-400" }) }),
10878
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-500 text-lg font-medium", children: "No shipping options available" }),
10879
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-400 text-sm mt-1", children: "Please check the shipping address or try a different location." })
10880
+ ] })
10881
+ ] }),
10882
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
10883
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white border-2 border-gray-100 rounded-[24px] p-8", children: [
10884
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 mb-6", children: [
10885
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: "w-8 h-8 text-[#2B4B7C]" }),
10886
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-semibold text-[#2B4B7C]", children: "Delivery Method" })
10544
10887
  ] }),
10545
- shippingRatesLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center py-12", children: [
10546
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-accent" }),
10547
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-3 text-gray-600", children: "Loading shipping options..." })
10548
- ] }) : shippingRatesError ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-12", children: [
10549
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 mx-auto mb-4 bg-red-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-8 h-8 text-red-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }) }),
10550
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-500 text-lg font-medium", children: "Error loading shipping options" }),
10551
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-400 text-sm mt-1", children: shippingRatesError })
10552
- ] }) : shippingRates && shippingRates.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: shippingRates.map((rate) => {
10553
- const isSelected = !!selectedShippingRateId && selectedShippingRateId === rate.objectId;
10554
- const isTest = rate.test;
10555
- const hasAttributes = rate.attributes && rate.attributes.length > 0;
10888
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-3", children: [
10889
+ {
10890
+ label: "Delivery",
10891
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: "w-5 h-5" }),
10892
+ value: true,
10893
+ desc: "Shipped to your address"
10894
+ },
10895
+ {
10896
+ label: "Pickup",
10897
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "w-5 h-5" }),
10898
+ value: false,
10899
+ desc: "Collect from pharmacy"
10900
+ }
10901
+ ].map((option) => {
10902
+ const active = isDelivery === option.value;
10556
10903
  return /* @__PURE__ */ jsxRuntime.jsxs(
10557
- "div",
10904
+ "button",
10558
10905
  {
10906
+ type: "button",
10559
10907
  onClick: () => {
10560
- setSelectedShippingRateId(rate.objectId);
10561
- setShippingPrice(parseFloat(rate.amount));
10908
+ setIsDelivery(option.value);
10909
+ if (option.value) {
10910
+ setSelectedShippingRateId(null);
10911
+ setShippingPrice(0);
10912
+ }
10562
10913
  },
10563
- className: `relative p-5 border-2 rounded-xl cursor-pointer transition-all duration-200 hover:shadow-md ${isSelected ? "border-primary-500 bg-primary-50 ring-2 ring-primary-200" : "border-gray-200 hover:border-gray-300"}`,
10914
+ className: `relative flex w-full items-center justify-between rounded-xl border-2 p-4 transition-all duration-200 ${active ? "border-primary-500 bg-primary-50" : "border-gray-200 hover:border-primary-300"}`,
10564
10915
  children: [
10565
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between", children: [
10566
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-4 flex-1", children: [
10567
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(
10568
- Image4__default.default,
10569
- {
10570
- src: rate.providerImage75 || "/placeholder-product.jpg",
10571
- alt: rate.provider,
10572
- className: "w-12 h-12 rounded-lg object-contain bg-white border border-gray-200 p-1",
10573
- onError: (e) => {
10574
- const target = e.target;
10575
- target.style.display = "none";
10576
- },
10577
- width: 48,
10578
- height: 48
10579
- }
10580
- ) }),
10581
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
10582
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-2", children: [
10583
- /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-lg font-semibold text-gray-900", children: [
10584
- rate.provider,
10585
- " ",
10586
- rate.servicelevel?.name
10587
- ] }),
10588
- isTest && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-2 py-1 text-xs font-medium bg-primary-100 text-primary-800 rounded-full", children: "TEST" })
10589
- ] }),
10590
- hasAttributes && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2 mb-3", children: rate.attributes.map((attr) => /* @__PURE__ */ jsxRuntime.jsx(
10591
- "span",
10592
- {
10593
- className: `px-2 py-1 text-xs font-medium rounded-full ${attr === "FASTEST" ? "bg-green-100 text-green-800" : attr === "BESTVALUE" ? "bg-blue-100 text-blue-800" : attr === "CHEAPEST" ? "bg-purple-100 text-purple-800" : "bg-gray-100 text-gray-800"}`,
10594
- children: attr
10595
- },
10596
- attr
10597
- )) }),
10598
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 text-sm text-gray-600", children: [
10599
- rate.durationTerms && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10600
- /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4 text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
10601
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: rate.durationTerms })
10602
- ] }),
10603
- rate.estimatedDays && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10604
- /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4 text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
10605
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
10606
- "Estimated ",
10607
- rate.estimatedDays,
10608
- " day",
10609
- rate.estimatedDays !== 1 ? "s" : ""
10610
- ] })
10611
- ] }),
10612
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10613
- /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4 text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" }) }),
10614
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
10615
- "Carrier: ",
10616
- rate.provider
10617
- ] })
10618
- ] }),
10619
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10620
- /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4 text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1" }) }),
10621
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
10622
- "Currency: ",
10623
- rate.currency
10624
- ] })
10625
- ] })
10626
- ] })
10627
- ] })
10628
- ] }),
10629
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-end", children: [
10630
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-2xl font-bold text-gray-900", children: formatPrice(parseFloat(rate.amount)) }),
10631
- rate.amount !== rate.amountLocal && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-gray-500", children: [
10632
- rate.amountLocal,
10633
- " ",
10634
- rate.currencyLocal
10635
- ] })
10916
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
10917
+ /* @__PURE__ */ jsxRuntime.jsx(
10918
+ "div",
10919
+ {
10920
+ className: `p-2 rounded-lg ${active ? "bg-primary-100 text-primary-600" : "bg-gray-100 text-gray-600"}`,
10921
+ children: option.icon
10922
+ }
10923
+ ),
10924
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-left", children: [
10925
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium text-gray-900", children: option.label }),
10926
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500", children: option.desc })
10636
10927
  ] })
10637
10928
  ] }),
10638
- isSelected && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute top-3 right-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-6 h-6 bg-primary-500 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "w-4 h-4 text-white" }) }) })
10929
+ active && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-5 h-5 rounded-full bg-primary-500 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "w-3 h-3 text-white" }) })
10639
10930
  ]
10640
10931
  },
10641
- rate.objectId
10932
+ option.label
10642
10933
  );
10643
- }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-12", children: [
10644
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 mx-auto mb-4 bg-gray-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: "w-8 h-8 text-gray-400" }) }),
10645
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-500 text-lg font-medium", children: "No shipping options available" }),
10646
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-400 text-sm mt-1", children: "Please check the shipping address or try a different location." })
10647
- ] })
10934
+ }) })
10648
10935
  ] }),
10649
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
10650
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white border-2 border-gray-100 rounded-[24px] p-8", children: [
10651
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 mb-6", children: [
10652
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: "w-8 h-8 text-[#2B4B7C]" }),
10653
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-semibold text-[#2B4B7C]", children: "Delivery Method" })
10654
- ] }),
10655
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-3", children: [
10656
- {
10657
- label: "Delivery",
10658
- icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: "w-5 h-5" }),
10659
- value: true,
10660
- desc: "Shipped to your address"
10661
- },
10662
- {
10663
- label: "Pickup",
10664
- icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "w-5 h-5" }),
10665
- value: false,
10666
- desc: "Collect from pharmacy"
10667
- }
10668
- ].map((option) => {
10669
- const active = isDelivery === option.value;
10670
- return /* @__PURE__ */ jsxRuntime.jsxs(
10671
- "button",
10672
- {
10673
- type: "button",
10674
- onClick: () => {
10675
- setIsDelivery(option.value);
10676
- if (option.value) {
10677
- setSelectedShippingRateId(null);
10678
- setShippingPrice(0);
10679
- }
10680
- },
10681
- className: `relative flex w-full items-center justify-between rounded-xl border-2 p-4 transition-all duration-200 ${active ? "border-primary-500 bg-primary-50" : "border-gray-200 hover:border-primary-300"}`,
10682
- children: [
10683
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
10684
- /* @__PURE__ */ jsxRuntime.jsx(
10685
- "div",
10686
- {
10687
- className: `p-2 rounded-lg ${active ? "bg-primary-100 text-primary-600" : "bg-gray-100 text-gray-600"}`,
10688
- children: option.icon
10689
- }
10690
- ),
10691
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-left", children: [
10692
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium text-gray-900", children: option.label }),
10693
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500", children: option.desc })
10694
- ] })
10695
- ] }),
10696
- active && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-5 h-5 rounded-full bg-primary-500 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "w-3 h-3 text-white" }) })
10697
- ]
10698
- },
10699
- option.label
10700
- );
10701
- }) })
10936
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white border-2 border-gray-100 rounded-[24px] p-8", children: [
10937
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 mb-6", children: [
10938
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CreditCard, { className: "w-8 h-8 text-[#2B4B7C]" }),
10939
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-semibold text-[#2B4B7C]", children: "Payment Method" })
10702
10940
  ] }),
10703
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white border-2 border-gray-100 rounded-[24px] p-8", children: [
10704
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 mb-6", children: [
10705
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CreditCard, { className: "w-8 h-8 text-[#2B4B7C]" }),
10706
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-semibold text-[#2B4B7C]", children: "Payment Method" })
10707
- ] }),
10708
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4 md:grid-cols-3", children: PAYMENT_METHODS.map((pm) => {
10709
- const active = paymentMethod === pm.value;
10710
- return /* @__PURE__ */ jsxRuntime.jsxs(
10711
- "button",
10712
- {
10713
- type: "button",
10714
- onClick: () => setPaymentMethod(pm.value),
10715
- className: `
10941
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4 md:grid-cols-3", children: PAYMENT_METHODS.map((pm) => {
10942
+ const active = paymentMethod === pm.value;
10943
+ return /* @__PURE__ */ jsxRuntime.jsxs(
10944
+ "button",
10945
+ {
10946
+ type: "button",
10947
+ onClick: () => setPaymentMethod(pm.value),
10948
+ className: `
10716
10949
  group relative flex w-full items-center justify-between rounded-xl border-2 p-3
10717
10950
  transition-all duration-200 ease-out
10718
10951
  focus:outline-hidden f
10719
10952
  ${active ? `${pm.activeClass} shadow-md scale-[1.02]` : `${pm.className} border-gray-200 bg-white hover:shadow-xs hover:-translate-y-0.5`}
10720
10953
  `,
10721
- children: [
10722
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
10723
- /* @__PURE__ */ jsxRuntime.jsx(
10724
- "div",
10725
- {
10726
- className: `
10954
+ children: [
10955
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
10956
+ /* @__PURE__ */ jsxRuntime.jsx(
10957
+ "div",
10958
+ {
10959
+ className: `
10727
10960
  flex items-center justify-center rounded-lg p-2
10728
10961
  transition-colors duration-200
10729
10962
  ${pm.value === "Card" ? " text-blue-600" : pm.value === "Cash" ? " text-amber-600" : " text-emerald-600"}
10730
10963
  ${active ? "opacity-80" : "group-hover:opacity-90"}
10731
10964
  `,
10732
- children: pm.icon
10733
- }
10734
- ),
10735
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold text-gray-900", children: pm.label })
10736
- ] }),
10737
- active && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-6 w-6 items-center justify-center rounded-full shadow-xs", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-white" }) })
10738
- ]
10739
- },
10740
- pm.value
10741
- );
10742
- }) }),
10743
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-gray-500 mt-4", children: [
10744
- paymentMethod === "Card" && "You will be redirected to a secure payment page.",
10745
- paymentMethod === "Cash" && "Pay with cash at the time of delivery or pickup.",
10746
- paymentMethod === "Credit" && "Use your available account credit for this order."
10747
- ] })
10965
+ children: pm.icon
10966
+ }
10967
+ ),
10968
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold text-gray-900", children: pm.label })
10969
+ ] }),
10970
+ active && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-6 w-6 items-center justify-center rounded-full shadow-xs", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-white" }) })
10971
+ ]
10972
+ },
10973
+ pm.value
10974
+ );
10975
+ }) }),
10976
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-gray-500 mt-4", children: [
10977
+ paymentMethod === "Card" && "You will be redirected to a secure payment page.",
10978
+ paymentMethod === "Cash" && "Pay with cash at the time of delivery or pickup.",
10979
+ paymentMethod === "Credit" && "Use your available account credit for this order."
10748
10980
  ] })
10749
10981
  ] })
10750
- ]
10751
- }
10752
- ),
10753
- /* @__PURE__ */ jsxRuntime.jsx(
10754
- framerMotion.motion.aside,
10755
- {
10756
- initial: { opacity: 0, y: 32 },
10757
- animate: { opacity: 1, y: 0 },
10758
- transition: { duration: 0.5, ease: "easeOut", delay: 0.1 },
10759
- className: "space-y-10 lg:sticky lg:top-24 lg:col-span-1",
10760
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-linear-to-br from-[#5B9BD5]/10 to-[#2B4B7C]/10 rounded-[24px] p-8 border-2 border-[#5B9BD5]/20 sticky top-24", children: [
10761
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-['Poppins',sans-serif] font-semibold text-[#2B4B7C] mb-6 text-2xl", children: "Order Summary" }),
10762
- /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "mt-8 pt-6 border-t border-slate-100", children: [
10763
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4 mb-6", children: cart?.cartBody?.items?.map((item) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
10764
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 rounded-xl overflow-hidden bg-white shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(Image4__default.default, { src: item.productVariantData.productMedia?.[0]?.file || "/placeholder-product.jpg", alt: item.productVariantData.name, className: "w-full h-full object-cover", height: 200, width: 200 }) }),
10765
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
10766
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-['Poppins',sans-serif] font-medium text-[12px] text-[#2B4B7C] mb-1", children: item?.productVariantData?.name }),
10767
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "font-['Poppins',sans-serif] text-[11px] text-[#676c80]", children: [
10768
- item?.productVariantData?.brand,
10769
- " \u2022 Qty: ",
10770
- item.quantity
10771
- ] }),
10772
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-['Poppins',sans-serif] font-semibold text-[12px] text-[#E67E50] mt-1", children: formatPrice(item.productVariantData.finalPrice * item.quantity) })
10773
- ] })
10774
- ] }, `${item.productId}-${item.color}-${item.size}`)) }),
10775
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-px bg-[#5B9BD5]/20 my-4" }),
10776
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-slate-600 space-y-3 py-4", children: [
10777
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10778
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Subtotal" }),
10779
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-slate-900", children: formatPrice(subtotal) })
10780
- ] }),
10781
- isDelivery && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10782
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Shipping" }),
10783
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: formatPrice(shippingPrice) })
10784
- ] }),
10785
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10786
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Estimated tax" }),
10787
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: formatPrice(tax) })
10982
+ ] })
10983
+ ]
10984
+ }
10985
+ ),
10986
+ /* @__PURE__ */ jsxRuntime.jsx(
10987
+ framerMotion.motion.aside,
10988
+ {
10989
+ initial: { opacity: 0, y: 32 },
10990
+ animate: { opacity: 1, y: 0 },
10991
+ transition: { duration: 0.5, ease: "easeOut", delay: 0.1 },
10992
+ className: "space-y-10 lg:sticky lg:top-24 lg:col-span-1",
10993
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-linear-to-br from-[#5B9BD5]/10 to-[#2B4B7C]/10 rounded-[24px] p-8 border-2 border-[#5B9BD5]/20 sticky top-24", children: [
10994
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-['Poppins',sans-serif] font-semibold text-[#2B4B7C] mb-6 text-2xl", children: "Order Summary" }),
10995
+ /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "mt-8 pt-6 border-t border-slate-100", children: [
10996
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4 mb-6", children: cart?.cartBody?.items?.map((item) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
10997
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 rounded-xl overflow-hidden bg-white shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(Image4__default.default, { src: item.productVariantData.productMedia?.[0]?.file || "/placeholder-product.jpg", alt: item.productVariantData.name, className: "w-full h-full object-cover", height: 200, width: 200 }) }),
10998
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
10999
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-['Poppins',sans-serif] font-medium text-[12px] text-[#2B4B7C] mb-1", children: item?.productVariantData?.name }),
11000
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "font-['Poppins',sans-serif] text-[11px] text-[#676c80]", children: [
11001
+ item?.productVariantData?.brand,
11002
+ " \u2022 Qty: ",
11003
+ item.quantity
10788
11004
  ] }),
10789
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-px bg-[#5B9BD5]/20 mt-6" }),
10790
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-6", children: [
10791
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-['Poppins',sans-serif] font-semibold text-[16px] text-[#2B4B7C]", children: "Total" }),
10792
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-['Poppins',sans-serif] font-bold text-[24px] text-[#E67E50]", children: formatPrice(total) })
10793
- ] })
11005
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-['Poppins',sans-serif] font-semibold text-[12px] text-[#E67E50] mt-1", children: formatPrice(item.productVariantData.finalPrice * item.quantity) })
11006
+ ] })
11007
+ ] }, `${item.productId}-${item.color}-${item.size}`)) }),
11008
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-px bg-[#5B9BD5]/20 my-4" }),
11009
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-slate-600 space-y-3 py-4", children: [
11010
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
11011
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Subtotal" }),
11012
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-slate-900", children: formatPrice(subtotal) })
10794
11013
  ] }),
10795
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white/80 rounded-xl p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "font-['Poppins',sans-serif] text-[11px] text-[#676c80] leading-[1.6]", children: [
10796
- /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "text-[#2B4B7C]", children: "Payment:" }),
10797
- " We'll contact you to arrange payment upon pickup or delivery. We accept cash, credit cards, and all major payment methods."
10798
- ] }) })
11014
+ isDelivery && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
11015
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Shipping" }),
11016
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: formatPrice(shippingPrice) })
11017
+ ] }),
11018
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
11019
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Estimated tax" }),
11020
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: formatPrice(tax) })
11021
+ ] }),
11022
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-px bg-[#5B9BD5]/20 mt-6" }),
11023
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-6", children: [
11024
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-['Poppins',sans-serif] font-semibold text-[16px] text-[#2B4B7C]", children: "Total" }),
11025
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-['Poppins',sans-serif] font-bold text-[24px] text-[#E67E50]", children: formatPrice(total) })
11026
+ ] })
10799
11027
  ] }),
10800
- /* @__PURE__ */ jsxRuntime.jsxs(
10801
- Button,
10802
- {
10803
- type: "submit",
10804
- isLoading: isSubmitting,
10805
- className: "font-['Poppins',sans-serif] font-medium text-[14px] px-6 py-2 rounded-full bg-[#E67E50] text-white hover:bg-[#d66f45] hover:shadow-lg transition-all duration-300 mt-4 w-full",
10806
- children: [
10807
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CreditCard, { className: "h-5 w-5" }),
10808
- isSubmitting ? "Placing order..." : "Place Secure Order"
10809
- ]
10810
- }
10811
- ),
10812
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-4 flex items-center justify-center gap-2 text-xs text-slate-500", children: [
10813
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Lock, { className: "h-4 w-4" }),
10814
- "Fully encrypted checkout \u2014 cancel anytime before shipment."
10815
- ] })
11028
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white/80 rounded-xl p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "font-['Poppins',sans-serif] text-[11px] text-[#676c80] leading-[1.6]", children: [
11029
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "text-[#2B4B7C]", children: "Payment:" }),
11030
+ " We'll contact you to arrange payment upon pickup or delivery. We accept cash, credit cards, and all major payment methods."
11031
+ ] }) })
11032
+ ] }),
11033
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 p-4 rounded-xl bg-red-50 border border-red-200 text-red-600 text-sm font-medium animate-in fade-in slide-in-from-top-1 duration-200", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
11034
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-4 w-4 shrink-0 mt-0.5" }),
11035
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: error })
11036
+ ] }) }),
11037
+ /* @__PURE__ */ jsxRuntime.jsxs(
11038
+ "button",
11039
+ {
11040
+ type: "submit",
11041
+ className: "font-['Poppins',sans-serif] font-medium text-[14px] px-6 py-3 rounded-full text-white hover:bg-[#d66f45] hover:shadow-lg transition-all duration-300 mt-4 w-full bg-[#E67E50] hover:bg-[#2B4B7C] flex items-center justify-center gap-2",
11042
+ children: [
11043
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CreditCard, { className: "h-5 w-5" }),
11044
+ isSubmitting ? "Placing order..." : "Place Secure Order"
11045
+ ]
11046
+ }
11047
+ ),
11048
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-4 flex items-center justify-center gap-2 text-xs text-slate-500", children: [
11049
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Lock, { className: "h-4 w-4" }),
11050
+ "Fully encrypted checkout \u2014 cancel anytime before shipment."
10816
11051
  ] })
10817
- }
10818
- )
10819
- ] })
10820
- ] }),
11052
+ ] })
11053
+ }
11054
+ )
11055
+ ] }) }),
10821
11056
  /* @__PURE__ */ jsxRuntime.jsx(
10822
11057
  AddressFormModal,
10823
11058
  {