diff --git a/app/frontend/src/javascript/components/pricing/configure-extended-price-button.tsx b/app/frontend/src/javascript/components/pricing/configure-extended-price-button.tsx index 66705ccc0..95f3a9149 100644 --- a/app/frontend/src/javascript/components/pricing/configure-extended-price-button.tsx +++ b/app/frontend/src/javascript/components/pricing/configure-extended-price-button.tsx @@ -41,7 +41,7 @@ export const ConfigureExtendedPriceButton: React.FC { onSuccess(message); PriceAPI.index({ group_id: groupId, priceable_id: priceableId, priceable_type: priceableType }) - .then(data => setExtendedPrices(data)) + .then(data => setExtendedPrices(data.filter(p => p.duration !== 60))) .catch(error => onError(error)); }; @@ -59,7 +59,7 @@ export const ConfigureExtendedPriceButton: React.FC {showList &&
    diff --git a/app/frontend/src/javascript/components/pricing/spaces-pricing.tsx b/app/frontend/src/javascript/components/pricing/spaces-pricing.tsx index b2f6dbc35..3d33cf60d 100644 --- a/app/frontend/src/javascript/components/pricing/spaces-pricing.tsx +++ b/app/frontend/src/javascript/components/pricing/spaces-pricing.tsx @@ -8,6 +8,7 @@ import SpaceAPI from '../../api/space'; import GroupAPI from '../../api/group'; import { Group } from '../../models/group'; import { IApplication } from '../../models/application'; +import { Space } from '../../models/space'; import { EditablePrice } from './editable-price'; import { ConfigureExtendedPriceButton } from './configure-extended-price-button'; import PriceAPI from '../../api/price'; @@ -28,9 +29,9 @@ interface SpacesPricingProps { const SpacesPricing: React.FC = ({ onError, onSuccess }) => { const { t } = useTranslation('admin'); - const [spaces, setSpaces] = useState>(null); + const [spaces, setSpaces] = useState>(null); const [groups, setGroups] = useState>(null); - const [prices, updatePrices] = useImmer>(null); + const [prices, updatePrices] = useImmer>([]); // retrieve the initial data useEffect(() => { @@ -62,8 +63,14 @@ const SpacesPricing: React.FC = ({ onError, onSuccess }) => return FormatLib.price(price); }; + /** + * Find the price matching the given criterion + */ + const findPriceBy = (spaceId, groupId): Price => { + return prices.find(price => price.priceable_id === spaceId && price.group_id === groupId); + }; const findPricesBy = (spaceId, groupId): Array => { - return prices.filter(price => price.priceable_id === spaceId && price.group_id === groupId); + return prices.filter(price => price.priceable_id === spaceId && price.group_id === groupId && price.duration !== 60); }; /** @@ -107,7 +114,7 @@ const SpacesPricing: React.FC = ({ onError, onSuccess }) => {spaces?.map(space => {space.name} {groups?.map(group => - {prices && } + {prices && }