Skip to content

Commit

Permalink
chore: changed frontend definitions
Browse files Browse the repository at this point in the history
Changed to match changes on the backend
  • Loading branch information
paulushcgcj committed Nov 4, 2024
1 parent 9e4c8a1 commit 9700a70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
} from "../../../../utils/fileConversions";
import { Tooltip } from "@carbon/react";
import { useNavigate } from "react-router-dom";
import { usePostViewedOpening } from "../../../../services/queries/dashboard/dashboardQueries";
import { usePutViewedOpening } from "../../../../services/queries/dashboard/dashboardQueries";

interface ISearchScreenDataTable {
rows: OpeningsSearch[];
Expand Down Expand Up @@ -78,7 +78,7 @@ const SearchScreenDataTable: React.FC<ISearchScreenDataTable> = ({
const [selectedRows, setSelectedRows] = useState<string[]>([]); // State to store selected rows
const [toastText, setToastText] = useState<string | null>(null);
const [openingDetails, setOpeningDetails] = useState(false);
const { mutate: markAsViewedOpening, isError, error } = usePostViewedOpening();
const { mutate: markAsViewedOpening, isError, error } = usePutViewedOpening();
const navigate = useNavigate();

useEffect(() => {
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/services/queries/dashboard/dashboardQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import { env } from "../../../env";

const backendUrl = env.VITE_BACKEND_URL;

// Function to send the POST request
export const postViewedOpening = async (openingId: string): Promise<any> => {
// Function to send the PUT request
export const putViewedOpening = async (openingId: string): Promise<any> => {
const authToken = getAuthIdToken();
try {
const response = await axios.post(`${backendUrl}/api/users/recent/${openingId}`, null, {
const response = await axios.put(`${backendUrl}/api/openings/recent/${openingId}`, null, {
headers: {
Authorization: `Bearer ${authToken}`
}
});
return response.data;
} catch (error:any) {
} catch (error: any) {
if (error.response?.status === 403) {
throw new Error("Forbidden: You don't have permission to view this opening.");
} else {
Expand All @@ -28,9 +28,9 @@ export const postViewedOpening = async (openingId: string): Promise<any> => {
};

// Hook for using the mutation
export const usePostViewedOpening = () => {
export const usePutViewedOpening = () => {
return useMutation({
mutationFn: (openingId: string) => postViewedOpening(openingId)
mutationFn: (openingId: string) => putViewedOpening(openingId)
});
};

Expand Down

0 comments on commit 9700a70

Please sign in to comment.