Skip to content

Commit

Permalink
fix: get event join link from apis
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Mazzon committed Oct 10, 2023
1 parent 854fd92 commit c2ba5ef
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
7 changes: 6 additions & 1 deletion app/creator/events/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Button } from "primereact/button";
import GetQrCode from "@/services/axios/requests/GetQrCode";
import { PuffLoader } from "react-spinners";
import { toast } from "react-toastify";
import GetEventJoinLink from "@/services/axios/requests/GetEventJoinLink";

export default function EventDetails({ params }: { params: any }) {
const [selectedEvent, setSelectedEvent] = useState<Event>();
Expand Down Expand Up @@ -58,7 +59,11 @@ export default function EventDetails({ params }: { params: any }) {

useEffect(() => {
if (selectedEvent) {
generateQrCode(selectedEvent.joinLink);
GetEventJoinLink(selectedEvent.id).then((result) => {
if (result.isOk()) {
generateQrCode(result.value);
}
});
}
}, [generateQrCode, selectedEvent]);

Expand Down
11 changes: 11 additions & 0 deletions app/services/axios/requests/GetEventJoinLink/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ResultAsync } from "neverthrow";
import axiosInstance from "../../index";

const GetEventJoinLink = (eventId: string): ResultAsync<string, Error> => {
return ResultAsync.fromPromise(
axiosInstance.get(`/events/${eventId}/links/join`),
(e: any) => e ?? Error("Error getting the link"),
).map((response) => response.data);
};

export default GetEventJoinLink;
2 changes: 1 addition & 1 deletion app/services/axios/requests/GetQrCode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const GetQrCode = (
Accept: type === "url" ? "application/json" : "image/*",
},
}),
(e: any) => e ?? Error("Error getting the nonce"),
(e: any) => e ?? Error("Error getting the qr code"),
).map((response) => response.data);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const EventsFields = gql`
}
}
detailsLink: details_link
joinLink: join_link
website
tags
}
Expand Down
4 changes: 0 additions & 4 deletions app/types/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ export interface Event {
* Link to share this event.
*/
detailsLink: string;
/**
* Link to join this event.
*/
joinLink: string;
}

export interface CreateEventValues {
Expand Down

0 comments on commit c2ba5ef

Please sign in to comment.