diff --git a/frontend/src/components/item-card/item-card.jsx b/frontend/src/components/item-card/item-card.jsx index d3de428..7c8783e 100644 --- a/frontend/src/components/item-card/item-card.jsx +++ b/frontend/src/components/item-card/item-card.jsx @@ -59,6 +59,7 @@ const ItemCard = ({ startDate, endDate, presenterName, + certificateLink, finished, level, cost = 50000, @@ -193,6 +194,18 @@ const ItemCard = ({ {getActionComponent()} + {certificateLink && + + } ); @@ -216,6 +229,7 @@ ItemCard.propTypes = { addToCalendarLink: PropTypes.string, onClickAddToCart: PropTypes.func, remainingCapacity: PropTypes.number, + certificateLink: PropTypes.string, finished: PropTypes.bool, }; diff --git a/frontend/src/pages/my-account/MyAccount.jsx b/frontend/src/pages/my-account/MyAccount.jsx index 0333679..cd22dfe 100644 --- a/frontend/src/pages/my-account/MyAccount.jsx +++ b/frontend/src/pages/my-account/MyAccount.jsx @@ -87,6 +87,7 @@ const MyAccount = () => { presenterName={item.presenters?.join(', ') ?? item.teachers?.join(', ')} cost={item.cost} hasProject={item.has_project} + certificateLink={item.certificateLink} prerequisites={item.prerequisites} syllabus={item.syllabus} capacity={item.capacity} diff --git a/frontend/src/pages/my-account/useMyAccount.js b/frontend/src/pages/my-account/useMyAccount.js index 5f45534..a79a861 100644 --- a/frontend/src/pages/my-account/useMyAccount.js +++ b/frontend/src/pages/my-account/useMyAccount.js @@ -160,6 +160,9 @@ export default function useMyAccount() { if (presentation.id === userPresentation.id) { presentation.type = "presentation" if (userPresentation.status !== "AWAITING_PAYMENT") { + if (userPresentation.certificate) { + presentation.certificateLink = userPresentation.certificate + } userTempPresentations.push(presentation) } else { userTempCart.push(presentation) @@ -172,6 +175,9 @@ export default function useMyAccount() { if (workshop.id === userWorkshop.id) { workshop.type = "workshop" if (userWorkshop.status !== "AWAITING_PAYMENT") { + if (userWorkshop.certificate) { + workshop.certificateLink = userWorkshop.certificate + } userTempWorkshops.push(workshop) } else { userTempCart.push(workshop) diff --git a/frontend/src/providers/APIProvider/APIProvider.jsx b/frontend/src/providers/APIProvider/APIProvider.jsx index db7a528..18caee9 100644 --- a/frontend/src/providers/APIProvider/APIProvider.jsx +++ b/frontend/src/providers/APIProvider/APIProvider.jsx @@ -8,7 +8,7 @@ export function APIProvider({ children }) { const { accessToken, refreshToken, setAccessTokenFromLocalStorage } = useConfig(); const service = axios; - const currentYear = new Date().getFullYear(); + const year = "2023"; const [workshopsData, setWorkshopsData] = useState(); const [presentationsData, setPresentationsData] = useState(); @@ -200,19 +200,19 @@ export function APIProvider({ children }) { async (id) => { if (id != null) id = id + '/'; await service - .get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.presenter}${id ?? ''}`) + .get(`${URL.baseURL}${URL.services[year]}${URL.endpoints.presenter}${id ?? ''}`) .then((response) => { setPresenterData(response.data); }); }, - [currentYear, service], + [year, service], ); const getCommitteeData = useCallback(async () => { - await service.get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.committee}`).then((response) => { + await service.get(`${URL.baseURL}${URL.services[year]}${URL.endpoints.committee}`).then((response) => { setCommitteeData(response.data); }); - }, [currentYear, service]); + }, [year, service]); const postVerifyPayment = useCallback( async (data) => { @@ -225,7 +225,7 @@ export function APIProvider({ children }) { setVerifyPaymentData(error.response); }); }, - [currentYear, service], + [year, service], ); const postPaymentData = useCallback( @@ -243,46 +243,46 @@ export function APIProvider({ children }) { setPaymentData(error.response); }); }, - [currentYear, service, getAccessTokenHeader], + [year, service, getAccessTokenHeader], ); const activateUser = useCallback(async () => { - await service.get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.user.activate}`).then((response) => { + await service.get(`${URL.baseURL}${URL.services[year]}${URL.endpoints.user.activate}`).then((response) => { setActivateUserData(response.data); }); - }, [currentYear, service]); + }, [year, service]); const deleteUser = useCallback( async (data) => { await service - .delete(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.user.default}`, data) + .delete(`${URL.baseURL}${URL.services[year]}${URL.endpoints.user.default}`, data) .then((response) => { setDeleteUserData(response.data); }); }, - [currentYear, service], + [year, service], ); const partiallyUpdateUser = useCallback( async (data) => { await service - .patch(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.user.default}`, data) + .patch(`${URL.baseURL}${URL.services[year]}${URL.endpoints.user.default}`, data) .then((response) => { setPartiallyUpdateUserData(response.data); }); }, - [currentYear, service], + [year, service], ); const updateUser = useCallback( async (data) => { await service - .put(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.user.default}`, data) + .put(`${URL.baseURL}${URL.services[year]}${URL.endpoints.user.default}`, data) .then((response) => { setUpdateUserData(response); }); }, - [currentYear, service], + [year, service], ); const createUser = useCallback( @@ -303,58 +303,58 @@ export function APIProvider({ children }) { async (id) => { if (id != null) id = id + '/'; await service - .get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.user.default}${id ?? ''}`) + .get(`${URL.baseURL}${URL.services[year]}${URL.endpoints.user.default}${id ?? ''}`) .then((response) => { setUserData(response.data); }); }, - [currentYear, service], + [year, service], ); const getMiscData = useCallback( async (id) => { if (id != null) id = id + '/'; await service - .get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.misc}${id ?? ''}`) + .get(`${URL.baseURL}${URL.services[year]}${URL.endpoints.misc}${id ?? ''}`) .then((response) => { setMiscData(response.data); }); }, - [currentYear, service], + [year, service], ); const getStaffData = useCallback(async () => { - await service.get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.staff}`).then((response) => { + await service.get(`${URL.baseURL}${URL.services[year]}${URL.endpoints.staff}`).then((response) => { setStaffData(response.data); }); - }, [currentYear, service]); + }, [year, service]); const getWorkshopsData = useCallback( async (id) => { if (id != null) id = id + '/'; await service - .get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.workshop}${id ?? ''}`) + .get(`${URL.baseURL}${URL.services[year]}${URL.endpoints.workshop}${id ?? ''}`) .then((response) => { setWorkshopsData(response.data); }); }, - [currentYear, service], + [year, service], ); const getPresentationsData = useCallback(async () => { - await service.get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.presentation}`).then((response) => { + await service.get(`${URL.baseURL}${URL.services[year]}${URL.endpoints.presentation}`).then((response) => { setPresentationsData(response.data); }); - }, [currentYear, service]); + }, [year, service]); const getTeachersData = useCallback( async (id) => { if (id != null) id = id + '/'; await service - .get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.teacher}${id ?? ''}`) + .get(`${URL.baseURL}${URL.services[year]}${URL.endpoints.teacher}${id ?? ''}`) .then((response) => setTeachersData(response.data)); }, - [currentYear, service], + [year, service], ); useEffect(() => {