feat: add notification API client functions
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
import { apiClient } from '@/shared/api/client'
|
||||||
|
|
||||||
|
export interface UserNotificationSettings {
|
||||||
|
id: string
|
||||||
|
userId: string
|
||||||
|
globalEnabled: boolean
|
||||||
|
orderCreated: boolean
|
||||||
|
orderStatusChanged: boolean
|
||||||
|
orderMessageReceived: boolean
|
||||||
|
paymentStatusChanged: boolean
|
||||||
|
createdAt: string
|
||||||
|
updatedAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminNotificationSettings {
|
||||||
|
id: string
|
||||||
|
emailEnabled: boolean
|
||||||
|
telegramEnabled: boolean
|
||||||
|
telegramChatId: string | null
|
||||||
|
newOrder: boolean
|
||||||
|
newOrderMessage: boolean
|
||||||
|
newReview: boolean
|
||||||
|
authCodeDuplicate: boolean
|
||||||
|
createdAt: string
|
||||||
|
updatedAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchUserNotificationSettings(): Promise<{ settings: UserNotificationSettings }> {
|
||||||
|
const { data } = await apiClient.get<{ settings: UserNotificationSettings }>('me/notifications/settings')
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateUserNotificationSettings(
|
||||||
|
settings: Partial<UserNotificationSettings>,
|
||||||
|
): Promise<{ settings: UserNotificationSettings }> {
|
||||||
|
const { data } = await apiClient.put<{ settings: UserNotificationSettings }>('me/notifications/settings', settings)
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchAdminNotificationSettings(): Promise<{ settings: AdminNotificationSettings }> {
|
||||||
|
const { data } = await apiClient.get<{ settings: AdminNotificationSettings }>('admin/notifications/settings')
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateAdminNotificationSettings(
|
||||||
|
settings: Partial<AdminNotificationSettings>,
|
||||||
|
): Promise<{ settings: AdminNotificationSettings }> {
|
||||||
|
const { data } = await apiClient.put<{ settings: AdminNotificationSettings }>('admin/notifications/settings', settings)
|
||||||
|
return data
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user