Initial Activity View

Add New Colors.jsx
Allow Dark model Toggle from the Navbar
This commit is contained in:
Mo Tarbin 2024-12-28 18:52:06 -05:00
parent 4fc836a34b
commit d4c36e2057
17 changed files with 1326 additions and 310 deletions

160
src/utils/Chores.jsx Normal file
View file

@ -0,0 +1,160 @@
import { TASK_COLOR } from './Colors.jsx'
export const ChoresGrouper = (groupBy, chores) => {
// sort by priority then due date:
chores.sort((a, b) => {
// no priority is lowest priority:
if (a.priority === 0) {
return 1
}
if (a.priority !== b.priority) {
return a.priority - b.priority
}
if (a.nextDueDate === null) {
return 1
}
if (b.nextDueDate === null) {
return -1
}
return new Date(a.nextDueDate) - new Date(b.nextDueDate)
})
var groups = []
switch (groupBy) {
case 'due_date':
var groupRaw = {
Today: [],
'In a week': [],
'This month': [],
Later: [],
Overdue: [],
Anytime: [],
}
chores.forEach(chore => {
if (chore.nextDueDate === null) {
groupRaw['Anytime'].push(chore)
} else if (new Date(chore.nextDueDate) < new Date()) {
groupRaw['Overdue'].push(chore)
} else if (
new Date(chore.nextDueDate).toDateString() ===
new Date().toDateString()
) {
groupRaw['Today'].push(chore)
} else if (
new Date(chore.nextDueDate) <
new Date(Date.now() + 7 * 24 * 60 * 60 * 1000) &&
new Date(chore.nextDueDate) > new Date()
) {
groupRaw['In a week'].push(chore)
} else if (
new Date(chore.nextDueDate).getMonth() === new Date().getMonth()
) {
groupRaw['This month'].push(chore)
} else {
groupRaw['Later'].push(chore)
}
})
groups = [
{
name: 'Overdue',
content: groupRaw['Overdue'],
color: TASK_COLOR.OVERDUE,
},
{ name: 'Today', content: groupRaw['Today'], color: TASK_COLOR.TODAY },
{
name: 'In a week',
content: groupRaw['In a week'],
color: TASK_COLOR.IN_A_WEEK,
},
{
name: 'This month',
content: groupRaw['This month'],
color: TASK_COLOR.THIS_MONTH,
},
{ name: 'Later', content: groupRaw['Later'], color: TASK_COLOR.LATER },
{
name: 'Anytime',
content: groupRaw['Anytime'],
color: TASK_COLOR.ANYTIME,
},
]
break
case 'priority':
groupRaw = {
p1: [],
p2: [],
p3: [],
p4: [],
no_priority: [],
}
chores.forEach(chore => {
switch (chore.priority) {
case 1:
groupRaw['p1'].push(chore)
break
case 2:
groupRaw['p2'].push(chore)
break
case 3:
groupRaw['p3'].push(chore)
break
case 4:
groupRaw['p4'].push(chore)
break
default:
groupRaw['no_priority'].push(chore)
break
}
})
groups = [
{
name: 'Priority 1',
content: groupRaw['p1'],
color: TASK_COLOR.PRIORITY_1,
},
{
name: 'Priority 2',
content: groupRaw['p2'],
color: TASK_COLOR.PRIORITY_2,
},
{
name: 'Priority 3',
content: groupRaw['p3'],
color: TASK_COLOR.PRIORITY_3,
},
{
name: 'Priority 4',
content: groupRaw['p4'],
color: TASK_COLOR.PRIORITY_4,
},
{
name: 'No Priority',
content: groupRaw['no_priority'],
color: TASK_COLOR.NO_PRIORITY,
},
]
break
case 'labels':
groupRaw = {}
var labels = {}
chores.forEach(chore => {
chore.labelsV2.forEach(label => {
labels[label.id] = label
if (groupRaw[label.id] === undefined) {
groupRaw[label.id] = []
}
groupRaw[label.id].push(chore)
})
})
groups = Object.keys(groupRaw).map(key => {
return {
name: labels[key].name,
content: groupRaw[key],
}
})
groups.sort((a, b) => {
a.name < b.name ? 1 : -1
})
}
return groups
}

View file

