Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashboard,js-sdk): fixes from rma flows testing #8826

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions packages/admin-next/dashboard/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,9 @@
},
"edits": {
"title": "Edit order",
"confirm": "Confirm Edit",
"confirmText": "You are about to confirm an Order Edit. This action cannot be undone.",
"cancel": "Cancel Edit",
"currentItems": "Current items",
"currentItemsDescription": "Adjust item quantity or remove.",
"addItemsDescription": "You can add new items to the order.",
Expand All @@ -874,6 +877,8 @@
},
"returns": {
"create": "Create Return",
"confirm": "Confirm Return",
"confirmText": "You are about to confirm a Return. This action cannot be undone.",
"inbound": "Inbound",
"outbound": "Outbound",
"sendNotification": "Send notification",
Expand Down Expand Up @@ -903,7 +908,7 @@
},
"receive": {
"action": "Receive items",
"receive": "Return {{label}}",
"receiveItems": "{{ returnType }} {{ id }}",
"restockAll": "Restock all items",
"itemsLabel": "Items received",
"title": "Receive items for #{{returnId}}",
Expand All @@ -928,6 +933,9 @@
},
"claims": {
"create": "Create Claim",
"confirm": "Confirm Claim",
"confirmText": "You are about to confirm a Claim. This action cannot be undone.",
"cancel": "Cancel Claim",
"manage": "Manage Claim",
"outbound": "Outbound",
"outboundItemAdded": "{{itemsCount}}x added through claim",
Expand Down Expand Up @@ -956,6 +964,9 @@
"exchanges": {
"create": "Create Exchange",
"manage": "Manage Exchange",
"confirm": "Confirm Exchange",
"confirmText": "You are about to confirm an Exchange. This action cannot be undone.",
"cancel": "Cancel Exchange",
"outbound": "Outbound",
"outboundItemAdded": "{{itemsCount}}x added through exchange",
"outboundTotal": "Outbound total",
Expand Down Expand Up @@ -1003,7 +1014,7 @@
"shipment": {
"title": "Mark fulfillment shipped",
"trackingNumber": "Tracking number",
"addTracking": "Add additional tracking number",
"addTracking": "Add tracking number",
"sendNotification": "Send notification",
"sendNotificationHint": "Notify the customer about this shipment.",
"toastCreated": "Shipment created successfully."
Expand Down Expand Up @@ -1078,6 +1089,10 @@
"deleteButtonText": "Delete comment"
},
"events": {
"common": {
"toReturn": "To return",
"toSend": "To send"
},
"placed": {
"title": "Order placed",
"fromSalesChannel": "from {{salesChannel}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Switch,
Text,
toast,
usePrompt,
} from "@medusajs/ui"
import { useEffect, useMemo, useState } from "react"
import { useFieldArray, useForm } from "react-hook-form"
Expand Down Expand Up @@ -305,8 +306,21 @@ export const ClaimCreateForm = ({

const showInboundItemsPlaceholder = !inboundItems.length
const shippingOptionId = form.watch("inbound_option_id")
const prompt = usePrompt()

const handleSubmit = form.handleSubmit(async (data) => {
const res = await prompt({
title: t("general.areYouSure"),
description: t("orders.claims.confirmText"),
confirmText: t("actions.continue"),
cancelText: t("actions.cancel"),
variant: "confirmation",
})

if (!res) {
return
}

await confirmClaimRequest(
{ no_notification: !data.send_notification },
{
Expand Down Expand Up @@ -518,6 +532,7 @@ export const ClaimCreateForm = ({
{t("actions.cancel")}
</Button>
</RouteFocusModal.Close>

<Button
key="submit-button"
type="submit"
Expand Down Expand Up @@ -859,6 +874,8 @@ export const ClaimCreateForm = ({
}}
/>
</div>

<div className="p-8" />
</div>
</RouteFocusModal.Body>
<RouteFocusModal.Footer>
Expand All @@ -871,7 +888,7 @@ export const ClaimCreateForm = ({
variant="secondary"
size="small"
>
{t("actions.cancel")}
{t("orders.claims.cancel")}
</Button>
</RouteFocusModal.Close>
<Button
Expand All @@ -881,7 +898,7 @@ export const ClaimCreateForm = ({
size="small"
isLoading={isRequestLoading}
>
{t("actions.save")}
{t("orders.claims.confirm")}
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { zodResolver } from "@hookform/resolvers/zod"
import { AdminOrder, AdminOrderPreview } from "@medusajs/types"
import { Button, Heading, Input, Switch, toast } from "@medusajs/ui"
import { Button, Heading, Input, Switch, toast, usePrompt } from "@medusajs/ui"
import { useForm } from "react-hook-form"
import { useTranslation } from "react-i18next"

Expand All @@ -10,13 +10,13 @@ import {
} from "../../../../../components/modals"

import { Form } from "../../../../../components/common/form"
import { getStylizedAmount } from "../../../../../lib/money-amount-helpers"
import { CreateOrderEditSchemaType, OrderEditCreateSchema } from "./schema"
import {
useCancelOrderEdit,
useRequestOrderEdit,
} from "../../../../../hooks/api/order-edits"
import { getStylizedAmount } from "../../../../../lib/money-amount-helpers"
import { OrderEditItemsSection } from "./order-edit-items-section"
import { CreateOrderEditSchemaType, OrderEditCreateSchema } from "./schema"

type ReturnCreateFormProps = {
order: AdminOrder
Expand Down Expand Up @@ -55,8 +55,22 @@ export const OrderEditCreateForm = ({
resolver: zodResolver(OrderEditCreateSchema),
})

const prompt = usePrompt()

const handleSubmit = form.handleSubmit(async (data) => {
try {
const res = await prompt({
title: t("general.areYouSure"),
description: t("orders.edits.confirmText"),
confirmText: t("actions.continue"),
cancelText: t("actions.cancel"),
variant: "confirmation",
})

if (!res) {
return
}

await requestOrderEdit()

toast.success(t("orders.edits.createSuccessToast"))
Expand Down Expand Up @@ -185,14 +199,16 @@ export const OrderEditCreateForm = ({
}}
/>
</div>

<div className="p-8" />
</div>
</RouteFocusModal.Body>
<RouteFocusModal.Footer>
<div className="flex w-full items-center justify-end gap-x-4">
<div className="flex items-center justify-end gap-x-2">
<RouteFocusModal.Close asChild>
<Button type="button" variant="secondary" size="small">
{t("actions.cancel")}
{t("orders.edits.cancel")}
</Button>
</RouteFocusModal.Close>
<Button
Expand All @@ -202,7 +218,7 @@ export const OrderEditCreateForm = ({
size="small"
isLoading={isRequestRunning}
>
{t("actions.save")}
{t("orders.edits.confirm")}
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
IconButton,
Switch,
toast,
usePrompt,
} from "@medusajs/ui"
import { useEffect, useMemo, useState } from "react"
import { useForm } from "react-hook-form"
Expand Down Expand Up @@ -148,9 +149,22 @@ export const ExchangeCreateForm = ({
})

const shippingOptionId = form.watch("inbound_option_id")
const prompt = usePrompt()

const handleSubmit = form.handleSubmit(async (data) => {
try {
const res = await prompt({
title: t("general.areYouSure"),
description: t("orders.exchanges.confirmText"),
confirmText: t("actions.continue"),
cancelText: t("actions.cancel"),
variant: "confirmation",
})

if (!res) {
return
}

await confirmExchangeRequest({ no_notification: !data.send_notification })

handleSuccess()
Expand Down Expand Up @@ -390,6 +404,8 @@ export const ExchangeCreateForm = ({
}}
/>
</div>

<div className="p-8" />
</div>
</RouteFocusModal.Body>
<RouteFocusModal.Footer>
Expand All @@ -402,17 +418,18 @@ export const ExchangeCreateForm = ({
variant="secondary"
size="small"
>
{t("actions.cancel")}
{t("orders.exchanges.cancel")}
</Button>
</RouteFocusModal.Close>

<Button
key="submit-button"
type="submit"
variant="primary"
size="small"
isLoading={isRequestLoading}
>
{t("actions.save")}
{t("orders.exchanges.confirm")}
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Switch,
Text,
toast,
usePrompt,
} from "@medusajs/ui"
import { useEffect, useMemo, useState } from "react"
import { useFieldArray, useForm } from "react-hook-form"
Expand Down Expand Up @@ -240,9 +241,22 @@ export const ReturnCreateForm = ({
const showPlaceholder = !items.length
const locationId = form.watch("location_id")
const shippingOptionId = form.watch("option_id")
const prompt = usePrompt()

const handleSubmit = form.handleSubmit(async (data) => {
try {
const res = await prompt({
title: t("general.areYouSure"),
description: t("orders.returns.confirmText"),
confirmText: t("actions.continue"),
cancelText: t("actions.cancel"),
variant: "confirmation",
})

if (!res) {
return
}

await confirmReturnRequest({ no_notification: !data.send_notification })

handleSuccess()
Expand Down Expand Up @@ -702,14 +716,16 @@ export const ReturnCreateForm = ({
}}
/>
</div>

<div className="p-8" />
</div>
</RouteFocusModal.Body>
<RouteFocusModal.Footer>
<div className="flex w-full items-center justify-end gap-x-4">
<div className="flex items-center justify-end gap-x-2">
<RouteFocusModal.Close asChild>
<Button type="button" variant="secondary" size="small">
{t("actions.cancel")}
{t("orders.returns.cancel.title")}
</Button>
</RouteFocusModal.Close>
<Button
Expand All @@ -719,7 +735,7 @@ export const ReturnCreateForm = ({
size="small"
isLoading={isRequestLoading}
>
{t("actions.save")}
{t("orders.returns.confirm")}
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const ActiveOrderClaimSection = ({

<div className="flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4">
<Button size="small" variant="secondary" onClick={onCancelClaim}>
{t("actions.cancel")}
{t("orders.claims.cancel")}
</Button>

<Button size="small" variant="secondary" onClick={onContinueClaim}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const ActiveOrderExchangeSection = ({

<div className="flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4">
<Button size="small" variant="secondary" onClick={onCancelExchange}>
{t("actions.cancel")}
{t("orders.exchanges.cancel")}
</Button>

<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const ActiveOrderReturnSection = ({

<div className="flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4">
<Button size="small" variant="secondary" onClick={onCancelReturn}>
{t("actions.cancel")}
{t("orders.returns.cancel.title")}
</Button>

<Button size="small" variant="secondary" onClick={onContinueReturn}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const CopyPaymentLink = React.forwardRef<any, CopyPaymentLinkProps>(
}

setTimeout(() => {
setText("CopyPaymentLink")
setText("Copy")
}, 500)
}, [done])

Expand Down
Loading
Loading