@isoftdata/svelte-ecommerce 1.0.0-beta.0 → 1.0.0-beta.1

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.
@@ -1,195 +1,199 @@
1
- <script lang="ts">
2
- import type { i18n } from 'i18next'
3
-
4
- import { getContext } from 'svelte'
5
-
6
- import EcommerceDefaults from './EcommerceDefaults.svelte'
7
- import type {
8
- EbayCategory,
9
- EbayCategoryMap,
10
- EbayPolicy,
11
- EbayLocation,
12
- EcommerceCondition,
13
- EcommerceConditionMap,
14
- ExtendedEcommerceConditionMap,
15
- EcommercePartnerConfiguration,
16
- EcommerceSharedDefaults,
17
- ExtendedEbayCategoryMap,
18
- ExtendedInventoryTypeListingDefaults,
19
- InventoryType,
20
- InventoryTypeCategory,
21
- InventoryTypeListingDefaults,
22
- NewInventoryTypeListingDefaults,
23
- Store,
24
- } from './utils.js'
25
- import EcommerceConditionMapConfig from './EcommerceConditionMapConfiguration.svelte'
26
- import EcommerceCategoryMapConfig from './EcommerceCategoryMapConfiguration.svelte'
27
- import EcommerceStoreConfig from './EcommerceStoreConfiguration.svelte'
28
- import EcommercePartTypeConfig from './EcommercePartTypeConfig.svelte'
29
-
30
- import { translate as defaultTranslate } from '@isoftdata/utility-string'
31
- const { t: translate } = getContext<i18n>('i18next') || { t: defaultTranslate }
32
-
33
- interface Props {
34
- ebayCategoryList: EbayCategory[]
35
- ebayCategoryMapList: ExtendedEbayCategoryMap[]
36
- ebayPolicyList: EbayPolicy[]
37
- ebayLocationList: EbayLocation[]
38
- ecommerceConditionList: EcommerceCondition[]
39
- ecommerceConditionMappingList: ExtendedEcommerceConditionMap[]
40
- inventoryConditionList: string[]
41
- inventoryTypeCategoryList: InventoryTypeCategory[]
42
- inventoryTypeList: InventoryType[]
43
- inventoryTypeWithDefaultConfigList: ExtendedInventoryTypeListingDefaults[]
44
- partnerConfigurationList: EcommercePartnerConfiguration[]
45
- saveEcommerceCategoryMap: (categoryMappingRow: EbayCategoryMap) => Promise<void>
46
- saveEcommerceConditionMap: (config: EcommerceConditionMap) => Promise<void>
47
- saveEcommercePartnerConfig: (config: EcommercePartnerConfiguration) => Promise<void>
48
- saveEcommercePartTypeConfig: (
49
- config: InventoryTypeListingDefaults | NewInventoryTypeListingDefaults,
50
- ) => Promise<void>
51
- storeList: Store[]
52
- //
53
- }
54
-
55
- let {
56
- ebayCategoryList = [],
57
- ebayCategoryMapList = [],
58
- ebayLocationList = [],
59
- ebayPolicyList = [],
60
- ecommerceConditionList = [],
61
- ecommerceConditionMappingList = [],
62
- inventoryConditionList = [],
63
- inventoryTypeCategoryList = [],
64
- inventoryTypeList = [],
65
- inventoryTypeWithDefaultConfigList = [],
66
- partnerConfigurationList = [],
67
- saveEcommerceCategoryMap = async (_: EbayCategoryMap) => {},
68
- saveEcommerceConditionMap = async (_: EcommerceConditionMap) => {},
69
- saveEcommercePartnerConfig = async (_: EcommercePartnerConfiguration) => {},
70
- saveEcommercePartTypeConfig = async (_: InventoryTypeListingDefaults | NewInventoryTypeListingDefaults) => {},
71
- storeList = [],
72
- }: Props = $props()
73
- // Hard coding this for now, should be selectable between htp and ebay....maybe just default to the only one?
74
- let selectedEcommercePartnerId = $state(1)
75
-
76
- let globalDefaults = $derived.by(getGlobalDefaults)
77
-
78
- function getGlobalDefaults() {
79
- const matchingPartnerConfig = partnerConfigurationList.find(
80
- row => row.ecommercePartnerId === selectedEcommercePartnerId,
81
- )
82
- if (matchingPartnerConfig) {
83
- return matchingPartnerConfig.defaults?.global
84
- }
85
- }
86
-
87
- // Handles global defaults being changed
88
- async function handleGlobalConfigChange(newGlobalDefaults: EcommerceSharedDefaults) {
89
- // Find the matching partner config to update the global defaults on
90
- const matchingPartnerConfig = partnerConfigurationList.find(
91
- row => row.ecommercePartnerId === selectedEcommercePartnerId,
92
- )
93
-
94
- if (!matchingPartnerConfig) {
95
- console.error('No matching partner configuration found for ID:', selectedEcommercePartnerId)
96
- return
97
- }
98
-
99
- // Initialize defaults if it doesn't exist
100
- if (!matchingPartnerConfig.defaults) {
101
- matchingPartnerConfig.defaults = {
102
- global: {},
103
- store: [],
104
- }
105
- }
106
-
107
- // Update the global defaults with the new values
108
- matchingPartnerConfig.defaults.global = { ...newGlobalDefaults }
109
-
110
- await saveEcommercePartnerConfig(matchingPartnerConfig)
111
- }
112
-
113
- async function handleStoreConfigChange(updatedPartnerConfig: EcommercePartnerConfiguration) {
114
- await saveEcommercePartnerConfig(updatedPartnerConfig)
115
- }
116
-
117
- async function handleCategoryMapChange(categoryMappingRow: EbayCategoryMap) {
118
- await saveEcommerceCategoryMap(categoryMappingRow)
119
- }
120
- async function handleConditionMapChange(conditionMapRow: EcommerceConditionMap) {
121
- await saveEcommerceConditionMap(conditionMapRow)
122
- }
123
-
124
- async function handlePartTypeConfigurationChange(
125
- partTypeConfigRow: InventoryTypeListingDefaults | NewInventoryTypeListingDefaults,
126
- ) {
127
- await saveEcommercePartTypeConfig(partTypeConfigRow)
128
- }
129
- </script>
130
-
131
- <div class="row">
132
- <div class="col">
133
- <div class="card-header">
134
- <h4 class="mb-0">{translate('ecommerce.configuration.globalDefaults', 'Global Defaults')}</h4>
135
- <p class="text-muted mb-0">
136
- {translate('ecommerce.configuration.configureGlobalDefaultsForEbay', 'Configure global defaults for eBay')}
137
- </p>
138
- </div>
139
- <div class="card-body">
140
- <EcommerceDefaults
141
- bind:defaults={globalDefaults}
142
- {ebayPolicyList}
143
- {ecommerceConditionList}
144
- {partnerConfigurationList}
145
- defaultsChanged={handleGlobalConfigChange}
146
- {selectedEcommercePartnerId}
147
- />
148
- </div>
149
- </div>
150
- <div class="col">
151
- <EcommerceStoreConfig
152
- {ecommerceConditionList}
153
- {ebayLocationList}
154
- {ebayPolicyList}
155
- partnerConfigurationChanged={handleStoreConfigChange}
156
- {partnerConfigurationList}
157
- {selectedEcommercePartnerId}
158
- {storeList}
159
- />
160
- </div>
161
- </div>
162
- <div class="row">
163
- <div class="col">
164
- <EcommerceConditionMapConfig
165
- {ecommerceConditionList}
166
- {inventoryConditionList}
167
- {ecommerceConditionMappingList}
168
- conditionMapChanged={handleConditionMapChange}
169
- />
170
- </div>
171
- </div>
172
- <div class="row">
173
- <div class="col">
174
- <EcommerceCategoryMapConfig
175
- {ebayCategoryList}
176
- {ebayCategoryMapList}
177
- {inventoryTypeList}
178
- categoryMapChanged={handleCategoryMapChange}
179
- />
180
- </div>
181
- </div>
182
- <div class="row">
183
- <div class="col">
184
- <EcommercePartTypeConfig
185
- {ebayPolicyList}
186
- {ecommerceConditionList}
187
- {inventoryTypeList}
188
- {inventoryTypeWithDefaultConfigList}
189
- {inventoryTypeCategoryList}
190
- {partnerConfigurationList}
191
- partTypeConfigurationChanged={handlePartTypeConfigurationChange}
192
- {selectedEcommercePartnerId}
193
- />
194
- </div>
195
- </div>
1
+ <script lang="ts">
2
+ import type { i18n } from 'i18next'
3
+
4
+ import { getContext } from 'svelte'
5
+
6
+ import EcommerceDefaults from './EcommerceDefaults.svelte'
7
+ import type {
8
+ EbayCategory,
9
+ EbayCategoryMap,
10
+ EbayPolicy,
11
+ EbayLocation,
12
+ EcommerceCondition,
13
+ EcommerceConditionMap,
14
+ ExtendedEcommerceConditionMap,
15
+ EcommercePartnerConfiguration,
16
+ EcommerceSharedDefaults,
17
+ ExtendedEbayCategoryMap,
18
+ ExtendedInventoryTypeListingDefaults,
19
+ InventoryType,
20
+ InventoryTypeCategory,
21
+ InventoryTypeListingDefaults,
22
+ NewInventoryTypeListingDefaults,
23
+ Store,
24
+ } from './utils.js'
25
+ import EcommerceConditionMapConfig from './EcommerceConditionMapConfiguration.svelte'
26
+ import EcommerceCategoryMapConfig from './EcommerceCategoryMapConfiguration.svelte'
27
+ import EcommerceStoreConfig from './EcommerceStoreConfiguration.svelte'
28
+ import EcommercePartTypeConfig from './EcommercePartTypeConfig.svelte'
29
+
30
+ import { translate as defaultTranslate } from '@isoftdata/utility-string'
31
+ const { t: translate } = getContext<i18n>('i18next') || { t: defaultTranslate }
32
+
33
+ interface Props {
34
+ ebayCategoryList: Array<EbayCategory>
35
+ ebayCategoryMapList: Array<ExtendedEbayCategoryMap>
36
+ ebayPolicyList: Array<EbayPolicy>
37
+ ebayLocationList: Array<EbayLocation>
38
+ ecommerceConditionList: Array<EcommerceCondition>
39
+ ecommerceConditionMappingList: Array<ExtendedEcommerceConditionMap>
40
+ inventoryConditionList: Array<string>
41
+ inventoryTypeCategoryList: Array<InventoryTypeCategory>
42
+ inventoryTypeList: Array<InventoryType>
43
+ inventoryTypeWithDefaultConfigList: Array<ExtendedInventoryTypeListingDefaults>
44
+ partnerConfigurationList: Array<EcommercePartnerConfiguration>
45
+ saveEcommerceCategoryMap?: ((categoryMappingRow: EbayCategoryMap) => Promise<void>) | undefined
46
+ saveEcommerceConditionMap?: ((config: EcommerceConditionMap) => Promise<void>) | undefined
47
+ saveEcommercePartnerConfig?: ((config: EcommercePartnerConfiguration) => Promise<void>) | undefined
48
+ saveEcommercePartTypeConfig?:
49
+ | ((config: InventoryTypeListingDefaults | NewInventoryTypeListingDefaults) => Promise<void>)
50
+ | undefined
51
+ storeList: Array<Store>
52
+ //
53
+ }
54
+
55
+ let {
56
+ ebayCategoryList = [],
57
+ ebayCategoryMapList = [],
58
+ ebayLocationList = [],
59
+ ebayPolicyList = [],
60
+ ecommerceConditionList = [],
61
+ ecommerceConditionMappingList = [],
62
+ inventoryConditionList = [],
63
+ inventoryTypeCategoryList = [],
64
+ inventoryTypeList = [],
65
+ inventoryTypeWithDefaultConfigList = [],
66
+ partnerConfigurationList = [],
67
+ saveEcommerceCategoryMap,
68
+ saveEcommerceConditionMap,
69
+ saveEcommercePartnerConfig,
70
+ saveEcommercePartTypeConfig,
71
+ storeList = [],
72
+ }: Props = $props()
73
+ // Hard coding this for now, should be selectable between htp and ebay....maybe just default to the only one?
74
+ let selectedEcommercePartnerId = $state(1)
75
+
76
+ let globalDefaults = $derived.by(getGlobalDefaults)
77
+
78
+ function getGlobalDefaults() {
79
+ const matchingPartnerConfig = partnerConfigurationList.find(
80
+ row => row.ecommercePartnerId === selectedEcommercePartnerId,
81
+ )
82
+ if (matchingPartnerConfig) {
83
+ return matchingPartnerConfig.defaults?.global
84
+ }
85
+ }
86
+
87
+ // Handles global defaults being changed
88
+ async function handleGlobalConfigChange() {
89
+ // Find the matching partner config to update the global defaults on
90
+ const matchingPartnerConfig = partnerConfigurationList.find(
91
+ row => row.ecommercePartnerId === selectedEcommercePartnerId,
92
+ )
93
+
94
+ if (!matchingPartnerConfig) {
95
+ console.error('No matching partner configuration found for ID:', selectedEcommercePartnerId)
96
+ return
97
+ }
98
+
99
+ // Initialize defaults if it doesn't exist
100
+ if (!matchingPartnerConfig.defaults) {
101
+ matchingPartnerConfig.defaults = {
102
+ global: {},
103
+ store: [],
104
+ }
105
+ }
106
+
107
+ // Update the global defaults with the new values (globalDefaults is already updated via binding)
108
+ if (globalDefaults) {
109
+ matchingPartnerConfig.defaults.global = { ...globalDefaults }
110
+ }
111
+
112
+ await saveEcommercePartnerConfig?.(matchingPartnerConfig)
113
+ }
114
+
115
+ async function handleStoreConfigChange(updatedPartnerConfig: EcommercePartnerConfiguration) {
116
+ await saveEcommercePartnerConfig?.(updatedPartnerConfig)
117
+ }
118
+
119
+ async function handleCategoryMapChange(categoryMappingRow: EbayCategoryMap) {
120
+ await saveEcommerceCategoryMap?.(categoryMappingRow)
121
+ }
122
+ async function handleConditionMapChange(conditionMapRow: EcommerceConditionMap) {
123
+ await saveEcommerceConditionMap?.(conditionMapRow)
124
+ }
125
+
126
+ async function handlePartTypeConfigurationChange(
127
+ partTypeConfigRow: InventoryTypeListingDefaults | NewInventoryTypeListingDefaults,
128
+ ) {
129
+ await saveEcommercePartTypeConfig?.(partTypeConfigRow)
130
+ }
131
+ </script>
132
+
133
+ <div class="row mb-3">
134
+ <div class="col">
135
+ <div class="card">
136
+ <div class="card-header">
137
+ <h4 class="mb-0">{translate('ecommerce.configuration.globalDefaults', 'Global Defaults')}</h4>
138
+ <p class="text-muted mb-0">
139
+ {translate('ecommerce.configuration.configureGlobalDefaultsForEbay', 'Configure global defaults for eBay')}
140
+ </p>
141
+ </div>
142
+ <div class="card-body">
143
+ <EcommerceDefaults
144
+ bind:defaults={globalDefaults}
145
+ {ebayPolicyList}
146
+ {ecommerceConditionList}
147
+ {partnerConfigurationList}
148
+ defaultsChanged={handleGlobalConfigChange}
149
+ {selectedEcommercePartnerId}
150
+ />
151
+ </div>
152
+ </div>
153
+ </div>
154
+ <div class="col">
155
+ <EcommerceStoreConfig
156
+ {ecommerceConditionList}
157
+ {ebayLocationList}
158
+ {ebayPolicyList}
159
+ partnerConfigurationChanged={handleStoreConfigChange}
160
+ {partnerConfigurationList}
161
+ {selectedEcommercePartnerId}
162
+ {storeList}
163
+ />
164
+ </div>
165
+ </div>
166
+ <div class="row mb-3">
167
+ <div class="col">
168
+ <EcommerceConditionMapConfig
169
+ {ecommerceConditionList}
170
+ {inventoryConditionList}
171
+ {ecommerceConditionMappingList}
172
+ conditionMapChanged={handleConditionMapChange}
173
+ />
174
+ </div>
175
+ </div>
176
+ <div class="row mb-3">
177
+ <div class="col">
178
+ <EcommerceCategoryMapConfig
179
+ {ebayCategoryList}
180
+ {ebayCategoryMapList}
181
+ {inventoryTypeList}
182
+ categoryMapChanged={handleCategoryMapChange}
183
+ />
184
+ </div>
185
+ </div>
186
+ <div class="row mb-3">
187
+ <div class="col">
188
+ <EcommercePartTypeConfig
189
+ {ebayPolicyList}
190
+ {ecommerceConditionList}
191
+ {inventoryTypeList}
192
+ {inventoryTypeWithDefaultConfigList}
193
+ {inventoryTypeCategoryList}
194
+ {partnerConfigurationList}
195
+ partTypeConfigurationChanged={handlePartTypeConfigurationChange}
196
+ {selectedEcommercePartnerId}
197
+ />
198
+ </div>
199
+ </div>
@@ -1,21 +1,21 @@
1
1
  import type { EbayCategory, EbayCategoryMap, EbayPolicy, EbayLocation, EcommerceCondition, EcommerceConditionMap, ExtendedEcommerceConditionMap, EcommercePartnerConfiguration, ExtendedEbayCategoryMap, ExtendedInventoryTypeListingDefaults, InventoryType, InventoryTypeCategory, InventoryTypeListingDefaults, NewInventoryTypeListingDefaults, Store } from './utils.js';