@ -26,6 +26,60 @@ const LABEL_COLORS = [
{ name: 'Sand', value: '#d7ccc8' },
]
export const COLORS = {
white: '#FFFFFF',
salmon: '#ff7961',
teal: '#26a69a',
skyBlue: '#80d8ff',
grape: '#7e57c2',
sunshine: '#ffee58',
coral: '#ff7043',
lavender: '#ce93d8',
rose: '#f48fb1',
charcoal: '#616161',
sienna: '#8d6e63',
mint: '#a7ffeb',
amber: '#ffc107',
cobalt: '#3f51b5',
emerald: '#4caf50',
peach: '#ffab91',
ocean: '#0288d1',
mustard: '#ffca28',
ruby: '#d32f2f',
periwinkle: '#b39ddb',
turquoise: '#00bcd4',
lime: '#cddc39',
blush: '#f8bbd0',
ash: '#90a4ae',
sand: '#d7ccc8',
}
export const TASK_COLOR = {
COMPLETED: '#4ec1a2',
LATE: '#f6ad55',
MISSED: '#F03A47',
UPCOMING: '#AF5B5B',
SKIPPED: '#E2C2FF',
// For the calendar
OVERDUE: '#F03A47',
TODAY: '#ffc107',
IN_A_WEEK: '#4ec1a2',
THIS_MONTH: '#00bcd4',
LATER: '#d7ccc8',
ANYTIME: '#90a4ae',
// FOR ASSIGNEE:
ASSIGNED_TO_ME: '#4ec1a2',
ASSIGNED_TO_OTHER: '#b39ddb',
// FOR PRIORITY:
PRIORITY_1: '#F03A47',
PRIORITY_2: '#ffc107',
PRIORITY_3: '#00bcd4',
PRIORITY_4: '#7e57c2',
NO_PRIORITY: '#90a4ae',
}
export default LABEL_COLORS
export const getTextColorFromBackgroundColor = bgColor => {

View file

@ -1,9 +1,5 @@
import { API_URL } from '../Config'
import { Fetch, HEADERS, apiManager } from './TokenManager'
const createChore = userID => {
return Fetch(`/chores/`, {
method: 'POST',
@ -33,7 +29,7 @@ const UpdatePassword = newPassword => {
}
const login = (username, password) => {
const baseURL = apiManager.getApiURL();
const baseURL = apiManager.getApiURL()
return fetch(`${baseURL}/auth/login`, {
headers: {
'Content-Type': 'application/json',
@ -49,8 +45,13 @@ const GetAllUsers = () => {
headers: HEADERS(),
})
}
const GetChoresNew = async () => {
const resp = await Fetch(`/chores/`, {
const GetChoresNew = async includeArchived => {
var url = `/chores/`
if (includeArchived) {
url += `?includeArchived=true`
}
const resp = await Fetch(url, {
method: 'GET',
headers: HEADERS(),
})
@ -95,7 +96,7 @@ const GetChoreDetailById = id => {
})
}
const MarkChoreComplete = (id, note, completedDate, performer) => {
var markChoreURL =`/chores/${id}/do`
var markChoreURL = `/chores/${id}/do`
const body = {
note,
@ -109,15 +110,13 @@ const MarkChoreComplete = (id, note, completedDate, performer) => {
}
if (performer) {
body.performer = Number(performer)
if(completedDateFormated === ''){
markChoreURL += `&performer=${performer}`
}
else{
if (completedDateFormated === '') {
markChoreURL += `&performer=${performer}`
} else {
markChoreURL += `?performer=${performer}`
}
}
return Fetch(markChoreURL, {
method: 'POST',
headers: HEADERS(),
@ -244,13 +243,10 @@ const LeaveCircle = id => {
}
const DeleteCircleMember = (circleID, memberID) => {
return Fetch(
`/circles/${circleID}/members/delete?member_id=${memberID}`,
{
method: 'DELETE',
headers: HEADERS(),
},
)
return Fetch(`/circles/${circleID}/members/delete?member_id=${memberID}`, {
method: 'DELETE',
headers: HEADERS(),
})
}
const UpdateUserDetails = userDetails => {
@ -345,13 +341,12 @@ const GetLongLiveTokens = () => {
headers: HEADERS(),
})
}
const PutNotificationTarget = ( platform, deviceToken) => {
const PutNotificationTarget = (platform, deviceToken) => {
return Fetch(`/users/targets`, {
method: 'PUT',
headers: HEADERS(),
body: JSON.stringify({ platform,deviceToken }),
}
)
body: JSON.stringify({ platform, deviceToken }),
})
}
const CreateLabel = label => {
return Fetch(`/labels`, {
@ -383,22 +378,19 @@ const DeleteLabel = id => {
})
}
const ChangePassword = (verifiticationCode, password) => {
const baseURL = apiManager.getApiURL();
return fetch(
`${baseURL}/auth/password?c=${verifiticationCode}`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ password: password }),
const ChangePassword = (verifiticationCode, password) => {
const baseURL = apiManager.getApiURL()
return fetch(`${baseURL}/auth/password?c=${verifiticationCode}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
)
body: JSON.stringify({ password: password }),
})
}
const ResetPassword = email => {
const basedURL = apiManager.getApiURL();
const basedURL = apiManager.getApiURL()
return fetch(`${basedURL}/auth/reset`, {
method: 'POST',
headers: {
@ -422,24 +414,34 @@ const UpdateDueDate = (id, dueDate) => {
}
const RefreshToken = () => {
const basedURL = apiManager.getApiURL();
const basedURL = apiManager.getApiURL()
return fetch(basedURL + '/auth/refresh', {
method: 'GET',
headers: HEADERS(),
})
}
const GetChoresHistory = async limit => {
var url = `/chores/history`
if (limit) {
url += `?limit=${limit}`
}
const resp = await Fetch(url, {
method: 'GET',
headers: HEADERS(),
})
return resp.json()
}
export {
AcceptCircleMemberRequest,
ArchiveChore,
CancelSubscription,
createChore,
ChangePassword,
CreateChore,
CreateLabel,
CreateLongLiveToken,
CreateThing,
DeleteChore,
DeleteChoreHistory,
ChangePassword,
DeleteCircleMember,
DeleteLabel,
DeleteLongLiveToken,
@ -451,6 +453,7 @@ export {
GetChoreDetailById,
GetChoreHistory,
GetChores,
GetChoresHistory,
GetChoresNew,
GetCircleMemberRequests,
GetLabels,
@ -462,14 +465,12 @@ export {
GetUserProfile,
JoinCircle,
LeaveCircle,
login,
MarkChoreComplete,
RefreshToken,
ResetPassword,
PutNotificationTarget,
RefreshToken,
ResetPassword,
SaveChore,
SaveThing,
signUp,
SkipChore,
UnArchiveChore,
UpdateChoreAssignee,
@ -481,4 +482,7 @@ export {
UpdatePassword,
UpdateThingState,
UpdateUserDetails,
createChore,
login,
signUp,
}