Skip to content

Commit

Permalink
feat: ✨ improve need help price card
Browse files Browse the repository at this point in the history
  • Loading branch information
lucca180 committed Jan 31, 2025
1 parent 2350732 commit 80a2624
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 25 deletions.
59 changes: 36 additions & 23 deletions components/Price/ItemPriceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,14 @@ const ItemPriceCard = (props: Props) => {

if (!hasTrades) return false;

if (!price) return true;
const res = {
needPricing: priceStatus.waitingTrades.needPricing,
needVoting: priceStatus.waitingTrades.needVoting,
};

if (differenceInCalendarDays(new Date(), new Date(price.addedAt)) > 15 && hasTrades)
return true;
if (!price) return res;

if (differenceInCalendarDays(new Date(), new Date(price.addedAt)) > 15 && hasTrades) return res;

return false;
}, [user, priceStatus, price]);
Expand Down Expand Up @@ -207,7 +211,7 @@ const ItemPriceCard = (props: Props) => {

<CardBase color={rgbColor} title={t('ItemPage.price-overview')}>
<Flex gap={3} flexFlow="column">
{needHelp && <HelpNeeded item={item} />}
{!!needHelp && <HelpNeeded item={item} helpData={needHelp} />}
<Flex
flexFlow={{ base: 'column', md: 'row' }}
alignItems={{ base: 'inherit', md: 'center' }}
Expand Down Expand Up @@ -377,10 +381,11 @@ export default ItemPriceCard;

type HelpNeededProps = {
item: ItemData;
helpData: { needPricing: number; needVoting: number };
};

const HelpNeeded = (props: HelpNeededProps) => {
const { item } = props;
const { item, helpData } = props;
const [hideHelp, setHideHelp] = useState(false);
const t = useTranslations();

Expand All @@ -399,24 +404,32 @@ const HelpNeeded = (props: HelpNeededProps) => {
>
{t('Feedback.price-update-txt')}
<HStack justifyContent={'center'}>
<Button
as={Link}
href={`/feedback/trades?target=${item.name}`}
prefetch={false}
target="_blank"
size="sm"
>
{t('Feedback.price-trade-lots')}
</Button>
<Button
as={Link}
href={`/feedback/vote?target=${item.name}`}
prefetch={false}
target="_blank"
size="sm"
>
{t('Feedback.vote-suggestions')}
</Button>
{!!helpData.needPricing && (
<Button
as={Link}
href={`/feedback/trades?target=${item.name}`}
prefetch={false}
target="_blank"
size="sm"
>
{t('Feedback.price-x-trade-lots', {
x: helpData.needPricing,
})}
</Button>
)}
{!!helpData.needVoting && (
<Button
as={Link}
href={`/feedback/vote?target=${item.name}`}
prefetch={false}
target="_blank"
size="sm"
>
{t('Feedback.vote-x-suggestions', {
x: helpData.needVoting,
})}
</Button>
)}
</HStack>
</AlertDescription>
<CloseButton
Expand Down
4 changes: 3 additions & 1 deletion translation/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,9 @@
"suggestion-voting-txt": "Vote on suggestions from other users (or from our system)",
"bug-helper-text": "If you are reporting a bug, provide as many details as possible about what happened and when.",
"we-need-your-help": "We need your help!",
"price-update-txt": "We detected that this price might be incorrect or outdated and we have new data waiting to be priced"
"price-update-txt": "We detected that this price might be incorrect or outdated and we have new data waiting to be priced",
"price-x-trade-lots": "Price {x} Trade Lots",
"vote-x-suggestions": "Vote {x} Suggestions"
},
"Restock": {
"restock-info": "Restock Info",
Expand Down
4 changes: 3 additions & 1 deletion translation/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,9 @@
"suggestion-voting-txt": "Vote na sugestões de outros usuários (ou do nosso sistema)",
"bug-helper-text": "Se você está reportando um bug, coloque a maior quantidade de detalhes possível sobre o que aconteceu e quando.",
"price-update-txt": "Detectamos que este preço pode estar incorreto ou desatualizado e temos novos dados aguardando para serem precificados",
"we-need-your-help": "Precisamos da sua ajuda!"
"we-need-your-help": "Precisamos da sua ajuda!",
"price-x-trade-lots": "Precificar {x} Lotes de Troca",
"vote-x-suggestions": "Votar em {x} Sugestões"
},
"Lists": {
"add-to-list": "Adicionar a Lista",
Expand Down

0 comments on commit 80a2624

Please sign in to comment.