Skip to content

Commit

Permalink
Revert "Fix toggling of adding your cube to the featured queue."
Browse files Browse the repository at this point in the history
This reverts commit beec154.

A separate change (that had no conflicts) resulted in a logical conflict
of GET vs POST. Reverting back to frontend and backend aligned on GET
action.
  • Loading branch information
KaelenProctor committed Feb 8, 2025
1 parent 346a9e3 commit 773cc04
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/client/components/cube/CubeOverviewCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useContext, useState } from 'react';
import React, { useContext, useState } from 'react';

import { EyeClosedIcon, LinkExternalIcon } from '@primer/octicons-react';

Expand Down Expand Up @@ -95,22 +95,6 @@ const CubeOverviewCard: React.FC<CubeOverviewCardProps> = ({ followed, priceOwne
});
};

const toggleFeatured = useCallback(() => {
const action = cube.featured ? 'unfeature' : 'feature';
csrfFetch(`/cube/${action}/${cube.id}`, {
method: 'POST',
headers: {},
}).then((response) => {
if (!response.ok) {
// eslint-disable-next-line no-console -- Debugging
console.error(response);
} else {
//Reload the page to see new state. TODO: Update state directly
window.location.reload();
}
});
}, [csrfFetch, cube]);

return (
<Flexbox direction="col" gap="2">
<Row>
Expand Down Expand Up @@ -202,7 +186,12 @@ const CubeOverviewCard: React.FC<CubeOverviewCardProps> = ({ followed, priceOwne
</>
)}
{user && user.roles && user.roles.includes('Admin') && (
<Button color="accent" disabled={cube.visibility !== 'pu'} onClick={toggleFeatured}>
<Button
color="accent"
type="link"
disabled={cube.visibility !== 'pu'}
href={`/cube/${cube.featured ? 'unfeature/' : 'feature/'}${cube.id}`}
>
{cube.featured ? 'Remove from featured' : 'Add to featured'}
</Button>
)}
Expand Down

0 comments on commit 773cc04

Please sign in to comment.