diff --git a/client/src/pages/project-detail/item-prices-modal.tsx b/client/src/pages/project-detail/item-prices-modal.tsx
index e4bd09c..1f96afb 100644
--- a/client/src/pages/project-detail/item-prices-modal.tsx
+++ b/client/src/pages/project-detail/item-prices-modal.tsx
@@ -5,10 +5,16 @@ import { ItemPricesPanel } from './item-prices-panel';
interface ItemPricesModalProps {
isOpen: boolean;
item: Item | null;
+ projectId: string | undefined;
onClose: () => void;
}
-export function ItemPricesModal({ isOpen, item, onClose }: ItemPricesModalProps) {
+export function ItemPricesModal({
+ isOpen,
+ item,
+ projectId,
+ onClose
+}: ItemPricesModalProps) {
useEffect(() => {
if (!isOpen) {
return;
@@ -53,7 +59,7 @@ export function ItemPricesModal({ isOpen, item, onClose }: ItemPricesModalProps)
Edit Item Prices
{itemTitle}
-
+
diff --git a/client/src/pages/project-detail/item-prices-panel.tsx b/client/src/pages/project-detail/item-prices-panel.tsx
index bb4e086..796dce8 100644
--- a/client/src/pages/project-detail/item-prices-panel.tsx
+++ b/client/src/pages/project-detail/item-prices-panel.tsx
@@ -6,9 +6,10 @@ const priceConditionOptions: PriceCondition[] = ['new', 'used'];
interface ItemPricesPanelProps {
itemId: string;
+ projectId: string | undefined;
}
-export function ItemPricesPanel({ itemId }: ItemPricesPanelProps) {
+export function ItemPricesPanel({ itemId, projectId }: ItemPricesPanelProps) {
const [condition, setCondition] = useState('new');
const [amount, setAmount] = useState('');
const [currency, setCurrency] = useState('USD');
@@ -17,7 +18,7 @@ export function ItemPricesPanel({ itemId }: ItemPricesPanelProps) {
const [formError, setFormError] = useState(null);
const pricesQuery = useItemPricesQuery(itemId, true);
- const createPriceMutation = useCreateItemPriceMutation(itemId);
+ const createPriceMutation = useCreateItemPriceMutation(itemId, projectId);
const prices = pricesQuery.data?.data ?? [];
const creationError = useMemo(
diff --git a/client/src/pages/project-detail/project-detail-page.tsx b/client/src/pages/project-detail/project-detail-page.tsx
index 01b31ee..41f5c23 100644
--- a/client/src/pages/project-detail/project-detail-page.tsx
+++ b/client/src/pages/project-detail/project-detail-page.tsx
@@ -314,6 +314,7 @@ export function ProjectDetailPage() {
diff --git a/client/src/query/item-prices.ts b/client/src/query/item-prices.ts
index 2eca526..939a88f 100644
--- a/client/src/query/item-prices.ts
+++ b/client/src/query/item-prices.ts
@@ -1,10 +1,11 @@
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import {
createItemPrice,
fetchItemPrices,
type CreateItemPricePayload,
type ItemPricesResponse
} from '../api/item-prices';
-import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import { projectsKeys } from './projects';
const DEFAULT_LIMIT = 50;
@@ -23,7 +24,10 @@ export const useItemPricesQuery = (
queryFn: ({ signal }) => fetchItemPrices(itemId!, { limit: DEFAULT_LIMIT, offset: 0, signal })
});
-export const useCreateItemPriceMutation = (itemId: string | undefined) => {
+export const useCreateItemPriceMutation = (
+ itemId: string | undefined,
+ projectId: string | undefined
+) => {
const queryClient = useQueryClient();
return useMutation({
@@ -39,6 +43,10 @@ export const useCreateItemPriceMutation = (itemId: string | undefined) => {
return;
}
queryClient.invalidateQueries({ queryKey: itemPricesKeys.list(itemId) });
+ if (projectId) {
+ queryClient.invalidateQueries({ queryKey: projectsKeys.items(projectId) });
+ queryClient.invalidateQueries({ queryKey: projectsKeys.detail(projectId) });
+ }
}
});
};