Skip to content

Commit

Permalink
calendar 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
haleymartin-6 committed Mar 11, 2024
1 parent bba8e36 commit 50eb658
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 5 deletions.
3 changes: 3 additions & 0 deletions backend/db/migrations/1.user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ VALUES
('8Sy7xBkGiGQv4ZKphcQfY8PxAqw1', 'Narayan', 'Sharma', '[email protected]', '', ''),
('iL7PnjS4axQffmlPceobjUUZ9DF2', 'Caitlin', 'Flynn', '[email protected]', '', ''),
('5JgN2PQxCRM9VoCiiFPlQPNqkL32', 'Linwood', 'Blaisdell', '[email protected]', '', '')
('9rIMSUo6qNf8ToTABkCfNqnByRv1', 'Haley', 'Martin', '[email protected]', '', '')


-- End Care-Wallet Team
;
3 changes: 2 additions & 1 deletion backend/db/migrations/2.group.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
;
6 changes: 6 additions & 0 deletions backend/schema/tasks/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
{
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion client/navigation/AppStackBottomTabNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
8 changes: 5 additions & 3 deletions client/screens/Calendar2.0.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -146,7 +148,7 @@ export default class TimelineCalendarScreen extends Component {
return (
<CalendarProvider
date={currentDate}
onDateChanged={this.onDateChanged}
onDateChanged={onDateChanged}
onMonthChange={this.onMonthChange}
showTodayButton
disabledOpacity={0.6}
Expand Down
148 changes: 148 additions & 0 deletions client/screens/Calendar3.0.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import React, { useState } from 'react';
import { Alert } from 'react-native';
import _ from 'lodash';

Check failure on line 3 in client/screens/Calendar3.0.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Insert `⏎`
import {
CalendarProvider,
CalendarUtils,
DateData,
ExpandableCalendar,
TimelineEventProps,
TimelineList,
TimelineProps,

Check failure on line 11 in client/screens/Calendar3.0.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Delete `,`
} from 'react-native-calendars';

Check failure on line 12 in client/screens/Calendar3.0.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Insert `⏎`
import { getDate, timelineEvents } from './timelineEvents';

Check failure on line 13 in client/screens/Calendar3.0.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Delete `⏎`


const INITIAL_TIME = { hour: 9, minutes: 0 };
const EVENTS: TimelineEventProps[] = timelineEvents;

const TimelineCalendarScreen: React.FC = () => {

Check failure on line 19 in client/screens/Calendar3.0.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Function component is not a function declaration
const [currentDate, setCurrentDate] = useState(getDate());
const [eventsByDate, setEventsByDate] = useState(_.groupBy(EVENTS, (e) => CalendarUtils.getCalendarDateString(e.start)));

Check failure on line 21 in client/screens/Calendar3.0.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Replace `_.groupBy(EVENTS,·(e)·=>·CalendarUtils.getCalendarDateString(e.start))` with `⏎····_.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 },

Check failure on line 28 in client/screens/Calendar3.0.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Delete `,`
};

const onDateChanged = (date: string, source: string) => {
console.log('TimelineCalendarScreen onDateChanged: ', date, source);
setCurrentDate(date);
};

const onMonthChange = (month: DateData, updateSource: any) => {

Check failure on line 36 in client/screens/Calendar3.0.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Unexpected any. Specify a different type
console.log('TimelineCalendarScreen onMonthChange: ', month, updateSource);

Check failure on line 37 in client/screens/Calendar3.0.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Insert `··`
};

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',

Check failure on line 52 in client/screens/Calendar3.0.tsx

View workflow job for this annotation

GitHub Actions / Lint (20.x, 1.21.x)

Delete `,`
};

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<TimelineProps> = {
format24h: false,
onBackgroundLongPress: createNewEvent,
onBackgroundLongPressOut: approveNewEvent,
unavailableHours: [
{ start: 0, end: 6 },
{ start: 22, end: 24 },
],
onEventPress: (e) => expandEvent(e),
overlapEventsSpacing: 8,
rightEdgeSpacing: 24,
};

return (
<CalendarProvider
date={currentDate}
onDateChanged={onDateChanged}
onMonthChange={onMonthChange}
showTodayButton
disabledOpacity={0.6}
>
<ExpandableCalendar firstDay={1} markedDates={marked} />
<TimelineList
events={eventsByDate}
timelineProps={timelineProps}
showNowIndicator
scrollToFirst
initialTime={INITIAL_TIME}
/>
</CalendarProvider>
);
};

function expandEvent(e: TimelineEventProps): void {
console.log('expand event', e.title);
}

export default TimelineCalendarScreen;
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"@types/node": "^20.11.25"
}
}

0 comments on commit 50eb658

Please sign in to comment.