EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
cwa-stores.ts
Go to the documentation of this file.
1// CWA Store Configuration Utility
2// Allows switching between different Cartridge World Australia stores
3
4export interface CWAStore {
5 id: string;
6 name: string;
7 url: string;
8 location?: string;
9}
10
11// Available CWA stores from environment variables
12export const CWA_STORES: CWAStore[] = [
13 {
14 id: 'iig',
15 name: 'IIG Store',
16 url: process.env.FIELDPINE_STORE_IIG || 'https://iig.cwanz.online',
17 location: 'Primary Store'
18 },
19 {
20 id: 'murwillumbah',
21 name: 'Murwillumbah Store',
22 url: process.env.FIELDPINE_STORE_MURWILLUMBAH || 'https://murwillumbah.cwanz.online',
23 location: 'Murwillumbah'
24 },
25 {
26 id: 'cowra',
27 name: 'Cowra Store',
28 url: process.env.FIELDPINE_STORE_COWRA || 'https://cowra.cwanz.online',
29 location: 'Cowra'
30 }
31];
32
33// Get current store configuration
34export function getCurrentStore(): CWAStore {
35 const currentUrl = process.env.FIELDPINE_BASE_URL || process.env.NEXT_PUBLIC_FIELDPINE_BASE_URL;
36 const store = CWA_STORES.find(s => s.url === currentUrl);
37 return store || CWA_STORES[0]; // Default to first store
38}
39
40// Get store by ID
41export function getStoreById(id: string): CWAStore | undefined {
42 return CWA_STORES.find(s => s.id === id);
43}
44
45// Documentation URL
46export const CWA_DOCS_URL = process.env.FIELDPINE_DOCS_URL || 'https://cwanz.docs.fieldpine.com';
47
48// Helper to get login URL for a specific store
49export function getStoreLoginUrl(storeId: string): string {
50 const store = getStoreById(storeId);
51 return store ? `${store.url}/login` : `${CWA_STORES[0].url}/login`;
52}