fix: use apiClient directly instead of window.apiClient in onboarding.js
Fixes JavaScript error "can't access property 'get', window.apiClient is undefined" by following the codebase pattern where apiClient is accessed directly as a global variable rather than via window object. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
14
static/vendor/js/onboarding.js
vendored
14
static/vendor/js/onboarding.js
vendored
@@ -88,7 +88,7 @@ function vendorOnboarding() {
|
|||||||
this.error = null;
|
this.error = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await window.apiClient.get('/api/v1/vendor/onboarding/status');
|
const response = await apiClient.get('/api/v1/vendor/onboarding/status');
|
||||||
this.status = response;
|
this.status = response;
|
||||||
this.currentStep = response.current_step;
|
this.currentStep = response.current_step;
|
||||||
this.completedSteps = response.completed_steps_count;
|
this.completedSteps = response.completed_steps_count;
|
||||||
@@ -118,12 +118,12 @@ function vendorOnboarding() {
|
|||||||
async loadStepData() {
|
async loadStepData() {
|
||||||
try {
|
try {
|
||||||
if (this.currentStep === 'company_profile') {
|
if (this.currentStep === 'company_profile') {
|
||||||
const data = await window.apiClient.get('/api/v1/vendor/onboarding/step/company-profile');
|
const data = await apiClient.get('/api/v1/vendor/onboarding/step/company-profile');
|
||||||
if (data) {
|
if (data) {
|
||||||
Object.assign(this.formData, data);
|
Object.assign(this.formData, data);
|
||||||
}
|
}
|
||||||
} else if (this.currentStep === 'product_import') {
|
} else if (this.currentStep === 'product_import') {
|
||||||
const data = await window.apiClient.get('/api/v1/vendor/onboarding/step/product-import');
|
const data = await apiClient.get('/api/v1/vendor/onboarding/step/product-import');
|
||||||
if (data) {
|
if (data) {
|
||||||
Object.assign(this.formData, {
|
Object.assign(this.formData, {
|
||||||
csv_url_fr: data.csv_url_fr || '',
|
csv_url_fr: data.csv_url_fr || '',
|
||||||
@@ -163,7 +163,7 @@ function vendorOnboarding() {
|
|||||||
this.connectionError = null;
|
this.connectionError = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await window.apiClient.post('/api/v1/vendor/onboarding/step/letzshop-api/test', {
|
const response = await apiClient.post('/api/v1/vendor/onboarding/step/letzshop-api/test', {
|
||||||
api_key: this.formData.api_key,
|
api_key: this.formData.api_key,
|
||||||
shop_slug: this.formData.shop_slug,
|
shop_slug: this.formData.shop_slug,
|
||||||
});
|
});
|
||||||
@@ -187,7 +187,7 @@ function vendorOnboarding() {
|
|||||||
this.saving = true;
|
this.saving = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await window.apiClient.post('/api/v1/vendor/onboarding/step/order-sync/trigger', {
|
const response = await apiClient.post('/api/v1/vendor/onboarding/step/order-sync/trigger', {
|
||||||
days_back: parseInt(this.formData.days_back),
|
days_back: parseInt(this.formData.days_back),
|
||||||
include_products: true,
|
include_products: true,
|
||||||
});
|
});
|
||||||
@@ -216,7 +216,7 @@ function vendorOnboarding() {
|
|||||||
// Poll sync progress
|
// Poll sync progress
|
||||||
async pollSyncProgress() {
|
async pollSyncProgress() {
|
||||||
try {
|
try {
|
||||||
const response = await window.apiClient.get(
|
const response = await apiClient.get(
|
||||||
`/api/v1/vendor/onboarding/step/order-sync/progress/${this.syncJobId}`
|
`/api/v1/vendor/onboarding/step/order-sync/progress/${this.syncJobId}`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ function vendorOnboarding() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await window.apiClient.post(endpoint, payload);
|
const response = await apiClient.post(endpoint, payload);
|
||||||
|
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
throw new Error(response.message || 'Save failed');
|
throw new Error(response.message || 'Save failed');
|
||||||
|
|||||||
Reference in New Issue
Block a user