2
2
  interface Props {
3
- ebayCategoryList: EbayCategory[];
4
- ebayCategoryMapList: ExtendedEbayCategoryMap[];
5
- ebayPolicyList: EbayPolicy[];
6
- ebayLocationList: EbayLocation[];
7
- ecommerceConditionList: EcommerceCondition[];
8
- ecommerceConditionMappingList: ExtendedEcommerceConditionMap[];
9
- inventoryConditionList: string[];
10
- inventoryTypeCategoryList: InventoryTypeCategory[];
11
- inventoryTypeList: InventoryType[];
12
- inventoryTypeWithDefaultConfigList: ExtendedInventoryTypeListingDefaults[];
13
- partnerConfigurationList: EcommercePartnerConfiguration[];
14
- saveEcommerceCategoryMap: (categoryMappingRow: EbayCategoryMap) => Promise<void>;
15
- saveEcommerceConditionMap: (config: EcommerceConditionMap) => Promise<void>;
16
- saveEcommercePartnerConfig: (config: EcommercePartnerConfiguration) => Promise<void>;
17
- saveEcommercePartTypeConfig: (config: InventoryTypeListingDefaults | NewInventoryTypeListingDefaults) => Promise<void>;
18
- storeList: Store[];
3
+ ebayCategoryList: Array<EbayCategory>;
4
+ ebayCategoryMapList: Array<ExtendedEbayCategoryMap>;
5
+ ebayPolicyList: Array<EbayPolicy>;
6
+ ebayLocationList: Array<EbayLocation>;
7
+ ecommerceConditionList: Array<EcommerceCondition>;
8
+ ecommerceConditionMappingList: Array<ExtendedEcommerceConditionMap>;
9
+ inventoryConditionList: Array<string>;
10
+ inventoryTypeCategoryList: Array<InventoryTypeCategory>;
11
+ inventoryTypeList: Array<InventoryType>;
12
+ inventoryTypeWithDefaultConfigList: Array<ExtendedInventoryTypeListingDefaults>;
13
+ partnerConfigurationList: Array<EcommercePartnerConfiguration>;
14
+ saveEcommerceCategoryMap?: ((categoryMappingRow: EbayCategoryMap) => Promise<void>) | undefined;
15
+ saveEcommerceConditionMap?: ((config: EcommerceConditionMap) => Promise<void>) | undefined;
16
+ saveEcommercePartnerConfig?: ((config: EcommercePartnerConfiguration) => Promise<void>) | undefined;
17
+ saveEcommercePartTypeConfig?: ((config: InventoryTypeListingDefaults | NewInventoryTypeListingDefaults) => Promise<void>) | undefined;
18
+ storeList: Array<Store>;
19
19
  }
20
20
  declare const EcommerceConfiguration: import("svelte").Component<Props, {}, "">;
21
21
  type EcommerceConfiguration = ReturnType<typeof EcommerceConfiguration>;