fix dates ant TZ, cleanup
This commit is contained in:
@ -15,13 +15,14 @@ import { getServerSession } from "next-auth/next"
|
||||
|
||||
import PublisherSearchBox from '../components/publisher/PublisherSearchBox';
|
||||
import PublisherInlineForm from '../components/publisher/PublisherInlineForm';
|
||||
import CartEventForm from "components/cartevent/CartEventForm";
|
||||
|
||||
|
||||
interface IProps {
|
||||
initialItems: Availability[];
|
||||
initialUserId: string;
|
||||
}
|
||||
export default function IndexPage({ initialItems, initialUserId }: IProps) {
|
||||
export default function IndexPage({ initialItems, initialUserId, cartEvents }: IProps) {
|
||||
const { data: session } = useSession();
|
||||
const [userName, setUserName] = useState(session?.user?.name);
|
||||
const [userId, setUserId] = useState(initialUserId);
|
||||
@ -78,7 +79,7 @@ export default function IndexPage({ initialItems, initialUserId }: IProps) {
|
||||
<div className="text-center font-bold pb-3 xs:pb-1">
|
||||
<PublisherInlineForm publisherId={userId} />
|
||||
</div>
|
||||
<AvCalendar publisherId={userId} events={events} selectedDate={new Date()} />
|
||||
<AvCalendar publisherId={userId} events={events} selectedDate={new Date()} cartEvents={cartEvents} />
|
||||
</div>
|
||||
</div>
|
||||
</ProtectedRoute>
|
||||
@ -223,10 +224,30 @@ export const getServerSideProps = async (context) => {
|
||||
return updatedItem;
|
||||
});
|
||||
|
||||
// log first availability startTime to verify timezone and UTC conversion
|
||||
|
||||
console.log("First availability startTime: " + items[0].startTime);
|
||||
console.log("First availability startTime: " + items[0].startTime.toLocaleString());
|
||||
|
||||
const prisma = common.getPrismaClient();
|
||||
let cartEvents = await prisma.cartEvent.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
startTime: true,
|
||||
endTime: true,
|
||||
dayofweek: true,
|
||||
shiftDuration: true,
|
||||
}
|
||||
});
|
||||
cartEvents = common.convertDatesToISOStrings(cartEvents);
|
||||
return {
|
||||
props: {
|
||||
initialItems: items,
|
||||
userId: session?.user.id,
|
||||
cartEvents: cartEvents,
|
||||
// messages: (await import(`../content/i18n/${context.locale}.json`)).default
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user