Skip to content

Commit

Permalink
Merge pull request #364 from datasektionen/main
Browse files Browse the repository at this point in the history
Pray this don´t burn down
  • Loading branch information
viktorrn authored Sep 19, 2024
2 parents 77feb4e + fd1efd6 commit 7ddd8a5
Show file tree
Hide file tree
Showing 19 changed files with 671 additions and 72 deletions.
2 changes: 2 additions & 0 deletions prisma/migrations/20240912093624_timeslots/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "exhibitors" ADD COLUMN "meetingTimeSlots" INTEGER[] DEFAULT ARRAY[]::INTEGER[];
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ model Exhibitor {
customBanquetTicketsWanted Int @default(0)
mapPosition Int @default(0)
meetingTimeSlots Int[] @default([])
foodPreferencess FoodPreferences[]
users User[]
Expand Down
32 changes: 22 additions & 10 deletions src/components/Company/ExtraOrders/CompanyMeetingBooker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ export default function CompanyMeetingBooker(
const getAcceptedStudents = api.exhibitor.getAcceptedMeetings.useQuery();
const getStudentCv = api.exhibitor.getStudentCV.useMutation();
const deleteMeeting = api.exhibitor.cancelMeeting.useMutation();
const getTimeSlotsLeft = api.exhibitor.getTimeSlotsLeft.useQuery();

const createMeeting = api.exhibitor.createMeeting.useMutation();

const [students, setStudents] = useState<MeetingData[]>([]);
const [tableIndex, setTableIndex] = useState(0);
const [currentCancelMeeting, setCurrentCancelMeeting] = useState<string | null>(null);
const [hasMeetingsLeft, setHasMeetingsLeft] = useState(true);

const [pendingStudents, setPendingStudents] = useState<MeetingData[]>([]);
const [acceptedStudents, setAcceptedStudents] = useState<MeetingData[]>([]);
Expand Down Expand Up @@ -132,6 +134,11 @@ export default function CompanyMeetingBooker(
setAcceptedStudents(students);
}, [getAcceptedStudents.data]);

useEffect(() => {
if(!getTimeSlotsLeft.data) return;
setHasMeetingsLeft(getTimeSlotsLeft.data.length > 0);
}, [getTimeSlotsLeft.data]);

const handleCheck = (id: string) => {
const updatedData = [...students];
const idx = updatedData.findIndex((d) => d.ugkthid === id);
Expand Down Expand Up @@ -284,16 +291,21 @@ export default function CompanyMeetingBooker(
</tbody>
</table>
</div>
<p className='text-white mt-2'>

{hasMeetingsLeft ? <>
<p className='text-white mt-2'>
{"("+ students.filter((student)=> student.checked).length.toString() + ") " + t.exhibitorSettings.meetings.selectedStudents}
</p>
<button className="mt-4 mb-4" onClick={bookMeetings}>
<a className={`block transition-transform rounded-full
text-white text-base font-medium px-6 py-2 max-lg:mx-auto w-max `
+ (students.filter((student)=> student.checked).length > 0 ? 'bg-cerise hover:scale-105' : 'bg-gray/50')}>
{t.exhibitorSettings.meetings.bookSelected}
</a>
</button>
</p>
<button className="mt-4 mb-4" onClick={bookMeetings}>
<a className={`block transition-transform rounded-full
text-white text-base font-medium px-6 py-2 max-lg:mx-auto w-max `
+ (students.filter((student)=> student.checked).length > 0 ? 'bg-cerise hover:scale-105' : 'bg-gray/50')}>
{t.exhibitorSettings.meetings.bookSelected}
</a>
</button>
</> : <>
<p className='text-white mt-2 text-lg font-weight'>{t.exhibitorSettings.meetings.noTimesLeft}!</p>
</> }
</>,
<> {/*Pending students*/}
<p className='text-white mb-2'> { "("+ pendingStudents.length + ") " + t.exhibitorSettings.meetings.pendingMeetings }</p>
Expand Down Expand Up @@ -338,7 +350,7 @@ export default function CompanyMeetingBooker(
</div>
</>,
<> {/*Accepted students*/}
<p className='text-white mb-2'> {"(" + acceptedStudents.length + ") " + t.exhibitorSettings.meetings.bookedMeetings} </p>
<p className='text-white mb-2'> {"(" + acceptedStudents.length + "/6) " + t.exhibitorSettings.meetings.bookedMeetings} </p>
<div className='overflow-y-auto h-90 p-8 bg-black/50 rounded-lg'>
<table className='w-full '>
<thead>
Expand Down
7 changes: 5 additions & 2 deletions src/components/Map/ExhibitorExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,13 @@ export default function ExhibitorExplorer({
}, [selectedExhibitor]);

return (
<div className="h-full w-full mt-0 mb-5 md:mb-0 flex flex-col gap-y-4 items-center justify-center">
<div
id={"explorer"}
className="h-full w-full mt-0 md:mb-0 flex flex-col gap-y-4 items-center justify-center"
>
<div
ref={buttonScrollRef}
className="h-full w-full border-4 border-pink-600
className="min-h-full w-full border-4 border-pink-600
bg-[#eaeaea] bg-opacity-10 rounded-xl pb-4 overflow-scroll
scrollbar-hide overflow-x-hidden mb-3"
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Map/NewMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "leaflet/dist/leaflet.css";
const exhibitorMarker = (id: string, selected: boolean): DivIcon =>
new DivIcon({
html: id,
className: `rounded-full bg-pink-600 ring ${selected ? "border-4 border-pink-500 ring-2 ring-yellow" : "ring-2 ring-pink-500"} text-white text-center content-center`,
className: `rounded-full bg-pink-600 ring ${selected ? "border-4 border-pink-500 ring-3 ring-yellow" : "ring-2 ring-pink-500"} text-white text-center content-center`,
iconSize: selected ? [38, 38] : [30, 30]
});

Expand Down
33 changes: 28 additions & 5 deletions src/components/Map/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Dispatch, useState, useEffect, useRef } from "react";
import type Locale from "@/locales";
import { Dispatch, useState } from "react";
import { CheckMark } from "../CheckMark";
import Button from "./Button";

Expand Down Expand Up @@ -72,6 +72,8 @@ export default function Search({
const [searchQuery, setSearchQuery] = useState("");
const [showFilter, setShowFilter] = useState(false);
const [checkmarks, setCheckmarks] = useState(Array<boolean>(11).fill(false));
const filterRef = useRef<HTMLDivElement>(null);
const searchBarRef = useRef<HTMLDivElement>(null);

const setSearchQueryAndApply = (value: string) => {
setSearchQuery(value);
Expand All @@ -87,9 +89,30 @@ export default function Search({
});
};

useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
filterRef.current &&
!filterRef.current.contains(event.target as Node) &&
searchBarRef.current &&
!searchBarRef.current.contains(event.target as Node)
) {
setShowFilter(false);
}
};

document.addEventListener("mousedown", handleClickOutside);
return () => {
document.removeEventListener("mousedown", handleClickOutside);
};
}, [filterRef, searchBarRef]);

return (
<div className="w-full flex flex-col items-center justify-center">
<div className="w-full flex items-center my-4">
<div
id={"search"}
className="w-full flex flex-col items-center justify-center"
>
<div ref={searchBarRef} className="w-full flex items-center my-4">
<input
className="grow min-h-[40px] outline-none border-2 border-cerise bg-[#eaeaea] bg-opacity-10
rounded-3xl px-3 text-white text-opacity-50 focus:placeholder:text-transparent"
Expand All @@ -104,12 +127,12 @@ export default function Search({
loading={false}
onClick={() => setShowFilter(!showFilter)}
/>

</div>
</div>
<div className="flex justify-center w-full relative">
{showFilter && (
<div
ref={filterRef}
className="absolute top-full z-10 mt-5 w-11/12 block border-4 border-pink-600 bg-[#867c8b] bg-opacity-60 backdrop-blur-sm rounded-lg text-white justify-center text-xl"
>
<div className="w-full h-full flex flex-col justify-center items-center p-2 max-xs:p-6 font-light text-base">
Expand Down Expand Up @@ -153,4 +176,4 @@ export default function Search({
</div>
</div>
);
}
}
122 changes: 121 additions & 1 deletion src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export default {
bookedMeetings: "booked meetings",
bookSelected: "Send meeting request",
caution: "Student meetings are not available on phones",
noTimesLeft: "No times left",
pages: {
interested: "Interested students",
pending: "Pending requests",
Expand Down Expand Up @@ -434,7 +435,7 @@ export default {
<p>Hi!</p>
<p>We are pleased to confirm we have received your exhibitor registration.
We will contact you during the spring about whether you got a spot at D-Dagen.
You can expect to hear from us by June 8th at the latest.</p>
You can expect to hear from us by June 8th at the latest.</p>
<p>Here are the details of your registration:</p>
<ul>
Expand All @@ -452,6 +453,125 @@ export default {
<p>The D-Dagen project group</p>
`,
},
meeting_email: {
meeting_request_to_student: {
subject: (
companyName: string
) => `Meeting Request from ${companyName}`,
body: (
firstName: string,
lastName: string,
companyName: string
)=>`
<p>Hi ${firstName} ${lastName}!</p>
<p>We are pleased to confirm that ${companyName} wants a meeting with you</p>
<p>If any of the information above is incorrect or if you have any other questions,
do not hesitate to contact our sales team at [email protected].</p>
<p>Best regards,</p>
<p>The D-Dagen project group</p>
`,
},
meeting_declined_by_student: {
subject: (
firstName: string,
lastName: string
)=>
`Meeting Declined by ${firstName} ${lastName}`,
body: (
firstName: string,
lastName: string,
)=>`
<p>Hi!</p>
<p>We are sorry to inform that ${firstName} ${lastName} has declined your meeting offer</p>
<p>If any of the information above is incorrect or if you have any other questions,
do not hesitate to contact our sales team at [email protected].</p>
<p>Best regards,</p>
<p>The D-Dagen project group</p>
`,
},
meeting_deleted_by_student: {
subject: (
firstName: string,
lastName: string
)=>
`Meeting Cancelled by ${firstName} ${lastName}`,
body: (
firstName: string,
lastName: string,
)=>`
<p>Hi!</p>
<p>We are sorry to inform that ${firstName} ${lastName} has canceled your meeting</p>
<p>If any of the information above is incorrect or if you have any other questions,
do not hesitate to contact our sales team at [email protected].</p>
<p>Best regards,</p>
<p>The D-Dagen project group</p>
`,
},
meeting_deleted_by_company: {
subject: (
companyName: string
)=>`Meeting Cancelled by ${companyName}`,
body: (
firstName: string,
lastName: string,
companyName: string,
)=>`
<p>Hi ${firstName} ${lastName}!</p>
<p>We are sorry to inform that ${companyName} has canceled your meeting</p>
<p>If any of the information above is incorrect or if you have any other questions,
do not hesitate to contact our sales team at [email protected].</p>
<p>Best regards,</p>
<p>The D-Dagen project group</p>
`,
},
meeting_completed_to_company: {
subject: (
firstName: string,
lastName: string,
companyName: string
)=> `Meeting Confirmed – ${companyName} and ${firstName} ${lastName}`,
body: (
firstName: string,
lastName: string,
companyName: string,
time: string,
location: string,
)=>`
<p>Hi ${companyName}!</p>
<p>This is a confirmation for your student meeting with ${firstName} ${lastName}</p>
<p>Time: ${time}</p>
<p>Location: ${location}</p>
<p>If any of the information above is incorrect or if you have any other questions,
do not hesitate to contact our sales team at [email protected].</p>
<p>Best regards,</p>
<p>The D-Dagen project group</p>
`,
},
meeting_completed_to_student: {
subject: (
firstName: string,
lastName: string,
companyName: string
)=> `Meeting Confirmed – ${companyName} and ${firstName} ${lastName}`,
body: (
firstName: string,
lastName: string,
companyName: string,
time: string,
location: string,
)=>`
<p>Hi ${firstName} ${lastName}!</p>
<p>This is a confirmation for your student meeting with ${companyName}</p>
<p>Time: ${time}</p>
<p>Location: ${location}</p>
<p>If you wish to unbook your meeting please unbook via our https://ddagen.se/student </p>
<p>If any of the information above is incorrect or if you have any other questions,
do not hesitate to contact our sales team at [email protected].</p>
<p>Best regards,</p>
<p>The D-Dagen project group</p>
`,
},
},
faq: {
box1: "ABOUT D-DAGEN",
box2: "MARKETING",
Expand Down
Loading

0 comments on commit 7ddd8a5

Please sign in to comment.