From 0a701e68bfe7c4f0c5cb9d558aa1952e306b94b1 Mon Sep 17 00:00:00 2001 From: homoakin619 Date: Sun, 10 Dec 2023 14:03:00 +0100 Subject: [PATCH 1/2] updated portfolio endpoint --- components/Modals/interest-modal.tsx | 6 +++--- components/Modals/language-modal.tsx | 10 +++++----- context/PortfolioLandingContext.tsx | 4 ++-- http/checkout.ts | 2 +- modules/explore/explorePage.tsx | 2 +- .../component/ProductWeThoughtMightInterestYou.tsx | 2 +- modules/marketplace/http/index.ts | 4 ++-- modules/portfolio/component/about/about.tsx | 10 +++++----- modules/portfolio/component/awards-modal.tsx | 12 ++++++------ modules/portfolio/component/certification-modal.tsx | 4 ++-- modules/portfolio/component/contact-modal.tsx | 8 ++++---- modules/portfolio/component/modals/apiService.js | 2 +- modules/portfolio/component/modals/edit-profile.tsx | 8 ++++---- .../modals/project-modal/all-projects-modal.tsx | 2 +- .../modals/project-modal/project-section-modal.tsx | 2 +- .../component/modals/project-modal/projects.tsx | 2 +- .../portfolio/component/modals/track-dropdown.tsx | 2 +- .../portfolio/component/new-custom-section-modal.tsx | 4 ++-- .../portfolioSettingsComponents/DeleteAccount.tsx | 2 +- .../UpdatingProfilePic.tsx | 2 +- .../notificationsSettings.tsx | 2 +- modules/portfolio/component/reference/reference.tsx | 2 +- .../portfolio/component/skillModal/SkillsModal.tsx | 8 ++++---- modules/portfolio/component/warningModals.tsx | 2 +- modules/portfolio/context/education-context.tsx | 4 ++-- .../context/work-experience-modal-context.tsx | 2 +- modules/shop/ZuriLandingPage.tsx | 2 -- pages/portfolio/[slug]/index.tsx | 4 ++-- pages/settings.tsx | 2 +- pages/super-admin/assessment/index.tsx | 2 +- pages/user/customer-purchase-dashboard/index.tsx | 4 ++++ 31 files changed, 63 insertions(+), 61 deletions(-) diff --git a/components/Modals/interest-modal.tsx b/components/Modals/interest-modal.tsx index 702a51098..738fe6726 100644 --- a/components/Modals/interest-modal.tsx +++ b/components/Modals/interest-modal.tsx @@ -11,7 +11,7 @@ import { checkObjectProperties } from '@modules/portfolio/functions/checkObjectP import Loader from '@ui/Loader'; import { AiOutlineClose, AiOutlineCloseCircle, AiOutlinePlus } from 'react-icons/ai'; -const endpoint = 'https://hng6-r5y3.onrender.com'; +const endpoint = `${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`; type interestModalProps = { onCloseModal: () => void; @@ -94,7 +94,7 @@ const InterestModal = ({ isOpen, onCloseModal, onSaveModal, userId }: interestMo userId: userId, }; axios - .post(`${endpoint}/api/v1/interests`, data) + .post(`${endpoint}/interests`, data) .then((res) => { setLoading(false); notify({ @@ -154,7 +154,7 @@ const InterestModal = ({ isOpen, onCloseModal, onSaveModal, userId }: interestMo const getAllInterests = () => { setInitialLoading(true); axios - .get(`${endpoint}/api/v1/interests/${userId}`) + .get(`${endpoint}/interests/${userId}`) .then((res) => { setInitialLoading(false); const interestsArray: string[] = res.data?.interestArray; diff --git a/components/Modals/language-modal.tsx b/components/Modals/language-modal.tsx index 5dab74312..9d5fc82c0 100644 --- a/components/Modals/language-modal.tsx +++ b/components/Modals/language-modal.tsx @@ -18,7 +18,7 @@ type languageModalProps = { userId: string; }; -const endpoint = 'https://hng6-r5y3.onrender.com'; +const endpoint = (`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`) as string; const programmingLanguages = [ 'JavaScript', 'TypeScript', @@ -101,7 +101,7 @@ const LanguageModal = ({ isOpen, onCloseModal, onSaveModal, userId }: languageMo }; const handleDelete = async (params: any) => { - const data = await fetch(`https://hng6-r5y3.onrender.com/api/v1/languages`, { + const data = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/languages`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -141,7 +141,7 @@ const LanguageModal = ({ isOpen, onCloseModal, onSaveModal, userId }: languageMo sectionId: 5, }; axios - .post(`${endpoint}/api/v1/languages`, data) + .post(`${endpoint}/languages`, data) .then(async (res) => { setLoading(false); notify({ @@ -151,7 +151,7 @@ const LanguageModal = ({ isOpen, onCloseModal, onSaveModal, userId }: languageMo type: 'success', }); setValues([]); - await fetch(`${endpoint}/api/v1/getPorfolio/${userId}`); + await fetch(`${endpoint}/getPorfolio/${userId}`); onSaveModal(); }) .catch((err) => { @@ -169,7 +169,7 @@ const LanguageModal = ({ isOpen, onCloseModal, onSaveModal, userId }: languageMo const getAllLanguages = () => { setInitialLoading(true); axios - .get(`${endpoint}/api/v1/languages/${userId}`) + .get(`${endpoint}/languages/${userId}`) .then((res) => { if (res.data.data !== null) { setInitialLoading(false); diff --git a/context/PortfolioLandingContext.tsx b/context/PortfolioLandingContext.tsx index f7304ae13..24c4b8813 100644 --- a/context/PortfolioLandingContext.tsx +++ b/context/PortfolioLandingContext.tsx @@ -116,7 +116,7 @@ const Portfolio = createContext({ export function PortfolioCtxProvider(props: { children: any }) { const queryClient = useQueryClient(); const router = useRouter(); - const portfolioUrl = `https://hng6-r5y3.onrender.com/api/v1/portfolio`; + const portfolioUrl = `${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/portfolio`; const { auth } = useAuth(); const [userId, setUserId] = useState(''); const [slug, setSlug] = useState(''); @@ -272,7 +272,7 @@ export function PortfolioCtxProvider(props: { children: any }) { formData.append('images', coverImage as string | Blob); formData.append('userId', userId); - const response = await fetch('https://hng6-r5y3.onrender.com/api/v1/profile/cover/upload', { + const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/profile/cover/upload`, { method: 'POST', body: formData, }); diff --git a/http/checkout.ts b/http/checkout.ts index 69ef676d5..88f4adc33 100644 --- a/http/checkout.ts +++ b/http/checkout.ts @@ -188,7 +188,7 @@ export const getRecentlyViewedProducts = async (token: string) => { }; export const getRecommendedProducts = async () => { - const apiUrl = 'https://coral-app-8bk8j.ondigitalocean.app/api/marketplace/recommendations'; + const apiUrl = 'https://coral-app-8bk8j.ondigitalocean.app/api/marketplace/v1/recommendations'; try { const response = await axios.get(apiUrl); return response.data.data; diff --git a/modules/explore/explorePage.tsx b/modules/explore/explorePage.tsx index 8ad7f7b26..13cfead02 100644 --- a/modules/explore/explorePage.tsx +++ b/modules/explore/explorePage.tsx @@ -82,7 +82,7 @@ const HomePage = () => { const { data, isLoading } = useQuery({ queryKey: ['profile', deBounce, filters, pageNumber], queryFn: () => fetchUsers(searchQuery), - staleTime: 60000, + // staleTime: 60000, }); return ( diff --git a/modules/marketplace/component/ProductWeThoughtMightInterestYou.tsx b/modules/marketplace/component/ProductWeThoughtMightInterestYou.tsx index dec581e66..928807694 100644 --- a/modules/marketplace/component/ProductWeThoughtMightInterestYou.tsx +++ b/modules/marketplace/component/ProductWeThoughtMightInterestYou.tsx @@ -19,7 +19,7 @@ export default function ProductWeThoughtMightInterestYou({ id }: any) { const { setCartCountNav, cartCount } = useCart(); const [cartLoading, setCartLoading] = useState(true); - const url = `https://coral-app-8bk8j.ondigitalocean.app/api/marketplace/similar_products/${id}/`; + const url = `https://coral-app-8bk8j.ondigitalocean.app/api/marketplace/v1/similar_products/${id}/`; useEffect(() => { fetch(url) .then((res) => res.json()) diff --git a/modules/marketplace/http/index.ts b/modules/marketplace/http/index.ts index a694bd957..3fa1fa57a 100644 --- a/modules/marketplace/http/index.ts +++ b/modules/marketplace/http/index.ts @@ -1,7 +1,7 @@ import axios from 'axios'; -// export let API_URI = 'https://coral-app-8bk8j.ondigitalocean.app/api/marketplace/v1'; -export let API_URI = 'https://staging.zuri.team/api/marketplace/v1'; +export let API_URI = 'https://coral-app-8bk8j.ondigitalocean.app/api/marketplace/v1'; +// export let API_URI = 'https://staging.zuri.team/api/marketplace/v1'; const http = axios.create({ baseURL: API_URI, diff --git a/modules/portfolio/component/about/about.tsx b/modules/portfolio/component/about/about.tsx index 7955691f2..909f15b33 100644 --- a/modules/portfolio/component/about/about.tsx +++ b/modules/portfolio/component/about/about.tsx @@ -26,12 +26,12 @@ const PortfolioAbout: React.FC = ({ onCloseModal, onSaveModal, const [create, setCreate] = useState(false); // POST ABOUT VALUE TO DATABASE - const API_BASE_URL = 'https://hng6-r5y3.onrender.com'; + const API_BASE_URL = (`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`) as string; const createResponse = async () => { try { const axiosConfig = { method: 'post', - url: `${API_BASE_URL}/api/v1/about/${userId}`, + url: `${API_BASE_URL}/about/${userId}`, data: bio, }; @@ -79,7 +79,7 @@ const PortfolioAbout: React.FC = ({ onCloseModal, onSaveModal, try { const axiosConfig = { method: 'get', - url: `${API_BASE_URL}/api/v1/about/${userId}`, + url: `${API_BASE_URL}/about/${userId}`, }; const response = await axios(axiosConfig); @@ -115,7 +115,7 @@ const PortfolioAbout: React.FC = ({ onCloseModal, onSaveModal, try { const axiosConfig = { method: 'put', - url: `${API_BASE_URL}/api/v1/about/${id}`, + url: `${API_BASE_URL}/about/${id}`, data: bio, }; @@ -179,7 +179,7 @@ const PortfolioAbout: React.FC = ({ onCloseModal, onSaveModal, try { const axiosConfig = { method: 'delete', - url: `${API_BASE_URL}/api/v1/about/${id}`, + url: `${API_BASE_URL}/about/${id}`, }; const response = await axios(axiosConfig); diff --git a/modules/portfolio/component/awards-modal.tsx b/modules/portfolio/component/awards-modal.tsx index 06c37eda2..451a9ab17 100644 --- a/modules/portfolio/component/awards-modal.tsx +++ b/modules/portfolio/component/awards-modal.tsx @@ -39,7 +39,7 @@ const initialContextValue: Context = { error: '', setIsLoading: () => {}, isLoading: false, - baseURL: 'https://hng6-r5y3.onrender.com', // Add baseURL with a default value + baseURL: (`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`) as string, // Add baseURL with a default value setBaseURL: () => {}, // Add setter for baseURL }; @@ -62,7 +62,7 @@ const Awards = ({ isOpen, onCloseModal }: awardsModalProps) => { url: '', description: '', }); - const [baseURL, setBaseURL] = useState('https://hng6-r5y3.onrender.com'); + const [baseURL, setBaseURL] = useState(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`); const [isModalOpen, setIsModalOpen] = useState(false); const [urlError, setUrlError] = useState(''); const [error, setError] = useState(''); @@ -82,7 +82,7 @@ const Awards = ({ isOpen, onCloseModal }: awardsModalProps) => { try { setIsLoading(true); - const response = await fetch(`${baseURL}/api/v1/awards/${userId}`, { + const response = await fetch(`${baseURL}/awards/${userId}`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -365,7 +365,7 @@ const AwardList: React.FC = () => { const fetchAwards = async () => { try { setIsLoading(true); - const response = await fetch(`${baseURL}/api/v1/awards`); + const response = await fetch(`${baseURL}/awards`); setIsLoading(false); const status = response.status; @@ -446,7 +446,7 @@ const AwardItem: React.FC = ({ award }) => { // Send a PUT request to update the award try { setEditLoading(true); - const response = await fetch(`${baseURL}/api/v1/awards/${id}`, { + const response = await fetch(`${baseURL}/awards/${id}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', @@ -513,7 +513,7 @@ const AwardItem: React.FC = ({ award }) => { try { setDeleteLoading(true); - const response = await fetch(`${baseURL}/api/v1/awards/${id}`, { + const response = await fetch(`${baseURL}/awards/${id}`, { method: 'DELETE', }); const status = response.status; diff --git a/modules/portfolio/component/certification-modal.tsx b/modules/portfolio/component/certification-modal.tsx index fa6f8d050..c4e3df8f7 100644 --- a/modules/portfolio/component/certification-modal.tsx +++ b/modules/portfolio/component/certification-modal.tsx @@ -39,7 +39,7 @@ const initialContextValue: Context = { error: '', setIsLoading: () => {}, isLoading: false, - baseURL: 'https://hng6-r5y3.onrender.com', // Add baseURL with a default value + baseURL: (`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`) as string, // Add baseURL with a default value setBaseURL: () => {}, // Add setter for baseURL }; @@ -62,7 +62,7 @@ const Certifications = ({ isOpen, onCloseModal }: certificationModalProps) => { url: '', description: '', }); - const [baseURL, setBaseURL] = useState('https://hng6-r5y3.onrender.com'); + const [baseURL, setBaseURL] = useState(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`); const [isModalOpen, setIsModalOpen] = useState(false); const [urlError, setUrlError] = useState(''); const [error, setError] = useState(''); diff --git a/modules/portfolio/component/contact-modal.tsx b/modules/portfolio/component/contact-modal.tsx index ed3b78589..84d686426 100644 --- a/modules/portfolio/component/contact-modal.tsx +++ b/modules/portfolio/component/contact-modal.tsx @@ -92,7 +92,7 @@ function ContactModal({ isOpen, onCloseModal, onSaveModal, userId }: contactModa user_id: userId, // Ensure you have the userId available })); - sendArrayOfObjects(data, 'https://hng6-r5y3.onrender.com/api/v1/contacts') + sendArrayOfObjects(data, `${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/contacts`) .then((response: any) => { setLoading(false); notify({ @@ -128,7 +128,7 @@ function ContactModal({ isOpen, onCloseModal, onSaveModal, userId }: contactModa console.log('delete clicked'); const id = 5; try { - const res = await fetch(`https://hng6-r5y3.onrender.com/api/v1/contacts/${id}`, { + const res = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/contacts/${id}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json', @@ -145,7 +145,7 @@ function ContactModal({ isOpen, onCloseModal, onSaveModal, userId }: contactModa const getSocialsAvailable = async () => { try { - const response = await axios.get(`https://hng6-r5y3.onrender.com/api/v1/socials`); + const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/socials`); const data = await response.data; console.log('getSocialsAvailable', data); setAvailableSocials(data?.data); @@ -164,7 +164,7 @@ function ContactModal({ isOpen, onCloseModal, onSaveModal, userId }: contactModa const getAllSocials = async () => { try { - const response = await axios.get(`https://hng6-r5y3.onrender.com/api/v1/contacts/${userId}`); + const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/contacts/${userId}`); const data = await response.data; console.log('responseData', data); } catch (error) { diff --git a/modules/portfolio/component/modals/apiService.js b/modules/portfolio/component/modals/apiService.js index 402822a47..f47bb4edb 100644 --- a/modules/portfolio/component/modals/apiService.js +++ b/modules/portfolio/component/modals/apiService.js @@ -1,6 +1,6 @@ import axios from 'axios'; -const BASE_URL = 'https://hng6-r5y3.onrender.com/api/v1'; +const BASE_URL = `${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/`; export const updateProfileDetails = async (userId, newProfileDetails) => { try { diff --git a/modules/portfolio/component/modals/edit-profile.tsx b/modules/portfolio/component/modals/edit-profile.tsx index e1b47e0de..749ce585f 100644 --- a/modules/portfolio/component/modals/edit-profile.tsx +++ b/modules/portfolio/component/modals/edit-profile.tsx @@ -38,7 +38,7 @@ const EditProfile = () => { const fetchData = async () => { try { setIsLoading(true); - const response = await fetch(`https://hng6-r5y3.onrender.com/api/v1/users/${userId}`); + const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/users/${userId}`); const userData = await response.json(); @@ -61,7 +61,7 @@ const EditProfile = () => { const getTracks = async () => { try { - const response = await fetch('https://hng6-r5y3.onrender.com/api/v1/tracks'); + const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/tracks`); const data = await response.json(); return data.data; } catch (error: any) { @@ -96,7 +96,7 @@ const EditProfile = () => { matchingTrack = availableTracks.find((track: any) => track.track === selectedTrack); if (matchingTrack) { setIsLoading(true); - const response = await fetch(`https://hng6-r5y3.onrender.com/api/v1/users/${userId}`, { + const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/users/${userId}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', @@ -131,7 +131,7 @@ const EditProfile = () => { const formData = new FormData(); formData.append('images', coverImage as string | Blob); formData.append('userId', userId); - const response = await fetch('https://hng6-r5y3.onrender.com/api/v1/profile/image/upload', { + const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/profile/image/upload`, { method: 'POST', body: formData, }); diff --git a/modules/portfolio/component/modals/project-modal/all-projects-modal.tsx b/modules/portfolio/component/modals/project-modal/all-projects-modal.tsx index 8848bfe7d..79b88e5b2 100644 --- a/modules/portfolio/component/modals/project-modal/all-projects-modal.tsx +++ b/modules/portfolio/component/modals/project-modal/all-projects-modal.tsx @@ -8,7 +8,7 @@ import { notify } from '@ui/Toast'; import { Edit2, Trash } from 'iconsax-react'; import { Data, allRouteOptions } from './project-section-modal'; -const endpoint = 'https://hng6-r5y3.onrender.com'; +const endpoint = (`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`) as string; const AllProjectsModal = ({ onEdit, projects, diff --git a/modules/portfolio/component/modals/project-modal/project-section-modal.tsx b/modules/portfolio/component/modals/project-modal/project-section-modal.tsx index 84890a19d..d095ea406 100644 --- a/modules/portfolio/component/modals/project-modal/project-section-modal.tsx +++ b/modules/portfolio/component/modals/project-modal/project-section-modal.tsx @@ -51,7 +51,7 @@ const ProjectSectionModal = ({ isOpen, onCloseModal, onSaveModal, userId }: Proj setLoading(data); }; - const endpoint = 'https://hng6-r5y3.onrender.com'; + const endpoint = (`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`) as string; const getAllProjects = () => { setLoading(true); axios diff --git a/modules/portfolio/component/modals/project-modal/projects.tsx b/modules/portfolio/component/modals/project-modal/projects.tsx index f2dfc09cf..a382c96e8 100644 --- a/modules/portfolio/component/modals/project-modal/projects.tsx +++ b/modules/portfolio/component/modals/project-modal/projects.tsx @@ -20,7 +20,7 @@ type ProjectSectionProps = { handleSetRoute: (data: allRouteOptions) => void; }; -const endpoint = 'https://hng6-r5y3.onrender.com'; +const endpoint = (`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`) as string; const ProjectSection: React.FC = ({ dataToEdit, onCloseModal, diff --git a/modules/portfolio/component/modals/track-dropdown.tsx b/modules/portfolio/component/modals/track-dropdown.tsx index 59e32c413..537ee3825 100644 --- a/modules/portfolio/component/modals/track-dropdown.tsx +++ b/modules/portfolio/component/modals/track-dropdown.tsx @@ -12,7 +12,7 @@ const TrackDropdown = ({ onSelectTrack }: { onSelectTrack: (selectedTrack: strin useEffect(() => { const fetchTracks = async () => { try { - const response = await fetch('https://hng6-r5y3.onrender.com/api/v1/tracks', { + const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/tracks`, { headers: { Accept: 'application/json', }, diff --git a/modules/portfolio/component/new-custom-section-modal.tsx b/modules/portfolio/component/new-custom-section-modal.tsx index cf708f236..3816aaa3b 100644 --- a/modules/portfolio/component/new-custom-section-modal.tsx +++ b/modules/portfolio/component/new-custom-section-modal.tsx @@ -128,7 +128,7 @@ function CreateCustomSectionContainer({ onClose, userId }: { onClose: () => void }; const createNewCustomSectionOption = useMutation(async () => { - const response = await axios.post(`https://hng6-r5y3.onrender.com/api/v1/custom/`, { + const response = await axios.post(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/custom/`, { sectionId: 55, title: form?.values?.addList[0]?.title, userId: userId, @@ -174,7 +174,7 @@ function CreateCustomSectionContainer({ onClose, userId }: { onClose: () => void ); if (fields.length < 1) { - const response = await axios.post(`https://hng6-r5y3.onrender.com/api/v1/custom/field`, { + const response = await axios.post(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/custom/field`, { customUserSectionId: sectionForm?.values?.section[0]?.id, fields: fields, }); diff --git a/modules/portfolio/component/portfolioSettingsComponents/DeleteAccount.tsx b/modules/portfolio/component/portfolioSettingsComponents/DeleteAccount.tsx index a2b11b6f4..6c0b40dae 100644 --- a/modules/portfolio/component/portfolioSettingsComponents/DeleteAccount.tsx +++ b/modules/portfolio/component/portfolioSettingsComponents/DeleteAccount.tsx @@ -16,7 +16,7 @@ function DeleteAccount() { }; const userId: string | undefined = auth?.user.id; const deleteAccountMutation = useMutation( - () => axios.delete(`https://hng6-r5y3.onrender.com/api/delete-user-account/${userId}`), + () => axios.delete(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/delete-user-account/${userId}`), { onSuccess: () => { // If the delete operation is successful, you can perform any necessary actions here. diff --git a/modules/portfolio/component/portfolioSettingsComponents/UpdatingProfilePic.tsx b/modules/portfolio/component/portfolioSettingsComponents/UpdatingProfilePic.tsx index 7b24ec543..ab66634be 100644 --- a/modules/portfolio/component/portfolioSettingsComponents/UpdatingProfilePic.tsx +++ b/modules/portfolio/component/portfolioSettingsComponents/UpdatingProfilePic.tsx @@ -17,7 +17,7 @@ const UpdatingProfilePic = () => { const [selectedPics, setSelectedPics] = React.useState(''); const [reload, setReload] = React.useState(false); const { auth } = useAuth(); - const baseUrl = 'https://hng6-r5y3.onrender.com/api/v1/'; + const baseUrl = `${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/`; const { data: userData, isLoading: isUserDataLoading, diff --git a/modules/portfolio/component/portfolioSettingsComponents/notificationsSettings.tsx b/modules/portfolio/component/portfolioSettingsComponents/notificationsSettings.tsx index 04fe0f3fb..9fdfc23e3 100644 --- a/modules/portfolio/component/portfolioSettingsComponents/notificationsSettings.tsx +++ b/modules/portfolio/component/portfolioSettingsComponents/notificationsSettings.tsx @@ -14,7 +14,7 @@ type Props = { }; const getUserNotifications = async (userId: string) => { - const response = await $http.get(`https://hng6-r5y3.onrender.com/api/v1/get-notification-settings/${userId}`); + const response = await $http.get(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/get-notification-settings/${userId}`); if (response.status === 200) { return response.data; } diff --git a/modules/portfolio/component/reference/reference.tsx b/modules/portfolio/component/reference/reference.tsx index 048bd0a87..b1aa6b629 100644 --- a/modules/portfolio/component/reference/reference.tsx +++ b/modules/portfolio/component/reference/reference.tsx @@ -55,7 +55,7 @@ interface EditFormData { position?: string; } -const API_BASE_URL = 'https://hng6-r5y3.onrender.com'; +const API_BASE_URL = (`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio`) as string; const PortfolioReference: React.FC = ({ isOpen, onCloseModal, onSaveModal, userId }) => { // console.log(countryData) diff --git a/modules/portfolio/component/skillModal/SkillsModal.tsx b/modules/portfolio/component/skillModal/SkillsModal.tsx index a503a5a90..f6f5792a4 100644 --- a/modules/portfolio/component/skillModal/SkillsModal.tsx +++ b/modules/portfolio/component/skillModal/SkillsModal.tsx @@ -49,7 +49,7 @@ const SkillModal = ({ onCloseModal, onSaveModal, isOpen, userId }: skillModalPro try { // Make a GET request to the API setIsLoading(true); - const response = await axios.get(`https://hng6-r5y3.onrender.com/api/v1/skills/${userId}`); + const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/skills/${userId}`); const data = response.data.skills; setValues(data); setIsLoading(false); @@ -111,7 +111,7 @@ const SkillModal = ({ onCloseModal, onSaveModal, isOpen, userId }: skillModalPro const getAllSkill = async () => { try { setIsLoading(true); - const response = await fetch(`https://hng6-r5y3.onrender.com/api/v1/portfolio/${slug}`); + const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/portfolio/${slug}`); if (response.ok) { const data = await response.json(); @@ -125,7 +125,7 @@ const SkillModal = ({ onCloseModal, onSaveModal, isOpen, userId }: skillModalPro } }; - const apiUrl = 'https://hng6-r5y3.onrender.com/api/v1/skills/'; + const apiUrl = `${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/skills/`; const requestData = { skills: values?.map((obj) => obj.skill), sectionId: 5, @@ -159,7 +159,7 @@ const SkillModal = ({ onCloseModal, onSaveModal, isOpen, userId }: skillModalPro async function deleteSkillsData(id: number) { try { - const response = await axios.delete(`https://hng6-r5y3.onrender.com/api/v1/skills/${id}}`); + const response = await axios.delete(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/skills/${id}}`); if (response.data.successful) { fetchSkillData(); } diff --git a/modules/portfolio/component/warningModals.tsx b/modules/portfolio/component/warningModals.tsx index 550b77ba8..54f9537a4 100644 --- a/modules/portfolio/component/warningModals.tsx +++ b/modules/portfolio/component/warningModals.tsx @@ -111,7 +111,7 @@ export function SectionDeleteModal({ sectionToDelete }: SectionModalProps) { const notify = () => (toastId.current = toast.success('Section deleted successfully')); //fetch the endpoint for deleting - await fetch(`https://hng6-r5y3.onrender.com/api/v1/profile/details/${userId}`, requestOptions) + await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/profile/details/${userId}`, requestOptions) .then((response) => response.text()) .then((result) => { //Show popup when section is deleted successfully diff --git a/modules/portfolio/context/education-context.tsx b/modules/portfolio/context/education-context.tsx index 6b989f811..689060eda 100644 --- a/modules/portfolio/context/education-context.tsx +++ b/modules/portfolio/context/education-context.tsx @@ -62,7 +62,7 @@ export const EducationModalContextProvider = ({ children }: { children: React.Re const { userId, slug, portfolioUrl } = useContext(Portfolio); const setnewdegree = useCallback(async () => { - fetch('https://hng6-r5y3.onrender.com/api/v1/degree') + fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/degree`) .then((res) => { return res.json(); }) @@ -87,7 +87,7 @@ export const EducationModalContextProvider = ({ children }: { children: React.Re } }; - const API_BASE_URL = 'https://hng6-r5y3.onrender.com/'; + const API_BASE_URL = `${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/`; const [educations, setEducations] = useState([]); const handleEditEducation = async (e: React.FormEvent, educationId: number) => { diff --git a/modules/portfolio/context/work-experience-modal-context.tsx b/modules/portfolio/context/work-experience-modal-context.tsx index 87e71bc39..89d2be52c 100644 --- a/modules/portfolio/context/work-experience-modal-context.tsx +++ b/modules/portfolio/context/work-experience-modal-context.tsx @@ -64,7 +64,7 @@ export const WorkExperienceModalContextProvider = ({ children }: { children: Rea }; const { userId, portfolioUrl, slug } = useContext(Portfolio); - const API_BASE_URL = 'https://hng6-r5y3.onrender.com/'; + const API_BASE_URL = `${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/`; const [workExperiences, setWorkExperiences] = useState([]); const handleEditExperience = async (id: number, e: React.FormEvent) => { diff --git a/modules/shop/ZuriLandingPage.tsx b/modules/shop/ZuriLandingPage.tsx index 5103353ea..ece308ea2 100644 --- a/modules/shop/ZuriLandingPage.tsx +++ b/modules/shop/ZuriLandingPage.tsx @@ -40,9 +40,7 @@ const ZuriLandingPage = () => { if (shop_id) { try { const response = await axios.get(`https://zuriportfolio-shop-internal-api.onrender.com/api/shop/${shop_id}`); - setShop(response.data); - setTimeout(() => { setShowLoader(false); setLoading(false); diff --git a/pages/portfolio/[slug]/index.tsx b/pages/portfolio/[slug]/index.tsx index 54b7678ca..d2901c728 100644 --- a/pages/portfolio/[slug]/index.tsx +++ b/pages/portfolio/[slug]/index.tsx @@ -18,7 +18,7 @@ const View = () => { const getUser = async () => { try { setIsLoading(true); - const response = await fetch(`https://hng6-r5y3.onrender.com/api/v1/portfolio/${urlSlug}`); + const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/portfolio/${urlSlug}`); const data = await response.json(); if (!response.ok) throw new Error(data.error); setUserData({ @@ -76,7 +76,7 @@ const View = () => { const getUser = async () => { try { setIsLoading(true); - const response = await fetch(`https://hng6-r5y3.onrender.com/api/v1/portfolio/${urlSlug}`); + const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/portfolio/${urlSlug}`); const data = await response.json(); if (!response.ok) throw new Error(data.error); setUserData({ diff --git a/pages/settings.tsx b/pages/settings.tsx index 50fe6ef4f..f1ccb0a1c 100644 --- a/pages/settings.tsx +++ b/pages/settings.tsx @@ -80,7 +80,7 @@ const SettingPage = () => { followUpdate: false, newMessages: false, }); - const baseUrl = 'https://hng6-r5y3.onrender.com/api/v1/'; + const baseUrl = `${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/`; const handleNotificationUpdate = async () => { // const anyCheckboxChecked = Object.values(checkboxState).some(value => value === true); setLoading(true); diff --git a/pages/super-admin/assessment/index.tsx b/pages/super-admin/assessment/index.tsx index 27b95d079..154ed195f 100644 --- a/pages/super-admin/assessment/index.tsx +++ b/pages/super-admin/assessment/index.tsx @@ -108,7 +108,7 @@ function Index() { }, [filterParam, assessments]); useEffect(() => { - const apiUrl = 'https://hng6-r5y3.onrender.com/api/v1/tracks'; + const apiUrl = `${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/tracks`; fetch(apiUrl) .then((response) => { diff --git a/pages/user/customer-purchase-dashboard/index.tsx b/pages/user/customer-purchase-dashboard/index.tsx index bbc22942b..b3ee88e45 100644 --- a/pages/user/customer-purchase-dashboard/index.tsx +++ b/pages/user/customer-purchase-dashboard/index.tsx @@ -16,6 +16,7 @@ import { getAllPurchases, getSearchedData } from '../../../http/customerPurchase import { withUserAuth } from '../../../helpers/withAuth'; import { formatToNigerianNaira } from '../../../helpers/formatCurrency'; import Loader from '../../../components/Loader/loader2'; +import SEO from '../../../components/SEO'; // Define a type for the data export type PurchaseData = { @@ -229,6 +230,8 @@ const MyPage: React.FC = () => { }; return ( + <> +
@@ -402,6 +405,7 @@ const MyPage: React.FC = () => { />
+ ); }; From 7abde244c1c855f3a949807eb40c4ef9db2b4077 Mon Sep 17 00:00:00 2001 From: homoakin619 Date: Mon, 11 Dec 2023 10:31:52 +0100 Subject: [PATCH 2/2] updated portfolio routes and fixed issue with fetching user id on settings page --- components/Navbars/TopBar.tsx | 1 - http/auth.ts | 3 ++- http/axios.ts | 2 +- http/checkout.ts | 2 +- .../ProductWeThoughtMightInterestYou.tsx | 2 +- .../portfolio/component/modals/edit-profile.tsx | 13 +++++++++---- .../modals/project-modal/all-projects-modal.tsx | 2 +- .../project-modal/project-section-modal.tsx | 2 +- .../UpdatingProfilePic.tsx | 15 ++++++++------- pages/index.tsx | 2 ++ pages/marketplace/index.tsx | 3 +++ pages/settings.tsx | 7 ++++--- 12 files changed, 33 insertions(+), 21 deletions(-) diff --git a/components/Navbars/TopBar.tsx b/components/Navbars/TopBar.tsx index db775fcb3..f7475b922 100644 --- a/components/Navbars/TopBar.tsx +++ b/components/Navbars/TopBar.tsx @@ -106,7 +106,6 @@ function TopBar(props: { activePage: string; showDashBorad: boolean }) { setToggle(false); } if (notificationsRef.current && !notificationsRef.current.contains(targetNode)) { - console.log(notificationsRef.current); setNotificationMenu(false); } } diff --git a/http/auth.ts b/http/auth.ts index 3a375f5a8..e4924b6e5 100644 --- a/http/auth.ts +++ b/http/auth.ts @@ -2,6 +2,7 @@ import axios from 'axios'; const AUTH_HTTP_URL = 'https://zuri-auth.up.railway.app/api/auth/api/auth'; const AUTH_HTTP_URL_2 = 'https://staging.zuri.team/api/auth/api'; +const _AUTH_HTTP_URL = 'https://zuri-auth.up.railway.app/api/auth/api'; const $http = axios.create({ baseURL: AUTH_HTTP_URL, @@ -11,7 +12,7 @@ const $http = axios.create({ }); const $http_2 = axios.create({ - baseURL: AUTH_HTTP_URL_2, + baseURL: _AUTH_HTTP_URL, timeout: 30000, headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/http/axios.ts b/http/axios.ts index 82cb340eb..7920b9e9e 100644 --- a/http/axios.ts +++ b/http/axios.ts @@ -6,7 +6,7 @@ const $http = axios.create({ headers: { 'Content-Type': 'application/json', credentials: 'include', - // 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Origin': '*', }, // withCredentials: false, }); diff --git a/http/checkout.ts b/http/checkout.ts index 88f4adc33..5ca5da701 100644 --- a/http/checkout.ts +++ b/http/checkout.ts @@ -6,7 +6,7 @@ import axios from 'axios'; // export const CART_ENDPOINT = "https://zuri-cart-checkout.onrender.com/api/v1/checkout_cart" -export const CART_ENDPOINT = "http://localhost:8000/api/v1/checkout_cart" +export const CART_ENDPOINT = process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL + "/checkout"; export const STAGING_URL = process.env.NEXT_PUBLIC_APP_STAGING_URL || 'https://staging.zuri.team'; export const RECENTLY_VIEWED_ENDPOINT = 'https://staging.zuri.team/api/marketplace/v1/recently-viewed'; diff --git a/modules/marketplace/component/ProductWeThoughtMightInterestYou.tsx b/modules/marketplace/component/ProductWeThoughtMightInterestYou.tsx index 928807694..5ab74cb65 100644 --- a/modules/marketplace/component/ProductWeThoughtMightInterestYou.tsx +++ b/modules/marketplace/component/ProductWeThoughtMightInterestYou.tsx @@ -30,7 +30,7 @@ export default function ProductWeThoughtMightInterestYou({ id }: any) { }, [url]); const addToCart = async (ids: string) => { - const apiUrl = `${CART_ENDPOINT}/api/carts`; + const apiUrl = `${CART_ENDPOINT}/carts`; if (auth?.token) { try { const response = await axios.post( diff --git a/modules/portfolio/component/modals/edit-profile.tsx b/modules/portfolio/component/modals/edit-profile.tsx index 749ce585f..05215c716 100644 --- a/modules/portfolio/component/modals/edit-profile.tsx +++ b/modules/portfolio/component/modals/edit-profile.tsx @@ -34,11 +34,14 @@ const EditProfile = () => { useEffect(() => { - + console.log("Logging before fetch") const fetchData = async () => { try { setIsLoading(true); + console.log('Logging this one'); const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/users/${userId}`); + console.log('after logging'); + const userData = await response.json(); @@ -96,7 +99,9 @@ const EditProfile = () => { matchingTrack = availableTracks.find((track: any) => track.track === selectedTrack); if (matchingTrack) { setIsLoading(true); - const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/users/${userId}`, { + console.log("Logging second one"); + const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL}/portfolio/users/${userId}`, + { method: 'PUT', headers: { 'Content-Type': 'application/json', @@ -253,14 +258,14 @@ const EditProfile = () => { {/* */}
- ​ ​ + - ​ +