From 50eb6582b17fb97fa5d390b9ae578302b5b9f0e5 Mon Sep 17 00:00:00 2001 From: haleymartin-6 <119809061+haleymartin-6@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:43:04 -0400 Subject: [PATCH] calendar 3.0 --- backend/db/migrations/1.user.sql | 3 + backend/db/migrations/2.group.sql | 3 +- backend/schema/tasks/routes.go | 6 + .../navigation/AppStackBottomTabNavigator.tsx | 2 +- client/screens/Calendar2.0.tsx | 8 +- client/screens/Calendar3.0.tsx | 148 ++++++++++++++++++ package.json | 5 + 7 files changed, 170 insertions(+), 5 deletions(-) create mode 100644 client/screens/Calendar3.0.tsx create mode 100644 package.json diff --git a/backend/db/migrations/1.user.sql b/backend/db/migrations/1.user.sql index 51cab11..9edd848 100644 --- a/backend/db/migrations/1.user.sql +++ b/backend/db/migrations/1.user.sql @@ -29,5 +29,8 @@ VALUES ('8Sy7xBkGiGQv4ZKphcQfY8PxAqw1', 'Narayan', 'Sharma', 'sharma.na@northeastern.edu', '', ''), ('iL7PnjS4axQffmlPceobjUUZ9DF2', 'Caitlin', 'Flynn', 'flynn.ca@northeastern.edu', '', ''), ('5JgN2PQxCRM9VoCiiFPlQPNqkL32', 'Linwood', 'Blaisdell', 'blaisdell.l@northeastern.edu', '', '') + ('9rIMSUo6qNf8ToTABkCfNqnByRv1', 'Haley', 'Martin', 'martin.hal@northeastern.edu', '', '') + + -- End Care-Wallet Team ; diff --git a/backend/db/migrations/2.group.sql b/backend/db/migrations/2.group.sql index a85d363..62763c3 100644 --- a/backend/db/migrations/2.group.sql +++ b/backend/db/migrations/2.group.sql @@ -49,6 +49,7 @@ VALUES (5, 'mPeo3d3MiXfnpPJADWgFD9ZcB2M2', 'SECONDARY'), (5, 'onrQs8HVGBVMPNz4Fk1uE94bSxg1', 'SECONDARY'), (5, '8Sy7xBkGiGQv4ZKphcQfY8PxAqw1', 'SECONDARY'), - (5, 'iL7PnjS4axQffmlPceobjUUZ9DF2', 'SECONDARY') + (5, 'iL7PnjS4axQffmlPceobjUUZ9DF2', 'SECONDARY'), + (5, '9rIMSUo6qNf8ToTABkCfNqnByRv1', 'SECONDARY') -- End Care-Wallet Team ; diff --git a/backend/schema/tasks/routes.go b/backend/schema/tasks/routes.go index 9452a46..05ca19a 100644 --- a/backend/schema/tasks/routes.go +++ b/backend/schema/tasks/routes.go @@ -23,6 +23,7 @@ func TaskGroup(v1 *gin.RouterGroup, c *PgModel) *gin.RouterGroup { tasks.GET("/filtered", c.GetFilteredTasks) tasks.GET("/assigned", c.GetTasksByAssignedUsers) tasks.POST("", c.CreateTask) +<<<<<<< Updated upstream byId := tasks.Group("/:tid") { @@ -33,6 +34,11 @@ func TaskGroup(v1 *gin.RouterGroup, c *PgModel) *gin.RouterGroup { byId.POST("/assign", c.AssignUsersToTask) byId.DELETE("/remove", c.RemoveUsersFromTask) } +======= + tasks.DELETE("/:tid", c.DeleteTask) + tasks.PUT("/:tid/info", c.UpdateTaskInfo) + tasks.GET("/:tid/assigned-users", c.GetUsersAssignedToTask) +>>>>>>> Stashed changes } return tasks } diff --git a/client/navigation/AppStackBottomTabNavigator.tsx b/client/navigation/AppStackBottomTabNavigator.tsx index f30f3a8..6efcbbe 100644 --- a/client/navigation/AppStackBottomTabNavigator.tsx +++ b/client/navigation/AppStackBottomTabNavigator.tsx @@ -7,7 +7,7 @@ import Bell from '../assets/bottom-nav/bell.svg'; import Calendar from '../assets/bottom-nav/calendar.svg'; import Home from '../assets/bottom-nav/home.svg'; import User from '../assets/bottom-nav/user.svg'; -import TimelineCalendarScreen from '../screens/Calendar2.0'; +import TimelineCalendarScreen from '../screens/Calendar3.0'; import MedicationList from '../screens/MedicationList'; import Profile from '../screens/Profile'; diff --git a/client/screens/Calendar2.0.tsx b/client/screens/Calendar2.0.tsx index 05c94e9..287b774 100644 --- a/client/screens/Calendar2.0.tsx +++ b/client/screens/Calendar2.0.tsx @@ -19,7 +19,7 @@ import { getDate, timelineEvents } from './timelineEvents'; const INITIAL_TIME = { hour: 9, minutes: 0 }; const EVENTS: TimelineEventProps[] = timelineEvents; -export default class TimelineCalendarScreen extends Component { +export default function TimelineCalendarScreen { state = { currentDate: getDate(), events: EVENTS, @@ -36,7 +36,9 @@ export default class TimelineCalendarScreen extends Component { [`${getDate(1)}`]: { marked: true }, [`${getDate(2)}`]: { marked: true }, [`${getDate(4)}`]: { marked: true } - }; + }; // what dates have event under them and which ones do not + // could be a useeffect... extract date from a task and filter which ones have tasks... + onDateChanged = (date: string, source: string) => { console.log('TimelineCalendarScreen onDateChanged: ', date, source); @@ -146,7 +148,7 @@ export default class TimelineCalendarScreen extends Component { return ( { + const [currentDate, setCurrentDate] = useState(getDate()); + const [eventsByDate, setEventsByDate] = useState(_.groupBy(EVENTS, (e) => CalendarUtils.getCalendarDateString(e.start))); + + const marked = { + [`${getDate(-1)}`]: { marked: true }, + [`${getDate()}`]: { marked: true }, + [`${getDate(1)}`]: { marked: true }, + [`${getDate(2)}`]: { marked: true }, + [`${getDate(4)}`]: { marked: true }, + }; + + const onDateChanged = (date: string, source: string) => { + console.log('TimelineCalendarScreen onDateChanged: ', date, source); + setCurrentDate(date); + }; + + const onMonthChange = (month: DateData, updateSource: any) => { + console.log('TimelineCalendarScreen onMonthChange: ', month, updateSource); + }; + + const createNewEvent: TimelineProps['onBackgroundLongPress'] = ( + timeString, + timeObject + ) => { + const hourString = `${(timeObject.hour + 1).toString().padStart(2, '0')}`; + const minutesString = `${timeObject.minutes.toString().padStart(2, '0')}`; + + const newEvent = { + id: 'draft', + start: `${timeString}`, + end: `${timeObject.date} ${hourString}:${minutesString}:00`, + title: 'New Event', + color: 'white', + }; + + if (timeObject.date) { + if (eventsByDate[timeObject.date]) { + setEventsByDate((prevEvents) => ({ + ...prevEvents, + [timeObject.date as string]: [...prevEvents[timeObject.date as string], newEvent], + })); + } else { + setEventsByDate((prevEvents) => ({ + ...prevEvents, + [timeObject.date as string]: [newEvent], + })); + } + } + }; + + const approveNewEvent: TimelineProps['onBackgroundLongPressOut'] = ( + _timeString, + timeObject + ) => { + Alert.prompt('New Event', 'Enter event title', [ + { + text: 'Cancel', + onPress: () => { + if (timeObject.date) { + setEventsByDate((prevEvents) => ({ + ...prevEvents, + [timeObject.date as string]: _.filter( + prevEvents[timeObject.date as string], + (e) => e.id !== 'draft' + ), + })); + } + }, + }, + { + text: 'Create', + onPress: (eventTitle) => { + if (timeObject.date) { + const draftEvent = _.find(eventsByDate[timeObject.date], { + id: 'draft', + }); + if (draftEvent) { + draftEvent.id = undefined; + draftEvent.title = eventTitle ?? 'New Event'; + draftEvent.color = 'lightgreen'; + setEventsByDate((prevEvents) => ({ + ...prevEvents, + [timeObject.date as string]: [...prevEvents[timeObject.date as string]], + })); + } + } + }, + }, + ]); + }; + + const timelineProps: Partial = { + format24h: false, + onBackgroundLongPress: createNewEvent, + onBackgroundLongPressOut: approveNewEvent, + unavailableHours: [ + { start: 0, end: 6 }, + { start: 22, end: 24 }, + ], + onEventPress: (e) => expandEvent(e), + overlapEventsSpacing: 8, + rightEdgeSpacing: 24, + }; + + return ( + + + + + ); +}; + +function expandEvent(e: TimelineEventProps): void { + console.log('expand event', e.title); +} + +export default TimelineCalendarScreen; diff --git a/package.json b/package.json new file mode 100644 index 0000000..087d38e --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "@types/node": "^20.11.25" + } +}