diff --git a/.github/teams.yml b/.github/teams.yml index c8a20258b5..8d1647f507 100644 --- a/.github/teams.yml +++ b/.github/teams.yml @@ -12,3 +12,4 @@ - "@sradevski" - "@edast" - "@thetutlage" + - "@christiananese" diff --git a/packages/admin-next/dashboard/src/components/table/data-table/data-table-root/data-table-root.tsx b/packages/admin-next/dashboard/src/components/table/data-table/data-table-root/data-table-root.tsx index 0a31970ea5..3be55a8371 100644 --- a/packages/admin-next/dashboard/src/components/table/data-table/data-table-root/data-table-root.tsx +++ b/packages/admin-next/dashboard/src/components/table/data-table/data-table-root/data-table-root.tsx @@ -52,6 +52,10 @@ export interface DataTableRootProps { * Whether the table is empty due to no results from the active query */ noResults?: boolean + /** + * Whether to display the tables header + */ + noHeader?: boolean /** * The layout of the table */ @@ -80,6 +84,7 @@ export const DataTableRoot = ({ commands, count = 0, noResults = false, + noHeader = false, layout = "fit", }: DataTableRootProps) => { const { t } = useTranslation() @@ -133,64 +138,66 @@ export const DataTableRoot = ({ > {!noResults ? ( - - {table.getHeaderGroups().map((headerGroup) => { - return ( - - {headerGroup.headers.map((header, index) => { - const isActionHeader = header.id === "actions" - const isSelectHeader = header.id === "select" - const isSpecialHeader = isActionHeader || isSelectHeader + {!noHeader && ( + + {table.getHeaderGroups().map((headerGroup) => { + return ( + + {headerGroup.headers.map((header, index) => { + const isActionHeader = header.id === "actions" + const isSelectHeader = header.id === "select" + const isSpecialHeader = isActionHeader || isSelectHeader - const firstHeader = headerGroup.headers.findIndex( - (h) => h.id !== "select" - ) - const isFirstHeader = - firstHeader !== -1 - ? header.id === headerGroup.headers[firstHeader].id - : index === 0 + const firstHeader = headerGroup.headers.findIndex( + (h) => h.id !== "select" + ) + const isFirstHeader = + firstHeader !== -1 + ? header.id === headerGroup.headers[firstHeader].id + : index === 0 - const isStickyHeader = isSelectHeader || isFirstHeader + const isStickyHeader = isSelectHeader || isFirstHeader - return ( - - {flexRender( - header.column.columnDef.header, - header.getContext() - )} - - ) - })} - - ) - })} - + return ( + + {flexRender( + header.column.columnDef.header, + header.getContext() + )} + + ) + })} + + ) + })} + + )} {table.getRowModel().rows.map((row) => { const to = navigateTo ? navigateTo(row) : undefined diff --git a/packages/admin-next/dashboard/src/components/table/data-table/data-table.tsx b/packages/admin-next/dashboard/src/components/table/data-table/data-table.tsx index 760acdeaec..42ef4e93d8 100644 --- a/packages/admin-next/dashboard/src/components/table/data-table/data-table.tsx +++ b/packages/admin-next/dashboard/src/components/table/data-table/data-table.tsx @@ -32,6 +32,7 @@ export const DataTable = ({ queryObject = {}, pageSize, isLoading = false, + noHeader = false, layout = "fit", noRecords: noRecordsProps = {}, }: DataTableProps) => { @@ -84,6 +85,7 @@ export const DataTable = ({ navigateTo={navigateTo} commands={commands} noResults={noResults} + noHeader={noHeader} layout={layout} /> diff --git a/packages/admin-next/dashboard/src/hooks/table/columns/use-return-reason-table-columns.tsx b/packages/admin-next/dashboard/src/hooks/table/columns/use-return-reason-table-columns.tsx index d27b870159..e2ab45782a 100644 --- a/packages/admin-next/dashboard/src/hooks/table/columns/use-return-reason-table-columns.tsx +++ b/packages/admin-next/dashboard/src/hooks/table/columns/use-return-reason-table-columns.tsx @@ -1,25 +1,30 @@ import { HttpTypes } from "@medusajs/types" +import { Badge } from "@medusajs/ui" import { createColumnHelper } from "@tanstack/react-table" import { useMemo } from "react" -import { useTranslation } from "react-i18next" -import { TextCell } from "../../../components/table/table-cells/common/text-cell" const columnHelper = createColumnHelper() export const useReturnReasonTableColumns = () => { - const { t } = useTranslation() - return useMemo( () => [ columnHelper.accessor("value", { - header: () => t("fields.value"), - cell: ({ getValue }) => , + cell: ({ getValue }) => {getValue()}, }), columnHelper.accessor("label", { - header: () => t("fields.createdAt"), - cell: ({ getValue }) => , + cell: ({ row }) => { + const { label, description } = row.original + return ( +
+ {label} + + {description ? description : "-"} + +
+ ) + }, }), ], - [t] + [] ) } diff --git a/packages/admin-next/dashboard/src/i18n/translations/en.json b/packages/admin-next/dashboard/src/i18n/translations/en.json index f7ffa6495e..53fd101fb5 100644 --- a/packages/admin-next/dashboard/src/i18n/translations/en.json +++ b/packages/admin-next/dashboard/src/i18n/translations/en.json @@ -166,7 +166,8 @@ "goToPublishableApiKeys": "Publishable API Keys", "goToSecretApiKeys": "Secret API Keys", "goToWorkflows": "Workflows", - "goToProfile": "Profile" + "goToProfile": "Profile", + "goToReturnReasons": "Return reasons" } }, "menus": { @@ -2104,6 +2105,7 @@ }, "returnReasons": { "domain": "Return Reasons", + "subtitle": "Manage reasons for returned items.", "calloutHint": "Manage the reasons to categorize returns.", "editReason": "Edit Return Reason", "create": { @@ -2113,6 +2115,8 @@ "successToast": "Return reason {{label}} was successfully created." }, "edit": { + "header": "Edit Return Reason", + "subtitle": "Edit the value of the return reason.", "successToast": "Return reason {{label}} was successfully updated." }, "delete": { diff --git a/packages/admin-next/dashboard/src/providers/keybind-provider/hooks.tsx b/packages/admin-next/dashboard/src/providers/keybind-provider/hooks.tsx index c57c0c080e..82a0a9908a 100644 --- a/packages/admin-next/dashboard/src/providers/keybind-provider/hooks.tsx +++ b/packages/admin-next/dashboard/src/providers/keybind-provider/hooks.tsx @@ -264,6 +264,14 @@ export const useGlobalShortcuts = () => { type: "settingShortcut", to: "/settings/locations", }, + { + keys: { + Mac: ["G", ",", "M"], + }, + label: t("app.keyboardShortcuts.settings.goToReturnReasons"), + type: "settingShortcut", + to: "/settings/return-reasons", + }, { keys: { Mac: ["G", ",", "J"], diff --git a/packages/admin-next/dashboard/src/providers/router-provider/route-map.tsx b/packages/admin-next/dashboard/src/providers/router-provider/route-map.tsx index 22388fcac0..5c2c898012 100644 --- a/packages/admin-next/dashboard/src/providers/router-provider/route-map.tsx +++ b/packages/admin-next/dashboard/src/providers/router-provider/route-map.tsx @@ -1304,6 +1304,28 @@ export const RouteMap: RouteObject[] = [ path: "", lazy: () => import("../../routes/return-reasons/return-reason-list"), + children: [ + { + path: "create", + lazy: () => + import( + "../../routes/return-reasons/return-reason-create" + ), + }, + + { + path: ":id", + children: [ + { + path: "edit", + lazy: () => + import( + "../../routes/return-reasons/return-reason-edit" + ), + }, + ], + }, + ], }, ], }, diff --git a/packages/admin-next/dashboard/src/routes/return-reasons/return-reason-create/components/return-reason-create-form/index.ts b/packages/admin-next/dashboard/src/routes/return-reasons/return-reason-create/components/return-reason-create-form/index.ts new file mode 100644 index 0000000000..45be67638b --- /dev/null +++ b/packages/admin-next/dashboard/src/routes/return-reasons/return-reason-create/components/return-reason-create-form/index.ts @@ -0,0 +1 @@ +export * from "./return-reason-create-form" diff --git a/packages/admin-next/dashboard/src/routes/return-reasons/return-reason-create/components/return-reason-create-form/return-reason-create-form.tsx b/packages/admin-next/dashboard/src/routes/return-reasons/return-reason-create/components/return-reason-create-form/return-reason-create-form.tsx new file mode 100644 index 0000000000..40710c7f41 --- /dev/null +++ b/packages/admin-next/dashboard/src/routes/return-reasons/return-reason-create/components/return-reason-create-form/return-reason-create-form.tsx @@ -0,0 +1,156 @@ +import { zodResolver } from "@hookform/resolvers/zod" +import { Button, Heading, Input, Text, Textarea, toast } from "@medusajs/ui" +import { useForm } from "react-hook-form" +import { useTranslation } from "react-i18next" +import { z } from "zod" +import { Form } from "../../../../../components/common/form" +import { + RouteFocusModal, + useRouteModal, +} from "../../../../../components/modals" +import { useCreateReturnReason } from "../../../../../hooks/api/return-reasons" + +const ReturnReasonCreateSchema = z.object({ + value: z.string().min(1), + label: z.string().min(1), + description: z.string().optional(), +}) + +export const ReturnReasonCreateForm = () => { + const { t } = useTranslation() + const { handleSuccess } = useRouteModal() + + const form = useForm>({ + defaultValues: { + value: "", + label: "", + description: "", + }, + resolver: zodResolver(ReturnReasonCreateSchema), + }) + + const { mutateAsync, isPending } = useCreateReturnReason() + + const handleSubmit = form.handleSubmit(async (data) => { + await mutateAsync(data, { + onSuccess: ({ return_reason }) => { + toast.success( + t("returnReasons.create.successToast", { + label: return_reason.label, + }) + ) + handleSuccess(`../`) + }, + onError: (error) => { + toast.error(error.message) + }, + }) + }) + + return ( + +
+ + +
+
+ + {t("returnReasons.create.header")} + + + + {t("returnReasons.create.subtitle")} + + +
+
+ { + return ( + + + {t("returnReasons.fields.value.label")} + + + + + + + ) + }} + /> + { + return ( + + + {t("returnReasons.fields.label.label")} + + + + + + + ) + }} + /> +
+ { + return ( + + + {t("returnReasons.fields.description.label")} + + +