Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed Aug 28, 2024
2 parents 95e302a + dbe931a commit b27efc6
Show file tree
Hide file tree
Showing 24 changed files with 415 additions and 123 deletions.
38 changes: 22 additions & 16 deletions packages/admin-next/dashboard/src/hooks/api/api-keys.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HttpTypes } from "@medusajs/types"
import { FetchError } from "@medusajs/js-sdk"
import {
MutationOptions,
QueryKey,
Expand All @@ -17,19 +18,18 @@ export const apiKeysQueryKeys = queryKeysFactory(API_KEYS_QUERY_KEY)

export const useApiKey = (
id: string,
query?: Record<string, any>,
options?: Omit<
UseQueryOptions<
HttpTypes.AdminApiKeyResponse,
Error,
FetchError,
HttpTypes.AdminApiKeyResponse,
QueryKey
>,
"queryKey" | "queryFn"
>
) => {
const { data, ...rest } = useQuery({
queryFn: () => sdk.admin.apiKey.retrieve(id, query),
queryFn: () => sdk.admin.apiKey.retrieve(id),
queryKey: apiKeysQueryKeys.detail(id),
...options,
})
Expand All @@ -38,11 +38,11 @@ export const useApiKey = (
}

export const useApiKeys = (
query?: Record<string, any>,
query?: HttpTypes.AdminGetApiKeysParams,
options?: Omit<
UseQueryOptions<
HttpTypes.AdminApiKeyListResponse,
Error,
HttpTypes.AdminGetApiKeysParams,
FetchError,
HttpTypes.AdminApiKeyListResponse,
QueryKey
>,
Expand All @@ -61,7 +61,7 @@ export const useApiKeys = (
export const useCreateApiKey = (
options?: UseMutationOptions<
HttpTypes.AdminApiKeyResponse,
Error,
FetchError,
HttpTypes.AdminCreateApiKey
>
) => {
Expand All @@ -80,7 +80,7 @@ export const useUpdateApiKey = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminApiKeyResponse,
Error,
FetchError,
HttpTypes.AdminUpdateApiKey
>
) => {
Expand All @@ -98,7 +98,7 @@ export const useUpdateApiKey = (

export const useRevokeApiKey = (
id: string,
options?: UseMutationOptions<HttpTypes.AdminApiKeyResponse, Error, void>
options?: UseMutationOptions<HttpTypes.AdminApiKeyResponse, FetchError, void>
) => {
return useMutation({
mutationFn: () => sdk.admin.apiKey.revoke(id),
Expand All @@ -113,7 +113,11 @@ export const useRevokeApiKey = (

export const useDeleteApiKey = (
id: string,
options?: MutationOptions<HttpTypes.DeleteResponse<"api_key">, Error, void>
options?: MutationOptions<
HttpTypes.DeleteResponse<"api_key">,
FetchError,
void
>
) => {
return useMutation({
mutationFn: () => sdk.admin.apiKey.delete(id),
Expand All @@ -130,12 +134,13 @@ export const useBatchRemoveSalesChannelsFromApiKey = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminApiKeyResponse,
Error,
{ sales_channel_ids: string[] }
FetchError,
HttpTypes.AdminBatchLink["remove"]
>
) => {
return useMutation({
mutationFn: (payload) => sdk.admin.apiKey.removeSalesChannels(id, payload),
mutationFn: (payload) =>
sdk.admin.apiKey.batchSalesChannels(id, { remove: payload }),
onSuccess: (data, variables, context) => {
queryClient.invalidateQueries({ queryKey: apiKeysQueryKeys.lists() })
queryClient.invalidateQueries({ queryKey: apiKeysQueryKeys.detail(id) })
Expand All @@ -153,12 +158,13 @@ export const useBatchAddSalesChannelsToApiKey = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminApiKeyResponse,
Error,
{ sales_channel_ids: string[] }
FetchError,
HttpTypes.AdminBatchLink["add"]
>
) => {
return useMutation({
mutationFn: (payload) => sdk.admin.apiKey.addSalesChannels(id, payload),
mutationFn: (payload) =>
sdk.admin.apiKey.batchSalesChannels(id, { add: payload }),
onSuccess: (data, variables, context) => {
queryClient.invalidateQueries({ queryKey: apiKeysQueryKeys.lists() })
queryClient.invalidateQueries({ queryKey: apiKeysQueryKeys.detail(id) })
Expand Down
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 @@ -76,24 +76,19 @@ export const ApiKeySalesChannelSection = ({
return
}

await mutateAsync(
{
sales_channel_ids: keys,
await mutateAsync(keys, {
onSuccess: () => {
toast.success(
t("apiKeyManagement.removeSalesChannel.successToastBatch", {
count: keys.length,
})
)
setRowSelection({})
},
{
onSuccess: () => {
toast.success(
t("apiKeyManagement.removeSalesChannel.successToastBatch", {
count: keys.length,
})
)
setRowSelection({})
},
onError: (err) => {
toast.error(err.message)
},
}
)
onError: (err) => {
toast.error(err.message)
},
})
}

return (
Expand Down Expand Up @@ -167,23 +162,18 @@ const SalesChannelActions = ({
return
}

await mutateAsync(
{
sales_channel_ids: [salesChannel.id],
await mutateAsync([salesChannel.id], {
onSuccess: () => {
toast.success(
t("apiKeyManagement.removeSalesChannel.successToast", {
count: 1,
})
)
},
{
onSuccess: () => {
toast.success(
t("apiKeyManagement.removeSalesChannel.successToast", {
count: 1,
})
)
},
onError: (err) => {
toast.error(err.message)
},
}
)
onError: (err) => {
toast.error(err.message)
},
})
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,20 @@ export const ApiKeySalesChannelsForm = ({
})

const handleSubmit = form.handleSubmit(async (values) => {
await mutateAsync(
{
sales_channel_ids: values.sales_channel_ids,
await mutateAsync(values.sales_channel_ids, {
onSuccess: () => {
toast.success(
t("apiKeyManagement.salesChannels.successToast", {
count: values.sales_channel_ids.length,
})
)

handleSuccess()
},
{
onSuccess: () => {
toast.success(
t("apiKeyManagement.salesChannels.successToast", {
count: values.sales_channel_ids.length,
})
)

handleSuccess()
},
onError: (err) => {
toast.error(err.message)
},
}
)
onError: (err) => {
toast.error(err.message)
},
})
})

return (
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
Loading

0 comments on commit b27efc6

Please sign in to comment.