Add Support for LabelV2, Add LabelModal and LabelView.

Add React Query
This commit is contained in:
Mo Tarbin 2024-11-23 20:23:59 -05:00
parent 5e590bfe9f
commit 42182371ff
18 changed files with 839 additions and 71 deletions

View file

@ -45,6 +45,13 @@ const GetAllUsers = () => {
headers: HEADERS(),
})
}
const GetChoresNew = async () => {
const resp = await Fetch(`${API_URL}/chores/`, {
method: 'GET',
headers: HEADERS(),
})
return resp.json()
}
const GetChores = () => {
return Fetch(`${API_URL}/chores/`, {
@ -294,16 +301,49 @@ const GetLongLiveTokens = () => {
headers: HEADERS(),
})
}
const CreateLabel = label => {
return Fetch(`${API_URL}/labels`, {
method: 'POST',
headers: HEADERS(),
body: JSON.stringify(label),
})
}
const GetLabels = async () => {
const resp = await Fetch(`${API_URL}/labels`, {
method: 'GET',
headers: HEADERS(),
})
return resp.json()
}
const UpdateLabel = label => {
return Fetch(`${API_URL}/labels`, {
method: 'PUT',
headers: HEADERS(),
body: JSON.stringify(label),
})
}
const DeleteLabel = id => {
return Fetch(`${API_URL}/labels/${id}`, {
method: 'DELETE',
headers: HEADERS(),
})
}
export {
AcceptCircleMemberRequest,
CancelSubscription,
createChore,
CreateChore,
CreateLabel,
CreateLongLiveToken,
CreateThing,
DeleteChore,
DeleteChoreHistory,
DeleteCircleMember,
DeleteLabel,
DeleteLongLiveToken,
DeleteThing,
GetAllCircleMembers,
@ -312,7 +352,9 @@ export {
GetChoreDetailById,
GetChoreHistory,
GetChores,
GetChoresNew,
GetCircleMemberRequests,
GetLabels,
GetLongLiveTokens,
GetSubscriptionSession,
GetThingHistory,
@ -330,6 +372,7 @@ export {
UpdateChoreAssignee,
UpdateChoreHistory,
UpdateChorePriority,
UpdateLabel,
UpdatePassword,
UpdateThingState,
UpdateUserDetails,

38
src/utils/LabelColors.jsx Normal file
View file

@ -0,0 +1,38 @@
const LABEL_COLORS = [
{ name: 'Default', value: '#FFFFFF' },
{ name: 'Salmon', value: '#ff7961' },
{ name: 'Teal', value: '#26a69a' },
{ name: 'Sky Blue', value: '#80d8ff' },
{ name: 'Grape', value: '#7e57c2' },
{ name: 'Sunshine', value: '#ffee58' },
{ name: 'Coral', value: '#ff7043' },
{ name: 'Lavender', value: '#ce93d8' },
{ name: 'Rose', value: '#f48fb1' },
{ name: 'Charcoal', value: '#616161' },
{ name: 'Sienna', value: '#8d6e63' },
{ name: 'Mint', value: '#a7ffeb' },
{ name: 'Amber', value: '#ffc107' },
{ name: 'Cobalt', value: '#3f51b5' },
{ name: 'Emerald', value: '#4caf50' },
{ name: 'Peach', value: '#ffab91' },
{ name: 'Ocean', value: '#0288d1' },
{ name: 'Mustard', value: '#ffca28' },
{ name: 'Ruby', value: '#d32f2f' },
{ name: 'Periwinkle', value: '#b39ddb' },
{ name: 'Turquoise', value: '#00bcd4' },
{ name: 'Lime', value: '#cddc39' },
{ name: 'Blush', value: '#f8bbd0' },
{ name: 'Ash', value: '#90a4ae' },
{ name: 'Sand', value: '#d7ccc8' },
]
export default LABEL_COLORS
export const getTextColorFromBackgroundColor = bgColor => {
if (!bgColor) return ''
const hex = bgColor.replace('#', '')
const r = parseInt(hex.substring(0, 2), 16)
const g = parseInt(hex.substring(2, 4), 16)
const b = parseInt(hex.substring(4, 6), 16)
return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? '#000000' : '#ffffff'
}