-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
429 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import axiosInstance from "./axiosInstance" | ||
|
||
export type duration = "IMMEDIATELY" | "MIN_15" | "MIN_30" | "MIN_45" | "MIN_60" | ||
|
||
export interface notification { | ||
id?: number | ||
isActive?: boolean | ||
duration?: duration | ||
} | ||
|
||
export const getNotification = async (): Promise<notification | null> => { | ||
try { | ||
const res = await axiosInstance.get(`/pose-notifications`) | ||
|
||
if (!res.data?.data) return null | ||
|
||
const { id, duration } = res.data.data | ||
return { id, duration } | ||
} catch (e) { | ||
throw e | ||
} | ||
} | ||
|
||
export const modifyNotification = async (notification: notification): Promise<notification> => { | ||
try { | ||
const res = await axiosInstance.post(`/pose-notifications`, { ...notification }) | ||
const { id, duration } = res.data.data | ||
return { id, duration } | ||
} catch (e) { | ||
throw e | ||
} | ||
} | ||
|
||
export const patchNotification = async (notification: notification): Promise<notification> => { | ||
try { | ||
const res = await axiosInstance.patch(`/pose-notifications/${notification.id}`, { ...notification }) | ||
const { id, isActive, duration } = res.data.data | ||
return { id, isActive, duration } | ||
} catch (e) { | ||
throw e | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.