- Added CalendarDayDetail component for displaying detailed event information for a selected day. - Created CalendarEventPill component to represent individual events in a compact format. - Introduced CalendarFilters component to filter events by project, stage type, and status. - Developed CalendarGrid component to render the calendar layout and manage event interactions. - Implemented CalendarView component to manage the overall calendar state and navigation. - Added useCalendar hook to fetch calendar events based on specified filters. - Created calendar-service to handle fetching events from the database with filtering capabilities. - Updated data model to include necessary fields for calendar events and filters. - Added system prompt and tools for AI assistant to manage calendar-related tasks.
61 lines
No EOL
1.7 KiB
TypeScript
61 lines
No EOL
1.7 KiB
TypeScript
import "dotenv/config";
|
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
import { PrismaClient } from "../src/generated/prisma/client";
|
|
import { addDays } from "date-fns";
|
|
|
|
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL! });
|
|
const prisma = new PrismaClient({ adapter });
|
|
|
|
async function main() {
|
|
console.log("Seeding stage dates for calendar view (Catalog Images specifically)...");
|
|
|
|
// Get only Catalog Images stages
|
|
const stages = await prisma.deliverableStage.findMany({
|
|
where: {
|
|
template: {
|
|
name: "Catalog Images"
|
|
}
|
|
},
|
|
take: 50,
|
|
});
|
|
|
|
if (stages.length === 0) {
|
|
console.log("No Catalog Images stages found to update.");
|
|
return;
|
|
}
|
|
|
|
const today = new Date();
|
|
|
|
for (let i = 0; i < stages.length; i++) {
|
|
const stage = stages[i];
|
|
|
|
// Spread start dates from 14 days ago to 14 days in the future
|
|
const startOffset = Math.floor(Math.random() * 28) - 14;
|
|
const startDate = addDays(today, startOffset);
|
|
|
|
// Duration approx 8 weeks (56 days), plus some random variance
|
|
const durationDays = 56 + Math.floor(Math.random() * 10) - 5;
|
|
const dueDate = addDays(startDate, durationDays);
|
|
|
|
await prisma.deliverableStage.update({
|
|
where: { id: stage.id },
|
|
data: {
|
|
startDate,
|
|
dueDate,
|
|
}
|
|
});
|
|
|
|
console.log(`Updated Catalog Images stage ${stage.id}: Start: ${startDate.toISOString().split('T')[0]}, Due: ${dueDate.toISOString().split('T')[0]}`);
|
|
}
|
|
|
|
console.log(`Successfully updated ${stages.length} Catalog Images stages with dates.`);
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
}); |