Skip to content

Commit

Permalink
add prettier to the project
Browse files Browse the repository at this point in the history
  • Loading branch information
ZegarekPL committed May 21, 2024
1 parent e84eb17 commit 2554490
Show file tree
Hide file tree
Showing 47 changed files with 1,470 additions and 1,208 deletions.
7 changes: 7 additions & 0 deletions .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.next
node_modules
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 80,
"tabWidth": 2
}
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Platform for organizing conferences

## Description
Expand All @@ -7,7 +6,7 @@ A web application for organizing scientific conferences is a tool designed to su

## Team Members

- **Marcin Bator** (@marcinbator)
- **Marcin Bator** (@marcinbator)
- **Igor Litwa** (@miszor03)
- **Wiktor Mazur** (@ZegarekPL)
- **Paweł Buczek** (@pablitoo1)
Expand Down
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"postcss": "^8",
"prettier": "^3.2.5",
"tailwindcss": "^3.3.0",
"typescript": "5.4.3"
}
Expand Down
34 changes: 18 additions & 16 deletions src/app/(role_all)/conference/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ export default function ConferencePage() {
sortFilterData?.verified,
sortFilterData?.participantsFull,
sortFilterData?.organizerId,
sortFilterData?.locationName
sortFilterData?.locationName,
),
{
staleTime: Infinity,
refetchOnMount: "always",
}
},
);

