@caseparts-org/casecore 0.0.16 → 0.0.18

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.
@@ -4,6 +4,7 @@ export type EmployeeResponse = {
4
4
  NickName: string;
5
5
  Branch: string;
6
6
  Rights: string;
7
+ SlackImgUrl?: string;
7
8
  };
8
9
  export type CustomerResponse = {
9
10
  UserName: string;
@@ -47,6 +48,7 @@ export type EmployeeClaims = {
47
48
  NickName: string;
48
49
  Branch: string | null;
49
50
  Rights: string[];
51
+ SlackImgUrl?: string;
50
52
  };
51
53
  export type CustomerClaims = {
52
54
  UserName: string;
package/dist/index.d.ts CHANGED
@@ -10,5 +10,5 @@ export type { Pricing, CustomerClass } from './cart/ClassPricing';
10
10
  export { getClassPricing } from './cart/ClassPricing';
11
11
  export type { BaseCartItem, CartContextValue, CartProviderProps, } from './cart/CartContext';
12
12
  export { CartProvider, useCartContext } from './cart/CartContext';
13
- export type { WarehouseInventory, Inventory, Availability, CustomPartAvailabilityResult, UnifiedAvailabilityResult, } from './inventory/PartAvailability';
13
+ export type { WarehouseInventory, Inventory, Availability, AvailabilityId, CustomPartAvailabilityResult, UnifiedAvailabilityResult, } from './inventory/PartAvailability';
14
14
  export { default as calcPartAvailability, calcDetailedPartAvailability, CUSTOM_PART_LEAD_TIMES, isDiscontinued, computeStockAvailability, computeCustomPartAvailability, shouldSuggestContactLink, computeAvailability } from './inventory/PartAvailability';
@@ -8,9 +8,10 @@ export interface Inventory {
8
8
  STL: WarehouseInventory;
9
9
  }
10
10
  export interface Availability {
11
+ id: AvailabilityId;
11
12
  description: string;
12
- id: string;
13
13
  }
14
+ export type AvailabilityId = "not-found" | "available" | "discontinued" | "limited" | "contact";
14
15
  export default function calcPartAvailability(inventory: Inventory | undefined, discontinued: boolean): Availability;
15
16
  export declare function calcDetailedPartAvailability(inventory: Inventory | undefined, discontinued: boolean): Availability;
16
17
  export declare const CUSTOM_PART_LEAD_TIMES: Record<string, string>;
@@ -1,7 +1,7 @@
1
1
  // export type SiteCode = "MPK" | "SEA" | "STL";
2
2
  export default function calcPartAvailability(inventory, discontinued) {
3
3
  if (!inventory || !inventory.MPK && !inventory.SEA && !inventory.STL) {
4
- return { description: "Unavailable", id: "unavailable" };
4
+ return { description: "", id: "not-found" };
5
5
  }
6
6
  const inStock = inventory.MPK.Unreserved > 5 || inventory.SEA.Unreserved > 5 || inventory.STL.Unreserved > 5;
7
7
  const limited = inventory.MPK.Unreserved > 0 || inventory.SEA.Unreserved > 0 || inventory.STL.Unreserved > 0;
@@ -14,7 +14,7 @@ export default function calcPartAvailability(inventory, discontinued) {
14
14
  else if (limited) {
15
15
  return { description: 'Limited availability', id: 'limited' };
16
16
  }
17
- return { description: 'Contact us', id: 'contactus' };
17
+ return { description: 'Contact us', id: 'contact' };
18
18
  }
19
19
  export function calcDetailedPartAvailability(inventory, discontinued) {
20
20
  const unreserved = (whse) => inventory ? inventory[whse].Unreserved : inventory[whse];
@@ -27,7 +27,7 @@ export function calcDetailedPartAvailability(inventory, discontinued) {
27
27
  ? { description: "This part is discontinued, supplies are limited", id: "limited" }
28
28
  : total > 0
29
29
  ? { description: `This part is discontinued and we only have ${total} in stock`, id: 'available' }
30
- : { description: "Contact us. This part is discontinued but we might have compatible alternatives.", id: "contactus" };
30
+ : { description: "Contact us. This part is discontinued but we might have compatible alternatives.", id: "contact" };
31
31
  return message;
32
32
  }
33
33
  // Count up the number of warehouses with sufficient unreserved quantity
@@ -68,7 +68,7 @@ export function calcDetailedPartAvailability(inventory, discontinued) {
68
68
  if (available("MPK") + available("STL") + available("SEA") >= quantity) {
69
69
  return { description: 'Limited availability', id: 'limited' };
70
70
  }
71
- return { description: 'Contact us for availability', id: 'contactus' };
71
+ return { description: 'Contact us for availability', id: 'contact' };
72
72
  }
73
73
  // Map of custom part lead times
74
74
  export const CUSTOM_PART_LEAD_TIMES = {
@@ -95,7 +95,7 @@ export function computeCustomPartAvailability(customType, _inventory, _partStatu
95
95
  }
96
96
  // Helper to decide whether UI should render a contact link
97
97
  export function shouldSuggestContactLink(availability, useFullDescription) {
98
- return availability.id === "contactus" && useFullDescription;
98
+ return availability.id === "contact" && useFullDescription;
99
99
  }
100
100
  // Wrapper choosing custom vs stock logic.
101
101
  // isCustom: true requires customType.
@@ -33,6 +33,7 @@ export function buildClaimsFromPayload(payload) {
33
33
  Rights: typeof employeeRaw.Rights === "string"
34
34
  ? employeeRaw.Rights.split(",").map((s) => s.trim())
35
35
  : [],
36
+ SlackImgUrl: employeeRaw.SlackImgUrl
36
37
  };
37
38
  }
38
39
  // Convert CustomerResponse to CustomerClaims (normalize Rights, PendingInvites, etc.)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/casecore",
3
3
  "private": false,
4
- "version": "0.0.16",
4
+ "version": "0.0.18",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",