@@ -8,20 +8,13 @@ import {
88 type ChannelDeleteMutation ,
99 type ChannelErrorFragment ,
1010 type ChannelUpdateMutation ,
11- isMainSchema ,
12- isStagingSchema ,
1311 useChannelActivateMutation ,
1412 useChannelDeactivateMutation ,
1513 useChannelDeleteMutation ,
1614 useChannelQuery ,
1715 useChannelsQuery ,
1816 useChannelUpdateMutation ,
1917} from "@dashboard/graphql" ;
20- import {
21- useChannelQuery as useChannelQueryStaging ,
22- useChannelsQuery as useChannelsQueryStaging ,
23- useChannelUpdateMutation as useChannelUpdateMutationStaging ,
24- } from "@dashboard/graphql/staging" ;
2518import { getSearchFetchMoreProps } from "@dashboard/hooks/makeTopLevelSearch/utils" ;
2619import useNavigator from "@dashboard/hooks/useNavigator" ;
2720import { useNotifier } from "@dashboard/hooks/useNotifier" ;
@@ -53,47 +46,25 @@ const ChannelDetails = ({ id, params }: ChannelDetailsProps) => {
5346 const notify = useNotifier ( ) ;
5447 const intl = useIntl ( ) ;
5548 const shop = useShop ( ) ;
56- const channelsListDataMain = useChannelsQuery ( {
57- displayLoader : true ,
58- skip : isStagingSchema ( ) ,
59- } ) ;
60- const channelsListDataStaging = useChannelsQueryStaging ( {
49+ const channelsListData = useChannelsQuery ( {
6150 displayLoader : true ,
62- skip : isMainSchema ( ) ,
6351 } ) ;
64- const channelsListData = channelsListDataStaging ?? channelsListDataMain ;
6552
6653 const [ openModal , closeModal ] = createDialogActionHandlers <
6754 ChannelUrlDialog ,
6855 ChannelUrlQueryParams
6956 > ( navigate , params => channelUrl ( id , params ) , params ) ;
7057
71- const [ updateChannelMain , updateChannelOptsMain ] = useChannelUpdateMutation ( {
72- onCompleted : ( { channelUpdate : { errors } } : ChannelUpdateMutation ) =>
73- notify ( getDefaultNotifierSuccessErrorData ( errors , intl ) ) ,
74- } ) ;
75-
76- const [ updateChannelStaging , updateChannelOptsStaging ] = useChannelUpdateMutationStaging ( {
58+ const [ updateChannel , updateChannelOpts ] = useChannelUpdateMutation ( {
7759 onCompleted : ( { channelUpdate : { errors } } : ChannelUpdateMutation ) =>
7860 notify ( getDefaultNotifierSuccessErrorData ( errors , intl ) ) ,
7961 } ) ;
8062
81- const { data : dataMain , loading : loadingMain } = useChannelQuery ( {
63+ const { data, loading } = useChannelQuery ( {
8264 displayLoader : true ,
8365 variables : { id } ,
84- skip : isStagingSchema ( ) ,
8566 } ) ;
8667
87- const { data : dataStaging , loading : loadingStaging } = useChannelQueryStaging ( {
88- displayLoader : true ,
89- variables : { id } ,
90- skip : isMainSchema ( ) ,
91- } ) ;
92-
93- const data = dataStaging ?? dataMain ;
94- const loading = loadingMain ?? loadingStaging ;
95- const updateChannelOpts = isStagingSchema ( ) ? updateChannelOptsStaging : updateChannelOptsMain ;
96-
9768 const { reorderChannelWarehouses, reorderChannelWarehousesOpts } = useChannelWarehousesReorder ( ) ;
9869
9970 const handleError = ( error : ChannelErrorFragment ) => {
@@ -175,64 +146,35 @@ const ChannelDetails = ({ id, params }: ChannelDetailsProps) => {
175146 automaticCompletionInput . cutOffDate = getCutOffDateTimeISO ( ) ;
176147 }
177148
178- const updateChannelMutation = isStagingSchema ( )
179- ? updateChannelStaging ( {
180- variables : {
181- id : data ?. channel . id ,
182- input : {
183- name,
184- checkoutSettings : {
185- automaticCompletion : automaticCompletionInput ,
186- allowLegacyGiftCardUse,
187- } ,
188- slug,
189- defaultCountry,
190- addShippingZones : shippingZonesIdsToAdd ,
191- removeShippingZones : shippingZonesIdsToRemove ,
192- addWarehouses : warehousesIdsToAdd ,
193- removeWarehouses : warehousesIdsToRemove ,
194- stockSettings : {
195- allocationStrategy,
196- } ,
197- paymentSettings : {
198- defaultTransactionFlowStrategy,
199- } ,
200- orderSettings : {
201- markAsPaidStrategy,
202- deleteExpiredOrdersAfter,
203- allowUnpaidOrders,
204- } ,
205- } ,
149+ const updateChannelMutation = updateChannel ( {
150+ variables : {
151+ id : data ?. channel . id ,
152+ input : {
153+ name,
154+ checkoutSettings : {
155+ automaticCompletion : automaticCompletionInput ,
156+ allowLegacyGiftCardUse,
206157 } ,
207- } )
208- : updateChannelMain ( {
209- variables : {
210- id : data ?. channel . id ,
211- input : {
212- name,
213- checkoutSettings : {
214- automaticCompletion : automaticCompletionInput ,
215- } ,
216- slug,
217- defaultCountry,
218- addShippingZones : shippingZonesIdsToAdd ,
219- removeShippingZones : shippingZonesIdsToRemove ,
220- addWarehouses : warehousesIdsToAdd ,
221- removeWarehouses : warehousesIdsToRemove ,
222- stockSettings : {
223- allocationStrategy,
224- } ,
225- paymentSettings : {
226- defaultTransactionFlowStrategy,
227- } ,
228- orderSettings : {
229- markAsPaidStrategy,
230- deleteExpiredOrdersAfter,
231- allowUnpaidOrders,
232- } ,
233- } ,
158+ slug,
159+ defaultCountry,
160+ addShippingZones : shippingZonesIdsToAdd ,
161+ removeShippingZones : shippingZonesIdsToRemove ,
162+ addWarehouses : warehousesIdsToAdd ,
163+ removeWarehouses : warehousesIdsToRemove ,
164+ stockSettings : {
165+ allocationStrategy,
234166 } ,
235- } ) ;
167+ paymentSettings : {
168+ defaultTransactionFlowStrategy,
169+ } ,
170+ orderSettings : {
171+ markAsPaidStrategy,
172+ deleteExpiredOrdersAfter,
173+ allowUnpaidOrders,
174+ } ,
175+ } ,
176+ } ,
177+ } ) ;
236178
237179 const resultChannel = await updateChannelMutation ;
238180 const errors = await extractMutationErrors ( updateChannelMutation ) ;
0 commit comments