forked from medusajs/medusa
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard,js-sdk,types,admin-shared): Add Product Types domain (m…
- Loading branch information
1 parent
70a72ce
commit 2d8d2c4
Showing
53 changed files
with
1,045 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/admin-next/dashboard/src/hooks/table/filters/use-date-table-filters.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useTranslation } from "react-i18next" | ||
import { Filter } from "../../../components/table/data-table" | ||
|
||
export const useDateTableFilters = () => { | ||
const { t } = useTranslation() | ||
|
||
const dateFilters: Filter[] = [ | ||
{ label: t("fields.createdAt"), key: "created_at" }, | ||
{ label: t("fields.updatedAt"), key: "updated_at" }, | ||
].map((f) => ({ | ||
key: f.key, | ||
label: f.label, | ||
type: "date", | ||
})) | ||
|
||
return dateFilters | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...n-next/dashboard/src/routes/product-types/common/hooks/use-delete-product-type-action.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { toast, usePrompt } from "@medusajs/ui" | ||
import { useTranslation } from "react-i18next" | ||
import { useDeleteProductType } from "../../../../hooks/api/product-types" | ||
|
||
export const useDeleteProductTypeAction = (id: string) => { | ||
const { t } = useTranslation() | ||
const prompt = usePrompt() | ||
|
||
const { mutateAsync } = useDeleteProductType(id) | ||
|
||
const handleDelete = async () => { | ||
const result = await prompt({ | ||
title: t("general.areYouSure"), | ||
description: t("productTypes.delete.confirmation"), | ||
confirmText: t("actions.delete"), | ||
cancelText: t("actions.cancel"), | ||
}) | ||
|
||
if (!result) { | ||
return | ||
} | ||
|
||
await mutateAsync(undefined, { | ||
onSuccess: () => { | ||
toast.success(t("general.success"), { | ||
description: t("productTypes.delete.successToast"), | ||
dismissLabel: t("actions.close"), | ||
dismissable: true, | ||
}) | ||
}, | ||
onError: (e) => { | ||
toast.error(t("general.error"), { | ||
description: e.message, | ||
dismissLabel: t("actions.close"), | ||
dismissable: true, | ||
}) | ||
}, | ||
}) | ||
} | ||
|
||
return handleDelete | ||
} |
Oops, something went wrong.