mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
fix: device purchase guard condition and cache invalidation
- Fix guard: available === false alone now properly gates the unavailability message (was incorrectly AND-ed with !max_device_limit) - Remove dead code block that was unreachable after guard fix - Add device-price cache invalidation after successful purchase
This commit is contained in:
@@ -276,6 +276,7 @@ export default function Subscription() {
|
|||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['subscription'] });
|
queryClient.invalidateQueries({ queryKey: ['subscription'] });
|
||||||
queryClient.invalidateQueries({ queryKey: ['devices'] });
|
queryClient.invalidateQueries({ queryKey: ['devices'] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['device-price'] });
|
||||||
setShowDeviceTopup(false);
|
setShowDeviceTopup(false);
|
||||||
setDevicesToAdd(1);
|
setDevicesToAdd(1);
|
||||||
},
|
},
|
||||||
@@ -1196,7 +1197,7 @@ export default function Subscription() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Check if completely unavailable (no subscription, price not set, etc.) */}
|
{/* Check if completely unavailable (no subscription, price not set, etc.) */}
|
||||||
{devicePriceData?.available === false && !devicePriceData?.max_device_limit ? (
|
{devicePriceData?.available === false ? (
|
||||||
<div className="py-4 text-center text-sm text-dark-400">
|
<div className="py-4 text-center text-sm text-dark-400">
|
||||||
{devicePriceData.reason ||
|
{devicePriceData.reason ||
|
||||||
t('subscription.additionalOptions.devicesUnavailable')}
|
t('subscription.additionalOptions.devicesUnavailable')}
|
||||||
@@ -1245,13 +1246,6 @@ export default function Subscription() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Show reason if can't add requested amount */}
|
|
||||||
{devicePriceData?.available === false && devicePriceData?.reason && (
|
|
||||||
<div className="rounded-lg bg-warning-500/10 p-3 text-center text-sm text-warning-400">
|
|
||||||
{devicePriceData.reason}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Price info - only when available */}
|
{/* Price info - only when available */}
|
||||||
{devicePriceData?.available && devicePriceData.price_per_device_label && (
|
{devicePriceData?.available && devicePriceData.price_per_device_label && (
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
|
|||||||
Reference in New Issue
Block a user