Skip to content

Commit

Permalink
fix: bug with leftover state
Browse files Browse the repository at this point in the history
  • Loading branch information
ldeluigi committed Jan 10, 2025
1 parent 819b9d4 commit 26e33c9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/pages/combo/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const Combo: React.FC<Props> = ({ combo, alternatives, previewImageUrl }) => {
useEffect(() => {
setVariants([]);
setVariantsLoading(false);
setVariantCount((combo?.variantCount ?? 1) - 1);
}, [combo]);
if ((combo?.variantCount ?? 0) > 1 && combo && variants.length == 0 && !variantsLoading) {
loadVariants(combo);
Expand Down Expand Up @@ -277,8 +278,8 @@ const Combo: React.FC<Props> = ({ combo, alternatives, previewImageUrl }) => {
variantsLoading
? []
: [
`Below you find ${variants.length == variantCount ? `all ${variants.length}` : `${variants.length} out of ${variantCount} total`} variants of this combo, with the alternative cards highlighted.`,
]
`Below you find ${variants.length == variantCount ? `all ${variants.length}` : `${variants.length} out of ${variantCount} total`} variants of this combo, with the alternative cards highlighted.`,
]
}
/>
{variantsLoading && <Loader />}
Expand Down Expand Up @@ -392,8 +393,8 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
});
const alternatives = results
? results.results.included
.concat(results.results.almostIncluded)
.concat(results.results.almostIncludedByAddingColors)
.concat(results.results.almostIncluded)
.concat(results.results.almostIncludedByAddingColors)
: [];
if (alternatives.length > 0) {
return {
Expand Down

0 comments on commit 26e33c9

Please sign in to comment.