update
This commit is contained in:
@@ -131,7 +131,6 @@ class AboutServiceAPI {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching about page data:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -155,7 +154,6 @@ class AboutServiceAPI {
|
||||
const data = await response.json();
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching about banners:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +177,6 @@ class AboutServiceAPI {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching about banner ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -203,7 +200,6 @@ class AboutServiceAPI {
|
||||
const data = await response.json();
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching about services:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -227,7 +223,6 @@ class AboutServiceAPI {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching about service ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -251,7 +246,6 @@ class AboutServiceAPI {
|
||||
const data = await response.json();
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching about processes:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -275,7 +269,6 @@ class AboutServiceAPI {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching about process ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -299,7 +292,6 @@ class AboutServiceAPI {
|
||||
const data = await response.json();
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching about journeys:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -323,7 +315,6 @@ class AboutServiceAPI {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching about journey ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching blog posts:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -142,7 +141,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching blog post:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -164,7 +162,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching featured posts:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -186,7 +183,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching latest posts:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -208,7 +204,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching popular posts:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -230,7 +225,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching related posts:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -252,7 +246,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return Array.isArray(data) ? data : data.results || [];
|
||||
} catch (error) {
|
||||
console.error('Error fetching blog categories:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -274,7 +267,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching categories with posts:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -296,7 +288,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching blog category:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -318,7 +309,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return Array.isArray(data) ? data : data.results || [];
|
||||
} catch (error) {
|
||||
console.error('Error fetching blog tags:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -340,7 +330,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching posts by tag:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -362,7 +351,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return Array.isArray(data) ? data : data.results || [];
|
||||
} catch (error) {
|
||||
console.error('Error fetching blog authors:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -384,7 +372,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching posts by author:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -406,7 +393,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return Array.isArray(data) ? data : data.results || [];
|
||||
} catch (error) {
|
||||
console.error('Error fetching comments:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -429,7 +415,6 @@ export const blogService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error creating comment:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -54,13 +54,14 @@ export interface JobApplication {
|
||||
|
||||
class CareerService {
|
||||
private baseUrl = `${API_BASE_URL}/api/career`;
|
||||
|
||||
|
||||
/**
|
||||
* Get all active job positions
|
||||
*/
|
||||
async getAllJobs(): Promise<JobPosition[]> {
|
||||
try {
|
||||
const response = await fetch(`${this.baseUrl}/jobs/`, {
|
||||
const response = await fetch(`${this.baseUrl}/jobs`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -75,7 +76,6 @@ class CareerService {
|
||||
// Handle paginated response - extract results array
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching jobs:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class CareerService {
|
||||
*/
|
||||
async getJobBySlug(slug: string): Promise<JobPosition> {
|
||||
try {
|
||||
const response = await fetch(`${this.baseUrl}/jobs/${slug}/`, {
|
||||
const response = await fetch(`${this.baseUrl}/jobs/${slug}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -99,7 +99,6 @@ class CareerService {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching job:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -109,7 +108,7 @@ class CareerService {
|
||||
*/
|
||||
async getFeaturedJobs(): Promise<JobPosition[]> {
|
||||
try {
|
||||
const response = await fetch(`${this.baseUrl}/jobs/featured/`, {
|
||||
const response = await fetch(`${this.baseUrl}/jobs/featured`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -124,7 +123,6 @@ class CareerService {
|
||||
// Handle paginated response - extract results array
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching featured jobs:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -136,19 +134,15 @@ class CareerService {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
|
||||
// Append all fields to FormData
|
||||
// Required fields
|
||||
formData.append('job', applicationData.job.toString());
|
||||
formData.append('first_name', applicationData.first_name);
|
||||
formData.append('last_name', applicationData.last_name);
|
||||
formData.append('email', applicationData.email);
|
||||
formData.append('consent', applicationData.consent.toString());
|
||||
formData.append('resume', applicationData.resume);
|
||||
|
||||
// Append resume file
|
||||
if (applicationData.resume) {
|
||||
formData.append('resume', applicationData.resume);
|
||||
}
|
||||
|
||||
// Append optional fields
|
||||
// Optional fields (only append if they exist)
|
||||
if (applicationData.phone) formData.append('phone', applicationData.phone);
|
||||
if (applicationData.current_position) formData.append('current_position', applicationData.current_position);
|
||||
if (applicationData.current_company) formData.append('current_company', applicationData.current_company);
|
||||
@@ -160,24 +154,24 @@ class CareerService {
|
||||
if (applicationData.website_url) formData.append('website_url', applicationData.website_url);
|
||||
if (applicationData.available_from) formData.append('available_from', applicationData.available_from);
|
||||
if (applicationData.notice_period) formData.append('notice_period', applicationData.notice_period);
|
||||
if (applicationData.expected_salary) formData.append('expected_salary', applicationData.expected_salary.toString());
|
||||
if (applicationData.expected_salary !== undefined) formData.append('expected_salary', applicationData.expected_salary.toString());
|
||||
if (applicationData.salary_currency) formData.append('salary_currency', applicationData.salary_currency);
|
||||
|
||||
const response = await fetch(`${this.baseUrl}/applications/`, {
|
||||
|
||||
const response = await fetch(`${this.baseUrl}/applications`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
// Don't set Content-Type header - browser will set it with boundary for multipart/form-data
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
throw new Error(errorData.error || `Failed to submit application: ${response.statusText}`);
|
||||
const errorData = await response.json().catch(() => ({}));
|
||||
const errorMessage = errorData.error || errorData.message || errorData.detail || `HTTP ${response.status}: ${response.statusText}`;
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error submitting application:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -187,7 +181,7 @@ class CareerService {
|
||||
*/
|
||||
async getJobsByDepartment(department: string): Promise<JobPosition[]> {
|
||||
try {
|
||||
const response = await fetch(`${this.baseUrl}/jobs/?department=${department}`, {
|
||||
const response = await fetch(`${this.baseUrl}/jobs?department=${department}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -202,7 +196,6 @@ class CareerService {
|
||||
// Handle paginated response - extract results array
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching jobs by department:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -212,7 +205,7 @@ class CareerService {
|
||||
*/
|
||||
async getJobsByEmploymentType(employmentType: string): Promise<JobPosition[]> {
|
||||
try {
|
||||
const response = await fetch(`${this.baseUrl}/jobs/?employment_type=${employmentType}`, {
|
||||
const response = await fetch(`${this.baseUrl}/jobs?employment_type=${employmentType}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -227,7 +220,6 @@ class CareerService {
|
||||
// Handle paginated response - extract results array
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching jobs by employment type:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching case studies:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -140,7 +139,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching case study ${slug}:`, error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -165,7 +163,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching featured case studies:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -190,7 +187,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching latest case studies:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -215,7 +211,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching popular case studies:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -240,7 +235,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching related case studies for ${slug}:`, error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -265,7 +259,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching case study categories:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -290,7 +283,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching categories with case studies:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -315,7 +307,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching clients:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -340,7 +331,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching client ${slug}:`, error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -365,7 +355,6 @@ export const caseStudyService = {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching case studies for client ${slug}:`, error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -51,7 +51,6 @@ class PolicyServiceAPI {
|
||||
const data = await response.json();
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching policies:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +74,6 @@ class PolicyServiceAPI {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching policy ${type}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +97,6 @@ class PolicyServiceAPI {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching policy ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,6 @@ export const getTicketCategories = async (): Promise<TicketCategory[]> => {
|
||||
// Handle paginated response
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching ticket categories:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -167,7 +166,6 @@ export const getTicketStatuses = async (): Promise<TicketStatus[]> => {
|
||||
// Handle paginated response
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching ticket statuses:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -183,7 +181,6 @@ export const getTicketPriorities = async (): Promise<TicketPriority[]> => {
|
||||
// Handle paginated response
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching ticket priorities:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -204,17 +201,38 @@ export const createTicket = async (data: CreateTicketData): Promise<SupportTicke
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => ({}));
|
||||
|
||||
// Handle validation errors
|
||||
if (response.status === 400 && errorData.user_email) {
|
||||
throw new Error(errorData.user_email[0] || 'Email validation failed');
|
||||
// Handle specific HTTP status codes
|
||||
if (response.status === 400) {
|
||||
// Handle validation errors
|
||||
if (errorData.user_email) {
|
||||
throw new Error(errorData.user_email[0] || 'Email validation failed');
|
||||
}
|
||||
if (errorData.title) {
|
||||
throw new Error(errorData.title[0] || 'Title is required');
|
||||
}
|
||||
if (errorData.description) {
|
||||
throw new Error(errorData.description[0] || 'Description is required');
|
||||
}
|
||||
if (errorData.user_name) {
|
||||
throw new Error(errorData.user_name[0] || 'Name is required');
|
||||
}
|
||||
// Generic validation error
|
||||
throw new Error(errorData.detail || errorData.message || 'Please check all required fields and try again');
|
||||
} else if (response.status === 429) {
|
||||
throw new Error('Too many requests. Please wait a moment and try again');
|
||||
} else if (response.status >= 500) {
|
||||
throw new Error('Server error. Please try again later');
|
||||
} else if (response.status === 403) {
|
||||
throw new Error('Access denied. Please contact support if this persists');
|
||||
} else if (response.status === 404) {
|
||||
throw new Error('Service not found. Please refresh the page and try again');
|
||||
}
|
||||
|
||||
throw new Error(errorData.detail || errorData.message || 'Failed to create ticket');
|
||||
throw new Error(errorData.detail || errorData.message || 'An unexpected error occurred');
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error creating ticket:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -239,7 +257,6 @@ export const checkTicketStatus = async (ticketNumber: string): Promise<SupportTi
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error checking ticket status:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -268,7 +285,6 @@ export const addTicketMessage = async (
|
||||
if (!response.ok) throw new Error('Failed to add ticket message');
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error adding ticket message:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -284,7 +300,6 @@ export const getKnowledgeBaseCategories = async (): Promise<KnowledgeBaseCategor
|
||||
// Handle paginated response
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching knowledge base categories:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -303,7 +318,6 @@ export const getKnowledgeBaseArticles = async (search?: string): Promise<Knowled
|
||||
// Handle paginated response
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching knowledge base articles:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -319,7 +333,6 @@ export const getFeaturedArticles = async (): Promise<KnowledgeBaseArticle[]> =>
|
||||
// Handle both array and paginated responses
|
||||
return Array.isArray(data) ? data : (data.results || data);
|
||||
} catch (error) {
|
||||
console.error('Error fetching featured articles:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -333,7 +346,6 @@ export const getKnowledgeBaseArticle = async (slug: string): Promise<KnowledgeBa
|
||||
if (!response.ok) throw new Error('Failed to fetch knowledge base article');
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error fetching knowledge base article:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -349,7 +361,6 @@ export const getArticlesByCategory = async (categorySlug: string): Promise<Knowl
|
||||
// Handle paginated response
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching articles by category:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -369,7 +380,6 @@ export const markArticleHelpful = async (slug: string, helpful: boolean): Promis
|
||||
if (!response.ok) throw new Error('Failed to mark article helpful');
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error marking article helpful:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -385,7 +395,6 @@ export const getSupportSettings = async (): Promise<SupportSettings[]> => {
|
||||
// Handle paginated response
|
||||
return data.results || data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching support settings:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -399,7 +408,6 @@ export const getSupportSetting = async (settingName: string): Promise<SupportSet
|
||||
if (!response.ok) throw new Error('Failed to fetch support setting');
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error fetching support setting:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user