@isoftdata/svelte-ecommerce 1.0.0-beta.4 → 1.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -56
- package/dist/EcommerceCategoryMapConfiguration.svelte +251 -251
- package/dist/EcommerceConditionMapConfiguration.svelte +192 -192
- package/dist/EcommerceConfiguration.svelte +204 -199
- package/dist/EcommerceDefaults.svelte +388 -352
- package/dist/EcommerceListingDetails.svelte +854 -852
- package/dist/EcommercePartTypeConfig.svelte +283 -277
- package/dist/EcommerceStoreConfiguration.svelte +251 -251
- package/dist/PolicyList.svelte +53 -54
- package/dist/helpers/listing.d.ts +19 -1
- package/dist/helpers/listing.js +112 -16
- package/dist/utils.d.ts +2 -1
- package/package.json +14 -13
|
@@ -1,199 +1,204 @@
|
|
|
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 = $
|
|
75
|
-
|
|
76
|
-
let globalDefaults = $derived.by(getGlobalDefaults)
|
|
77
|
-
|
|
78
|
-
function
|
|
79
|
-
const matchingPartnerConfig = partnerConfigurationList.find(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
<
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
{
|
|
162
|
-
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
{
|
|
195
|
-
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
|
|
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: 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 = $derived.by(getEcommercePartnerId)
|
|
75
|
+
|
|
76
|
+
let globalDefaults = $derived.by(getGlobalDefaults)
|
|
77
|
+
|
|
78
|
+
function getEcommercePartnerId() {
|
|
79
|
+
const matchingPartnerConfig = partnerConfigurationList.find(row => row.name === 'ebay')
|
|
80
|
+
return matchingPartnerConfig ? matchingPartnerConfig.ecommercePartnerId : 1
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getGlobalDefaults() {
|
|
84
|
+
const matchingPartnerConfig = partnerConfigurationList.find(
|
|
85
|
+
row => row.ecommercePartnerId === selectedEcommercePartnerId,
|
|
86
|
+
)
|
|
87
|
+
if (matchingPartnerConfig) {
|
|
88
|
+
return matchingPartnerConfig.defaults?.global
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Handles global defaults being changed
|
|
93
|
+
async function handleGlobalConfigChange() {
|
|
94
|
+
// Find the matching partner config to update the global defaults on
|
|
95
|
+
const matchingPartnerConfig = partnerConfigurationList.find(
|
|
96
|
+
row => row.ecommercePartnerId === selectedEcommercePartnerId,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
if (!matchingPartnerConfig) {
|
|
100
|
+
console.error('No matching partner configuration found for ID:', selectedEcommercePartnerId)
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Initialize defaults if it doesn't exist
|
|
105
|
+
if (!matchingPartnerConfig.defaults) {
|
|
106
|
+
matchingPartnerConfig.defaults = {
|
|
107
|
+
global: {},
|
|
108
|
+
store: [],
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Update the global defaults with the new values (globalDefaults is already updated via binding)
|
|
113
|
+
if (globalDefaults) {
|
|
114
|
+
matchingPartnerConfig.defaults.global = { ...globalDefaults }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
await saveEcommercePartnerConfig?.(matchingPartnerConfig)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function handleStoreConfigChange(updatedPartnerConfig: EcommercePartnerConfiguration) {
|
|
121
|
+
await saveEcommercePartnerConfig?.(updatedPartnerConfig)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function handleCategoryMapChange(categoryMappingRow: EbayCategoryMap) {
|
|
125
|
+
await saveEcommerceCategoryMap?.(categoryMappingRow)
|
|
126
|
+
}
|
|
127
|
+
async function handleConditionMapChange(conditionMapRow: EcommerceConditionMap) {
|
|
128
|
+
await saveEcommerceConditionMap?.(conditionMapRow)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function handlePartTypeConfigurationChange(
|
|
132
|
+
partTypeConfigRow: InventoryTypeListingDefaults | NewInventoryTypeListingDefaults,
|
|
133
|
+
) {
|
|
134
|
+
await saveEcommercePartTypeConfig?.(partTypeConfigRow)
|
|
135
|
+
}
|
|
136
|
+
</script>
|
|
137
|
+
|
|
138
|
+
<div class="row mb-3">
|
|
139
|
+
<div class="col">
|
|
140
|
+
<div class="card">
|
|
141
|
+
<div class="card-header">
|
|
142
|
+
<h4 class="mb-0">{translate('ecommerce.configuration.globalDefaults', 'Global Defaults')}</h4>
|
|
143
|
+
<p class="text-muted mb-0">
|
|
144
|
+
{translate('ecommerce.configuration.configureGlobalDefaultsForEbay', 'Configure global defaults for eBay')}
|
|
145
|
+
</p>
|
|
146
|
+
</div>
|
|
147
|
+
<div class="card-body">
|
|
148
|
+
<EcommerceDefaults
|
|
149
|
+
bind:defaults={globalDefaults}
|
|
150
|
+
{ebayPolicyList}
|
|
151
|
+
{ecommerceConditionList}
|
|
152
|
+
{partnerConfigurationList}
|
|
153
|
+
defaultsChanged={handleGlobalConfigChange}
|
|
154
|
+
{selectedEcommercePartnerId}
|
|
155
|
+
/>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
<div class="col">
|
|
160
|
+
<EcommerceStoreConfig
|
|
161
|
+
{ecommerceConditionList}
|
|
162
|
+
{ebayLocationList}
|
|
163
|
+
{ebayPolicyList}
|
|
164
|
+
partnerConfigurationChanged={handleStoreConfigChange}
|
|
165
|
+
{partnerConfigurationList}
|
|
166
|
+
{selectedEcommercePartnerId}
|
|
167
|
+
{storeList}
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
<div class="row mb-3">
|
|
172
|
+
<div class="col">
|
|
173
|
+
<EcommerceConditionMapConfig
|
|
174
|
+
{ecommerceConditionList}
|
|
175
|
+
{inventoryConditionList}
|
|
176
|
+
{ecommerceConditionMappingList}
|
|
177
|
+
conditionMapChanged={handleConditionMapChange}
|
|
178
|
+
/>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
<div class="row mb-3">
|
|
182
|
+
<div class="col">
|
|
183
|
+
<EcommerceCategoryMapConfig
|
|
184
|
+
{ebayCategoryList}
|
|
185
|
+
{ebayCategoryMapList}
|
|
186
|
+
{inventoryTypeList}
|
|
187
|
+
categoryMapChanged={handleCategoryMapChange}
|
|
188
|
+
/>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
<div class="row mb-3">
|
|
192
|
+
<div class="col">
|
|
193
|
+
<EcommercePartTypeConfig
|
|
194
|
+
{ebayPolicyList}
|
|
195
|
+
{ecommerceConditionList}
|
|
196
|
+
{inventoryTypeList}
|
|
197
|
+
{inventoryTypeWithDefaultConfigList}
|
|
198
|
+
{inventoryTypeCategoryList}
|
|
199
|
+
{partnerConfigurationList}
|
|
200
|
+
partTypeConfigurationChanged={handlePartTypeConfigurationChange}
|
|
201
|
+
{selectedEcommercePartnerId}
|
|
202
|
+
/>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|