|
@@ -31,7 +31,16 @@ import { toast } from 'sonner';
|
|
|
import { CreateProductVariantsDialog } from './components/create-product-variants-dialog.js';
|
|
import { CreateProductVariantsDialog } from './components/create-product-variants-dialog.js';
|
|
|
import { ProductOptionGroupBadge } from './components/product-option-group-badge.js';
|
|
import { ProductOptionGroupBadge } from './components/product-option-group-badge.js';
|
|
|
import { ProductVariantsTable } from './components/product-variants-table.js';
|
|
import { ProductVariantsTable } from './components/product-variants-table.js';
|
|
|
-import { createProductDocument, productDetailDocument, updateProductDocument } from './products.graphql.js';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ assignProductsToChannelDocument,
|
|
|
|
|
+ createProductDocument,
|
|
|
|
|
+ productDetailDocument,
|
|
|
|
|
+ removeProductsFromChannelDocument,
|
|
|
|
|
+ updateProductDocument,
|
|
|
|
|
+} from './products.graphql.js';
|
|
|
|
|
+import { api } from '@/vdb/graphql/api.js';
|
|
|
|
|
+import { AssignedChannels } from '@/vdb/components/shared/assigned-channels.js';
|
|
|
|
|
+import { useChannel } from '@/vdb/hooks/use-channel.js';
|
|
|
|
|
|
|
|
const pageId = 'product-detail';
|
|
const pageId = 'product-detail';
|
|
|
|
|
|
|
@@ -56,6 +65,7 @@ function ProductDetailPage() {
|
|
|
const creatingNewEntity = params.id === NEW_ENTITY_PATH;
|
|
const creatingNewEntity = params.id === NEW_ENTITY_PATH;
|
|
|
const { t } = useLingui();
|
|
const { t } = useLingui();
|
|
|
const refreshRef = useRef<() => void>(() => {});
|
|
const refreshRef = useRef<() => void>(() => {});
|
|
|
|
|
+ const { channels } = useChannel();
|
|
|
|
|
|
|
|
const { form, submitHandler, entity, isPending, refreshEntity, resetForm } = useDetailPage({
|
|
const { form, submitHandler, entity, isPending, refreshEntity, resetForm } = useDetailPage({
|
|
|
pageId,
|
|
pageId,
|
|
@@ -70,6 +80,7 @@ function ProductDetailPage() {
|
|
|
featuredAssetId: entity.featuredAsset?.id,
|
|
featuredAssetId: entity.featuredAsset?.id,
|
|
|
assetIds: entity.assets.map(asset => asset.id),
|
|
assetIds: entity.assets.map(asset => asset.id),
|
|
|
facetValueIds: entity.facetValues.map(facetValue => facetValue.id),
|
|
facetValueIds: entity.facetValues.map(facetValue => facetValue.id),
|
|
|
|
|
+ channelIds: entity.channels.map(c => c.id) ?? [],
|
|
|
translations: entity.translations.map(translation => ({
|
|
translations: entity.translations.map(translation => ({
|
|
|
id: translation.id,
|
|
id: translation.id,
|
|
|
languageCode: translation.languageCode,
|
|
languageCode: translation.languageCode,
|
|
@@ -205,6 +216,18 @@ function ProductDetailPage() {
|
|
|
)}
|
|
)}
|
|
|
/>
|
|
/>
|
|
|
</PageBlock>
|
|
</PageBlock>
|
|
|
|
|
+ {channels.length > 1 && entity && (
|
|
|
|
|
+ <PageBlock column="side" blockId="channels" title={<Trans>Channels</Trans>}>
|
|
|
|
|
+ <AssignedChannels
|
|
|
|
|
+ channels={entity.channels}
|
|
|
|
|
+ entityId={entity.id}
|
|
|
|
|
+ canUpdate={!creatingNewEntity}
|
|
|
|
|
+ assignMutationFn={api.mutate(assignProductsToChannelDocument)}
|
|
|
|
|
+ removeMutationFn={api.mutate(removeProductsFromChannelDocument)}
|
|
|
|
|
+ />
|
|
|
|
|
+ </PageBlock>
|
|
|
|
|
+ )}
|
|
|
|
|
+
|
|
|
<PageBlock column="side" blockId="assets" title={<Trans>Assets</Trans>}>
|
|
<PageBlock column="side" blockId="assets" title={<Trans>Assets</Trans>}>
|
|
|
<FormItem>
|
|
<FormItem>
|
|
|
<FormControl>
|
|
<FormControl>
|