Kaynağa Gözat

fix(dashboard): Fix some issues on order list/detail pages

Michael Bromley 8 ay önce
ebeveyn
işleme
fe0ceb49c6

+ 1 - 1
packages/dashboard/src/app/routes/_authenticated/_orders/components/customer-address-selector.tsx

@@ -48,7 +48,7 @@ export function CustomerAddressSelector({ customerId, onSelect }: CustomerAddres
         <Popover open={open} onOpenChange={setOpen}>
             <PopoverTrigger asChild>
                 <div className="flex items-center gap-2">
-                    <Button variant="outline" size="sm" className="" disabled={!customerId}>
+                    <Button variant="outline" size="sm" type="button" className="" disabled={!customerId}>
                         <Plus className="h-4 w-4" />
                         <Trans>Select address</Trans>
                     </Button>

+ 3 - 1
packages/dashboard/src/app/routes/_authenticated/_orders/components/edit-order-table.tsx

@@ -78,7 +78,7 @@ export function EditOrderTable({ order, eligibleShippingMethods, onAddItem, onAd
             cell: ({ row }) => {
                 return <div className="flex gap-2">
                     <Input type="number" value={row.original.quantity} onChange={e => onAdjustLine({ lineId: row.original.id, quantity: e.target.valueAsNumber, customFields: row.original.customFields })} />
-                    <Button variant="outline" size="icon" onClick={() => onRemoveLine({ lineId: row.original.id })}>
+                    <Button variant="outline" type="button" size="icon" onClick={() => onRemoveLine({ lineId: row.original.id })}>
                         <Trash2 />
                     </Button>
                     {row.original.customFields &&
@@ -188,6 +188,7 @@ export function EditOrderTable({ order, eligibleShippingMethods, onAddItem, onAd
                                             }}
                                         />
                                         <Button
+                                            type="button"
                                             onClick={() => onApplyCouponCode({ couponCode })}
                                             disabled={!couponCode}
                                         >
@@ -203,6 +204,7 @@ export function EditOrderTable({ order, eligibleShippingMethods, onAddItem, onAd
                                                 >
                                                     <span>{code}</span>
                                                     <Button
+                                                        type="button"
                                                         variant="ghost"
                                                         size="sm"
                                                         className="h-6 w-6 p-0"

+ 17 - 17
packages/dashboard/src/app/routes/_authenticated/_orders/orders.tsx

@@ -33,26 +33,26 @@ function OrderListPage() {
             title="Orders"
             onSearchTermChange={searchTerm => {
                 return {
-                    code: {
-                        contains: searchTerm,
-                    },
-                    customerLastName: {
-                        contains: searchTerm,
-                    },
-                    transactionId: {
-                        contains: searchTerm,
-                    },
+                    _or: [
+                        {
+                            code: {
+                                contains: searchTerm,
+                            },
+                        },
+                        {
+                            customerLastName: {
+                                contains: searchTerm,
+                            },
+                        },
+                        {
+                            transactionId: {
+                                contains: searchTerm,
+                            },
+                        },
+                    ],
                 };
             }}
             defaultSort={[{ id: 'orderPlacedAt', desc: true }]}
-            transformVariables={variables => {
-                return {
-                    options: {
-                        ...variables.options,
-                        filterOperator: 'OR',
-                    }
-                };
-            }}
             listQuery={orderListDocument}
             route={Route}
             customizeColumns={{

+ 22 - 19
packages/dashboard/src/app/routes/_authenticated/_orders/orders_.draft.$id.tsx

@@ -302,14 +302,14 @@ function DraftOrderPage() {
                                 deleteDraftOrder({ orderId: entity.id });
                             }}
                         >
-                            <Button variant="destructive">
+                            <Button variant="destructive" type="button">
                                 <Trans>Delete draft</Trans>
                             </Button>
                         </ConfirmationDialog>
 
                     </PermissionGuard>
                     <PermissionGuard requires={['UpdateOrder']}>
-                        <Button type="submit"
+                        <Button type="button"
                             disabled={!entity.customer || entity.lines.length === 0 || entity.shippingLines.length === 0 || entity.state !== 'Draft'}
                             onClick={() => completeDraftOrder({ id: entity.id, state: 'ArrangingPayment' })}
                         >
@@ -361,8 +361,9 @@ function DraftOrderPage() {
                 <PageBlock column="side" blockId="shipping-address" title={<Trans>Shipping address</Trans>}>
                     <div className="flex flex-col">
                         <OrderAddress address={entity.shippingAddress ?? undefined} />
-                        {entity.shippingAddress?.streetLine1 ?
-                            <RemoveAddressButton onClick={() => unsetShippingAddressForDraftOrder({ orderId: entity.id })} /> : <CustomerAddressSelector customerId={entity.customer?.id} onSelect={address => {
+                        {entity.shippingAddress?.streetLine1
+                            ? <RemoveAddressButton onClick={() => unsetShippingAddressForDraftOrder({ orderId: entity.id })} />
+                            : <CustomerAddressSelector customerId={entity.customer?.id} onSelect={address => {
                                 setShippingAddressForDraftOrder({
                                     orderId: entity.id, input: {
                                         fullName: address.fullName,
@@ -383,21 +384,23 @@ function DraftOrderPage() {
                 <PageBlock column="side" blockId="billing-address" title={<Trans>Billing address</Trans>}>
                     <div className="flex flex-col">
                         <OrderAddress address={entity.billingAddress ?? undefined} />
-                        {entity.billingAddress?.streetLine1 ? <RemoveAddressButton onClick={() => unsetBillingAddressForDraftOrder({ orderId: entity.id })} /> : <CustomerAddressSelector customerId={entity.customer?.id} onSelect={address => {
-                            setBillingAddressForDraftOrder({
-                                orderId: entity.id, input: {
-                                    fullName: address.fullName,
-                                    company: address.company,
-                                    streetLine1: address.streetLine1,
-                                    streetLine2: address.streetLine2,
-                                    city: address.city,
-                                    province: address.province,
-                                    postalCode: address.postalCode,
-                                    countryCode: address.country.code,
-                                    phoneNumber: address.phoneNumber,
-                                }
-                            });
-                        }} />
+                        {entity.billingAddress?.streetLine1
+                            ? <RemoveAddressButton onClick={() => unsetBillingAddressForDraftOrder({ orderId: entity.id })} />
+                            : <CustomerAddressSelector customerId={entity.customer?.id} onSelect={address => {
+                                setBillingAddressForDraftOrder({
+                                    orderId: entity.id, input: {
+                                        fullName: address.fullName,
+                                        company: address.company,
+                                        streetLine1: address.streetLine1,
+                                        streetLine2: address.streetLine2,
+                                        city: address.city,
+                                        province: address.province,
+                                        postalCode: address.postalCode,
+                                        countryCode: address.country.code,
+                                        phoneNumber: address.phoneNumber,
+                                    }
+                                });
+                            }} />
                         }
                     </div>
                 </PageBlock>