implement chat messaging with event proposals
- Add functional chat with server communication and test responses - Add ProposedEventCard component for confirm/reject actions - Move Constants (Day, Month) from client to shared package - Add dateHelpers utility for weekday calculations - Extend Themes.tsx with button and text colors - Update CLAUDE.md with current implementation status - Add *.tsbuildinfo to .gitignore
This commit is contained in:
@@ -1 +1,2 @@
|
||||
export * from './models';
|
||||
export * from './utils';
|
||||
|
||||
39
packages/shared/src/models/Constants.ts
Normal file
39
packages/shared/src/models/Constants.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
export const MONTHS = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
] as const;
|
||||
|
||||
export type Month = (typeof MONTHS)[number];
|
||||
|
||||
export const DAYS = [
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
"Sunday",
|
||||
] as const;
|
||||
|
||||
export type Day = (typeof DAYS)[number];
|
||||
|
||||
// Mapping for Date.getDay() which returns 0=Sunday, 1=Monday, etc.
|
||||
export const DAY_INDEX: Record<Day, number> = {
|
||||
Sunday: 0,
|
||||
Monday: 1,
|
||||
Tuesday: 2,
|
||||
Wednesday: 3,
|
||||
Thursday: 4,
|
||||
Friday: 5,
|
||||
Saturday: 6,
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './User';
|
||||
export * from './CalendarEvent';
|
||||
export * from './ChatMessage';
|
||||
export * from './Constants';
|
||||
|
||||
31
packages/shared/src/utils/dateHelpers.ts
Normal file
31
packages/shared/src/utils/dateHelpers.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Day, DAY_INDEX } from '../models/Constants';
|
||||
|
||||
/**
|
||||
* Get a date for a specific weekday relative to today.
|
||||
* @param day - The target day (e.g., "Friday")
|
||||
* @param offset - 1 = next occurrence, 2 = the one after, -1 = last occurrence, etc.
|
||||
* @param hour - Hour of day (0-23)
|
||||
* @param minute - Minute (0-59)
|
||||
*/
|
||||
export function getDay(day: Day, offset: number, hour: number, minute: number): Date {
|
||||
const today = new Date();
|
||||
const currentDay = today.getDay();
|
||||
const targetDay = DAY_INDEX[day];
|
||||
|
||||
let daysUntil = targetDay - currentDay;
|
||||
|
||||
if (offset > 0) {
|
||||
// Future: if target is today or past, move to next week
|
||||
if (daysUntil <= 0) daysUntil += 7;
|
||||
daysUntil += (offset - 1) * 7;
|
||||
} else if (offset < 0) {
|
||||
// Past: if target is today or future, move to last week
|
||||
if (daysUntil >= 0) daysUntil -= 7;
|
||||
daysUntil += (offset + 1) * 7;
|
||||
}
|
||||
|
||||
const result = new Date(today);
|
||||
result.setDate(today.getDate() + daysUntil);
|
||||
result.setHours(hour, minute, 0, 0);
|
||||
return result;
|
||||
}
|
||||
1
packages/shared/src/utils/index.ts
Normal file
1
packages/shared/src/utils/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dateHelpers';
|
||||
Reference in New Issue
Block a user