useEffect(() => {
Expand Down Expand Up @@ -103,20 +103,22 @@ export default function ConferencePage() {
role={"USER"}
/>
<div className="w-full flex flex-col gap-y-10">
{data.content?.sort((a,b)=>Number(a.canceled)-Number(b.canceled)).map((conf) => {
return (
<ConferenceList
key={`${conf.id}`}
conference={conf}
role={userRole}
setSignUpWarning={setSignUpWarning}
setTempId={setTempId}
update={update}
setUpdate={setUpdate}
mode={"conference"}
/>
);
})}
{data.content
?.sort((a, b) => Number(a.canceled) - Number(b.canceled))
.map((conf) => {
return (
<ConferenceList
key={`${conf.id}`}
conference={conf}
role={userRole}
setSignUpWarning={setSignUpWarning}
setTempId={setTempId}
update={update}
setUpdate={setUpdate}
mode={"conference"}
/>
);
})}
</div>
</div>
) : (
Expand Down
67 changes: 39 additions & 28 deletions src/app/(role_organizer)/lecture/[lectureId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { BoxWithImage } from "@/components/common/Box/Box";
import Error500 from "@/components/common/Error/Error500";
import People from "@/components/myconferenceId/Participants/People";
import { getConferenceDetailsWithRoleFiltering } from "@/hooks/conference";
import { getLectureDetails, GetLectureDetailsData, addLectureToFavourites, removeLectureFromFavourites } from "@/hooks/lecture";
import {
getLectureDetails,
GetLectureDetailsData,
addLectureToFavourites,
removeLectureFromFavourites,
} from "@/hooks/lecture";
import { getCurrentUser } from "@/hooks/user";
import MyLecturePageImageBox from "@/components/lecture/MyLecturePageImageBox";
import TitleHeader from "@/components/common/Box/TitleHeader";
Expand All @@ -16,17 +21,17 @@ import useAuth from "@/hooks/useAuth";
import NotFound from "../../addlecture/[conferenceId]/not-found";
import { FaStar, FaRegStar } from "react-icons/fa";
import { IoArrowBackCircle } from "react-icons/io5";
import {useRouter} from "next/navigation";
import { useRouter } from "next/navigation";

async function getId() {
const userData = await getCurrentUser();
if (userData && typeof userData === 'object' && 'id' in userData) {
if (userData && typeof userData === "object" && "id" in userData) {
return userData.id;
}
return null;
}

const RedirectToConference = ({conferenceId} : {conferenceId: number}) => {
const RedirectToConference = ({ conferenceId }: { conferenceId: number }) => {
const router = useRouter();

return (
Expand All @@ -35,12 +40,12 @@ const RedirectToConference = ({conferenceId} : {conferenceId: number}) => {
onClick={() => router.push(`/myconference/${conferenceId}`)}
>
<div className="flex justify-center items-center gap-x-2">
<IoArrowBackCircle className="size-5 md:size-7 hidden xs:block"/>
<IoArrowBackCircle className="size-5 md:size-7 hidden xs:block" />
<p className="text-xs md:text-base">Przejdź do konferencji</p>
</div>
</div>
)
}
);
};

export default function LecturePage({
params,
Expand All @@ -60,7 +65,6 @@ export default function LecturePage({
const [update, setUpdate] = useState<boolean>(false);
const [isFavourite, setIsFavourite] = useState<boolean>(false);


useEffect(() => {
const fetchId = async () => {
const id = await getId();
Expand All @@ -76,12 +80,14 @@ export default function LecturePage({
const data = await getLectureDetails(parseInt(params.lectureId));
setLectureIdData(data);
setLoading(false);
if (typeof data !== 'string') {
const conference = await getConferenceDetailsWithRoleFiltering(data.conferenceId);
if (typeof conference !== 'string') {
if (typeof data !== "string") {
const conference = await getConferenceDetailsWithRoleFiltering(
data.conferenceId,
);
if (typeof conference !== "string") {
setParticipant(conference.amISignedUp);
}
setIsFavourite(data.interested.some(user => user.id === userId));
setIsFavourite(data.interested.some((user) => user.id === userId));
}
} catch (error: any) {
setError(error.message);
Expand All @@ -98,35 +104,33 @@ export default function LecturePage({
if (isError) return <Error500 />;
if (isAuthorise === false) return <NotFound />;

const handleAddToFavourites = async () => {
const handleAddToFavourites = async () => {
try {
const result = await addLectureToFavourites(parseInt(params.lectureId));
if (result === 200) {
if (setUpdate)
setUpdate(!update);
if (setUpdate) setUpdate(!update);
} else {
console.error("Błąd dodawania wykładu do ulubionych.");
}
} catch (error) {
console.error("Błąd dodawania wykładu do ulubionych.", error);
}
}
};

const handleRemoveFromFavourites = async() => {
const handleRemoveFromFavourites = async () => {
try {
const result = await removeLectureFromFavourites(parseInt(params.lectureId));
const result = await removeLectureFromFavourites(
parseInt(params.lectureId),
);
if (result === 200) {
if (setUpdate)
setUpdate(!update);
if (setUpdate) setUpdate(!update);
} else {
console.error("Błąd usuwania wykładu z ulubionych.");
}
} catch (error) {
console.error("Błąd usuwania wykładu z ulubionych.", error);
}
}


};

return (
<Page>
Expand All @@ -136,7 +140,7 @@ export default function LecturePage({
lectureIdData &&
typeof lectureIdData !== "string" ? (
<div className="w-[90%] lg:w-[60%]">
<RedirectToConference conferenceId={lectureIdData.conferenceId}/>
<RedirectToConference conferenceId={lectureIdData.conferenceId} />
<BoxWithImage
className="text-darkblue mb-5 rounded-tl-none"
src={lectureIdData.image.id}
Expand All @@ -155,13 +159,21 @@ export default function LecturePage({
<span className="w-full flex justify-center md:justify-end">
<span
onClick={() => {
isFavourite ? handleRemoveFromFavourites() : handleAddToFavourites();
isFavourite
? handleRemoveFromFavourites()
: handleAddToFavourites();
}}
className="w-fit h-min flex justify-center items-center gap-x-2 cursor-pointer text-darkblue px-3"
>
{isFavourite ? <FaStar className="text-xl" /> : <FaRegStar className="text-xl" />}
{isFavourite ? (
<FaStar className="text-xl" />
) : (
<FaRegStar className="text-xl" />
)}
<p className="text-sm md:text-lg font-medium">
{isFavourite ? "Usuń z ulubionych" : "Dodaj do ulubionych"}
{isFavourite
? "Usuń z ulubionych"
: "Dodaj do ulubionych"}
</p>
</span>
</span>
Expand Down Expand Up @@ -217,7 +229,6 @@ export default function LecturePage({
</div>
</>
) : null}

</BoxWithImage>
</div>
) : (
Expand Down
54 changes: 36 additions & 18 deletions src/app/(role_organizer)/myconference/[conferenceId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
deleteConference,
getConferenceDetailsWithRoleFiltering,
GetConferenceDetailsWithRoleFilteringData,
signOutFromConference
signOutFromConference,
} from "@/hooks/conference";
import Error500 from "@/components/common/Error/Error500";
import People from "@/components/myconferenceId/Participants/People";
Expand Down Expand Up @@ -35,9 +35,9 @@ export default function MyConferencePage({
data: conferenceIdData,
isLoading,
isError,
refetch
refetch,
} = useQuery(`conferenceId${parseInt(params.conferenceId)}`, () =>
getConferenceDetailsWithRoleFiltering(parseInt(params.conferenceId))
getConferenceDetailsWithRoleFiltering(parseInt(params.conferenceId)),
);

if (isError) return <Error500 />;
Expand All @@ -46,20 +46,19 @@ export default function MyConferencePage({
const [signUpWarning, setSignUpWarning] = useState<boolean>(false);
const [update, setUpdate] = useState<boolean>(false);

const signOut = async (id : number) => {
const signOut = async (id: number) => {
try {
const result = await signOutFromConference(id);
if (result === 200) {
console.log("Wypisano z konferencji.");
if (setUpdate)
setUpdate(!update);
if (setUpdate) setUpdate(!update);
} else {
console.error("Błąd wypisywania z konferencji.");
}
} catch (error) {
console.error("Błąd wypisywania z konferencji.", error);
}
}
};

useEffect(() => {
refetch();
Expand All @@ -78,21 +77,35 @@ export default function MyConferencePage({
) : null}
<Title conferenceIdData={conferenceIdData}>
<span className="flex justify-center w-full">
<span onClick={() => {
if(conferenceIdData.amISignedUp) {
<span
onClick={() => {
if (conferenceIdData.amISignedUp) {
signOut(conferenceIdData.id);
}
else if (!conferenceIdData.participantsFull && !conferenceIdData.amISignedUp) {
} else if (
!conferenceIdData.participantsFull &&
!conferenceIdData.amISignedUp
) {
setSignUpWarning(true);
}
}}
className="flex items-center bg-gray-300 rounded-full cursor-pointer px-2 mt-4 space-x-2">
className="flex items-center bg-gray-300 rounded-full cursor-pointer px-2 mt-4 space-x-2"
>
<p className="text-black font-semibold">
{conferenceIdData.participantsFull && !conferenceIdData.amISignedUp ? "Brak miejsc" : conferenceIdData.amISignedUp ? "Wypisz się" : "Zapisz się"}
</p>
{conferenceIdData.participantsFull && !conferenceIdData.amISignedUp ?
<CiCirclePlus className="text-4xl text-darkblue opacity-50"/> : conferenceIdData.amISignedUp ?
<CiCircleMinus className="text-4xl text-darkblue" /> : <CiCirclePlus className="text-4xl text-darkblue" />}
{conferenceIdData.participantsFull &&
!conferenceIdData.amISignedUp
? "Brak miejsc"
: conferenceIdData.amISignedUp
? "Wypisz się"
: "Zapisz się"}
</p>
{conferenceIdData.participantsFull &&
!conferenceIdData.amISignedUp ? (
<CiCirclePlus className="text-4xl text-darkblue opacity-50" />
) : conferenceIdData.amISignedUp ? (
<CiCircleMinus className="text-4xl text-darkblue" />
) : (
<CiCirclePlus className="text-4xl text-darkblue" />
)}
</span>
</span>
</Title>
Expand All @@ -109,7 +122,12 @@ export default function MyConferencePage({
<Photos photos={conferenceIdData.photos} />
) : null}
{signUpWarning && (
<SignUpWarning setSignUpWarning={setSignUpWarning} tempId={conferenceIdData.id} update={update} setUpdate={setUpdate}/>
<SignUpWarning
setSignUpWarning={setSignUpWarning}
tempId={conferenceIdData.id}
update={update}
setUpdate={setUpdate}
/>
)}
</>
) : (
Expand Down
Loading

0 comments on commit 2554490

Please sign in to comment.