Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/dist/assets/index-CbSqCWf5.js

Large diffs are not rendered by default.

34 changes: 16 additions & 18 deletions client/src/components/accounts/ListingCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useRef, useEffect } from 'react';
import { NewListing } from '../../types/types';
import { Listing } from '../../types/types';
import ListingForm from './ListingForm';
import { departmentCategories } from '../../utils/departmentNames';
import { createListing } from '../../utils/apiCleaner';
Expand All @@ -9,15 +9,14 @@ import { useContext } from "react";
import UserContext from "../../contexts/UserContext";

interface ListingCardProps {
listing: NewListing;
listing: Listing;
favListingsIds: string[];
updateFavorite: (listing: NewListing, listingId: string, favorite: boolean) => void;
updateListing: (newListing: NewListing) => void;
postListing: (newListing: NewListing) => void;
postNewListing: (newListing: NewListing) => void;
updateFavorite: (listing: Listing, listingId: string, favorite: boolean) => void;
updateListing: (listing: Listing) => void;
postListing: (listing: Listing) => void;
clearCreatedListing: () => void;
deleteListing: (listing: NewListing) => void;
openModal: (listing: NewListing) => void;
deleteListing: (listing: Listing) => void;
openModal: (listing: Listing) => void;
globalEditing: boolean;
setGlobalEditing: (editing: boolean) => void;
editable: boolean;
Expand All @@ -30,7 +29,6 @@ const ListingCard = ({
updateFavorite,
updateListing,
postListing,
postNewListing,
clearCreatedListing,
deleteListing,
openModal,
Expand All @@ -51,7 +49,7 @@ const ListingCard = ({
const canDelete = user && (user.netId === listing.ownerId);

// Store the original listing before editing begins.
const originalListingRef = useRef<NewListing | null>(null);
const originalListingRef = useRef<Listing | null>(null);

const departmentColors = [
"bg-blue-200",
Expand Down Expand Up @@ -170,11 +168,11 @@ const ListingCard = ({
e.stopPropagation();
if (archived) {
setArchived(false);
axios.put(`/newListings/${listing.id}/unarchive`, { withCredentials: true })
axios.put(`/listings/${listing.id}/unarchive`, { withCredentials: true })
.then((response) => {
const responseListing = response.data.listing;
const newListing = createListing(responseListing);
updateListing(newListing);
const listing = createListing(responseListing);
updateListing(listing);
})
.catch((error) => {
setArchived(true);
Expand All @@ -189,11 +187,11 @@ const ListingCard = ({
});
} else {
setArchived(true);
axios.put(`/newListings/${listing.id}/archive`, { withCredentials: true })
axios.put(`/listings/${listing.id}/archive`, { withCredentials: true })
.then((response) => {
const responseListing = response.data.listing;
const newListing = createListing(responseListing);
updateListing(newListing);
const listing = createListing(responseListing);
updateListing(listing);
})
.catch((error) => {
setArchived(false);
Expand Down Expand Up @@ -388,8 +386,8 @@ const ListingCard = ({
setEditing(false);
setGlobalEditing(false);
}}
onCreate={(newListing) => {
postNewListing(newListing);
onCreate={(listing) => {
postListing(listing);
setEditing(false);
setGlobalEditing(false);
}}
Expand Down
46 changes: 23 additions & 23 deletions client/src/components/accounts/ListingForm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react';
import { NewListing } from '../../../types/types';
import { Listing } from '../../../types/types';
import { departmentNames } from '../../../utils/departmentNames';
import swal from "sweetalert";
import axios from '../../../utils/axios';
Expand All @@ -17,12 +17,12 @@ import { useContext } from "react";
import UserContext from "../../../contexts/UserContext";

interface ListingFormProps {
listing: NewListing;
listing: Listing;
isCreated: boolean;
onLoad: (updatedListing: NewListing, success: boolean) => void;
onLoad: (updatedListing: Listing, success: boolean) => void;
onCancel?: () => void;
onSave?: (updatedListing: NewListing) => void;
onCreate?: (newListing: NewListing) => void;
onSave?: (updatedListing: Listing) => void;
onCreate?: (listing: Listing) => void;
}

const ListingForm = ({ listing, isCreated, onLoad, onCancel, onSave, onCreate }: ListingFormProps) => {
Expand Down Expand Up @@ -61,31 +61,31 @@ const ListingForm = ({ listing, isCreated, onLoad, onCancel, onSave, onCreate }:
useEffect(() => {
if (!isCreated) {
setLoading(true);
axios.get(`/newListings/${listing.id}`, { withCredentials: true }).then((response) => {
axios.get(`/listings/${listing.id}`, { withCredentials: true }).then((response) => {
if (!response.data.listing) {
console.error(`Response, but no listing ${listing.id}:`, response.data);
onLoad(listing, false);
return;
}
const newListing = createListing(response.data.listing);
const listing = createListing(response.data.listing);
// Update state with new listing data
setTitle(newListing.title);
setProfessorNames([...newListing.professorNames]);
setOwnerName(`${newListing.ownerFirstName} ${newListing.ownerLastName}`);
setDepartments([...newListing.departments]);
setEmails([...newListing.emails]);
setOwnerEmail(newListing.ownerEmail);
setWebsites(newListing.websites ? [...newListing.websites] : []);
setDescription(newListing.description);
setKeywords(newListing.keywords ? [...newListing.keywords] : []);
setEstablished(newListing.established || '');
setHiringStatus(newListing.hiringStatus);
setArchived(newListing.archived);
setTitle(listing.title);
setProfessorNames([...listing.professorNames]);
setOwnerName(`${listing.ownerFirstName} ${listing.ownerLastName}`);
setDepartments([...listing.departments]);
setEmails([...listing.emails]);
setOwnerEmail(listing.ownerEmail);
setWebsites(listing.websites ? [...listing.websites] : []);
setDescription(listing.description);
setKeywords(listing.keywords ? [...listing.keywords] : []);
setEstablished(listing.established || '');
setHiringStatus(listing.hiringStatus);
setArchived(listing.archived);

onLoad(newListing, true);
onLoad(listing, true);

setAvailableDepartments(
departmentNames.filter(dept => !newListing.departments.includes(dept)).sort()
departmentNames.filter(dept => !listing.departments.includes(dept)).sort()
);
setLoading(false);
}).catch((error) => {
Expand All @@ -102,7 +102,7 @@ const ListingForm = ({ listing, isCreated, onLoad, onCancel, onSave, onCreate }:

// Live update preview when editing or creating a listing
useEffect(() => {
const updatedListing: NewListing = {
const updatedListing: Listing = {
...listing,
title,
professorNames,
Expand Down Expand Up @@ -142,7 +142,7 @@ const ListingForm = ({ listing, isCreated, onLoad, onCancel, onSave, onCreate }:

// Only proceed if no errors
if (Object.keys(filteredErrors).length === 0) {
const updatedListing: NewListing = {
const updatedListing: Listing = {
...listing,
title,
professorIds,
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/accounts/ListingModal.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { useEffect, useState, useContext } from 'react';
import { NewListing } from '../../types/types';
import { Listing } from '../../types/types';
import { departmentCategories } from '../../utils/departmentNames';
import UserContext from "../../contexts/UserContext";

interface ListingModalProps {
isOpen: boolean;
onClose: () => void;
listing: NewListing;
listing: Listing;
favListingsIds: string[];
updateFavorite: (listing: NewListing, listingId: string, favorite: boolean) => void;
updateFavorite: (listing: Listing, listingId: string, favorite: boolean) => void;
}

const ListingModal = ({ isOpen, onClose, listing, favListingsIds, updateFavorite }: ListingModalProps) => {
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/home/ListingCard.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React, { useState, useRef, useEffect } from 'react';
import { NewListing } from '../../types/types';
import { Listing } from '../../types/types';
import { departmentCategories } from '../../utils/departmentNames';
import axios from "../../utils/axios";
import swal from "sweetalert";
import { useContext } from "react";
import UserContext from "../../contexts/UserContext";

interface ListingCardProps {
listing: NewListing;
listing: Listing;
favListingsIds: string[];
updateFavorite: (listingId: string, favorite: boolean) => void;
openModal: (listing: NewListing) => void;
openModal: (listing: Listing) => void;
}

const ListingCard = ({ listing, favListingsIds, updateFavorite, openModal }: ListingCardProps) => {
Expand Down Expand Up @@ -129,7 +129,7 @@ const ListingCard = ({ listing, favListingsIds, updateFavorite, openModal }: Lis

const handleListingClick = () => {
if (!viewed) {
axios.put(`newListings/${listing.id}/addView`, {withCredentials: true}).catch((error) => {
axios.put(`listings/${listing.id}/addView`, {withCredentials: true}).catch((error) => {
console.log('Could not add view for listing');
listing.views = listing.views - 1;
})
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/home/ListingModal.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useEffect, useState, useContext } from 'react';
import { NewListing } from '../../types/types';
import { Listing } from '../../types/types';
import { departmentCategories } from '../../utils/departmentNames';
import UserContext from '../../contexts/UserContext';

interface ListingModalProps {
isOpen: boolean;
onClose: () => void;
listing: NewListing;
listing: Listing;
favListingsIds: string[];
updateFavorite: (listingId: string, favorite: boolean) => void;
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/home/ListingsCardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import ListingsModal from '../home/ListingModal';
import ListingCard from './ListingCard';
import SortDropdown from './SortDropdown';
import PulseLoader from "react-spinners/PulseLoader";
import { NewListing } from '../../types/types';
import { Listing } from '../../types/types';

type ListingsCardListProps = {
loading: Boolean;
searchExhausted: Boolean;
setPage: React.Dispatch<React.SetStateAction<number>>;
listings: NewListing[];
listings: Listing[];
sortableKeys: string[];
sortBy: string;
setSortBy: (sortBy: string) => void;
Expand Down Expand Up @@ -73,7 +73,7 @@ export default function ListingsCardList({
{value: 'title', label: 'Sort by: Lab Title'}
];

const openModalForListing = (listing: NewListing) => {
const openModalForListing = (listing: Listing) => {
setSelectedListingId(listing.id);
setModalOpen(true);
};
Expand Down
12 changes: 6 additions & 6 deletions client/src/components/home/SearchHub.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useRef, KeyboardEvent, useEffect } from 'react';
import { NewListing } from '../../types/types';
import { Listing } from '../../types/types';
import axios from 'axios';
import swal from 'sweetalert';
import { createListing } from '../../utils/apiCleaner';
Expand All @@ -8,8 +8,8 @@ import SortDropdown from './SortDropdown';

interface SearchHubProps {
allDepartments: string[];
resetListings: (newListings: NewListing[]) => void;
addListings: (newListings: NewListing[]) => void;
resetListings: (listings: Listing[]) => void;
addListings: (listings: Listing[]) => void;
setIsLoading: React.Dispatch<React.SetStateAction<Boolean>>;
sortBy: string;
sortOrder: number;
Expand Down Expand Up @@ -203,11 +203,11 @@ const SearchHub = ({
if (sortBy === 'default') {
url =
backendBaseURL +
`/newListings/search?query=${formattedQuery}&page=${page}&pageSize=${pageSize}`;
`/listings/search?query=${formattedQuery}&page=${page}&pageSize=${pageSize}`;
} else {
url =
backendBaseURL +
`/newListings/search?query=${formattedQuery}&sortBy=${sortBy}&sortOrder=${sortOrder}&page=${page}&pageSize=${pageSize}`;
`/listings/search?query=${formattedQuery}&sortBy=${sortBy}&sortOrder=${sortOrder}&page=${page}&pageSize=${pageSize}`;
}

if (formattedDepartments) {
Expand All @@ -219,7 +219,7 @@ const SearchHub = ({
axios
.get(url, { withCredentials: true })
.then((response) => {
const responseListings: NewListing[] = response.data.results.map(function (
const responseListings: Listing[] = response.data.results.map(function (
elem: any
) {
return createListing(elem);
Expand Down
Loading