feat: Add organization logo support
- Add Organization interface to auth store - Fetch org info including logo_url on login - Update sidebar to show org logo or name - Add logo upload in Settings (chef only) - Support FormData uploads in API client
This commit is contained in:
@@ -19,11 +19,10 @@ class ApiClient {
|
||||
private async request<T>(
|
||||
method: string,
|
||||
endpoint: string,
|
||||
data?: unknown
|
||||
data?: unknown,
|
||||
options?: { headers?: Record<string, string> }
|
||||
): Promise<ApiResponse<T>> {
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
const headers: Record<string, string> = {}
|
||||
|
||||
const token = this.getToken()
|
||||
if (token) {
|
||||
@@ -35,8 +34,24 @@ class ApiClient {
|
||||
headers,
|
||||
}
|
||||
|
||||
if (data) {
|
||||
// Handle FormData (multipart/form-data) vs JSON
|
||||
if (data instanceof FormData) {
|
||||
config.body = data
|
||||
// Don't set Content-Type for FormData - browser will set it with boundary
|
||||
} else if (data) {
|
||||
headers['Content-Type'] = 'application/json'
|
||||
config.body = JSON.stringify(data)
|
||||
} else {
|
||||
headers['Content-Type'] = 'application/json'
|
||||
}
|
||||
|
||||
// Merge custom headers
|
||||
if (options?.headers) {
|
||||
Object.assign(headers, options.headers)
|
||||
// Remove Content-Type if it's multipart (let browser handle it)
|
||||
if (options.headers['Content-Type']?.includes('multipart')) {
|
||||
delete headers['Content-Type']
|
||||
}
|
||||
}
|
||||
|
||||
const response = await fetch(`${this.baseUrl}${endpoint}`, config)
|
||||
@@ -90,8 +105,8 @@ class ApiClient {
|
||||
return this.request<T>('GET', endpoint)
|
||||
}
|
||||
|
||||
post<T>(endpoint: string, data?: unknown): Promise<ApiResponse<T>> {
|
||||
return this.request<T>('POST', endpoint, data)
|
||||
post<T>(endpoint: string, data?: unknown, options?: { headers?: Record<string, string> }): Promise<ApiResponse<T>> {
|
||||
return this.request<T>('POST', endpoint, data, options)
|
||||
}
|
||||
|
||||
put<T>(endpoint: string, data?: unknown): Promise<ApiResponse<T>> {
|
||||
|
||||
Reference in New Issue
Block a user