(
10 | render: (props: PropsWithoutRef, ref: Ref) => ReactNode
11 | ): (props: P & RefAttributes) => ReactNode {
12 | return forwardRef(render) as any
13 | }
14 |
--------------------------------------------------------------------------------
/packages/nocto/src/plugins/routes/login/index.ts:
--------------------------------------------------------------------------------
1 | import { ConfigSchema } from "./plugin"
2 |
3 | export const loginPlugin = {
4 | id: "@login",
5 | configSchema: ConfigSchema,
6 | routes: () => [
7 | {
8 | path: "/login",
9 | layout: "auth",
10 | lazy: () =>
11 | import("./plugin").then((mod) => ({
12 | Component: () => mod.default(),
13 | })),
14 | },
15 | ],
16 | }
17 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/tax-regions/common/utils.ts:
--------------------------------------------------------------------------------
1 | import { HttpTypes } from "@medusajs/types"
2 |
3 | import { TaxRateRuleTarget } from "./schemas"
4 |
5 | export const createTaxRulePayload = (
6 | target: TaxRateRuleTarget
7 | ): HttpTypes.AdminCreateTaxRate["rules"] => {
8 | return target.references.map((reference) => ({
9 | reference: target.reference_type,
10 | reference_id: reference.value,
11 | }))
12 | }
13 |
--------------------------------------------------------------------------------
/packages/cli/template/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Nocto
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/nocto/src/components/modals/route-modal-provider/use-route-modal.tsx:
--------------------------------------------------------------------------------
1 | import { useContext } from "react"
2 | import { RouteModalProviderContext } from "./route-modal-context"
3 |
4 | export const useRouteModal = () => {
5 | const context = useContext(RouteModalProviderContext)
6 |
7 | if (!context) {
8 | throw new Error("useRouteModal must be used within a RouteModalProvider")
9 | }
10 |
11 | return context
12 | }
13 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/campaigns/common/constants.ts:
--------------------------------------------------------------------------------
1 | import { CampaignBudgetTypeValues } from "@medusajs/types"
2 |
3 | export const DEFAULT_CAMPAIGN_VALUES = {
4 | name: "",
5 | description: "",
6 | campaign_identifier: "",
7 | starts_at: null,
8 | ends_at: null,
9 | budget: {
10 | type: "usage" as CampaignBudgetTypeValues,
11 | currency_code: null,
12 | limit: null,
13 | attribute: null,
14 | },
15 | }
16 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/locations/location-detail/constants.ts:
--------------------------------------------------------------------------------
1 | export const LOCATION_DETAILS_FIELD =
2 | "name,*sales_channels,*address,fulfillment_sets.type,fulfillment_sets.name,*fulfillment_sets.service_zones.geo_zones,*fulfillment_sets.service_zones,*fulfillment_sets.service_zones.shipping_options,*fulfillment_sets.service_zones.shipping_options.rules,*fulfillment_sets.service_zones.shipping_options.shipping_profile,*fulfillment_providers"
3 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/shipping-option-types/shipping-option-type-create/shipping-option-type-create.tsx:
--------------------------------------------------------------------------------
1 | import { RouteFocusModal } from "../../../components/modals"
2 | import { CreateShippingOptionTypeForm } from "./components/create-shipping-option-type-form"
3 |
4 | export const ShippingOptionTypeCreate = () => {
5 | return (
6 |
7 |
8 |
9 | )
10 | }
11 |
--------------------------------------------------------------------------------
/packages/nocto/.gitignore:
--------------------------------------------------------------------------------
1 | #Medusa Upstream
2 | upstream
3 |
4 | # Logs
5 | logs
6 | *.log
7 | npm-debug.log*
8 | yarn-debug.log*
9 | yarn-error.log*
10 | pnpm-debug.log*
11 | lerna-debug.log*
12 |
13 | node_modules
14 | dist
15 | dist-ssr
16 | *.local
17 |
18 | # Editor directories and files
19 | .vscode/*
20 | !.vscode/extensions.json
21 | .idea
22 | .DS_Store
23 | *.suo
24 | *.ntvs*
25 | *.njsproj
26 | *.sln
27 | *.sw?
28 | .vercel
29 | .yarn
30 |
--------------------------------------------------------------------------------
/packages/nocto/src/components/data-grid/context/use-data-grid-context.tsx:
--------------------------------------------------------------------------------
1 | import { useContext } from "react"
2 | import { DataGridContext } from "./data-grid-context"
3 |
4 | export const useDataGridContext = () => {
5 | const context = useContext(DataGridContext)
6 |
7 | if (!context) {
8 | throw new Error(
9 | "useDataGridContext must be used within a DataGridContextProvider"
10 | )
11 | }
12 |
13 | return context
14 | }
15 |
--------------------------------------------------------------------------------
/packages/nocto/src/plugins/custom/order-detail-slot-1/index.tsx:
--------------------------------------------------------------------------------
1 | import { ConfigSchema } from "./plugin";
2 |
3 | export const myPlugin = {
4 | id: "@my-plugin",
5 | configSchema: ConfigSchema,
6 | routes: () => [
7 | {
8 | path: "/my-plugin",
9 | layout: "main",
10 | lazy: () =>
11 | import("./plugin").then((mod) => ({
12 | Component: () => mod.default(),
13 | })),
14 | },
15 | ],
16 | }
17 |
--------------------------------------------------------------------------------
/packages/nocto/src/plugins/extensions/draft-orders/components/modals/stacked-modal-provider/stacked-modal-context.tsx:
--------------------------------------------------------------------------------
1 | import { createContext } from "react"
2 |
3 | type StackedModalState = {
4 | getIsOpen: (id: string) => boolean
5 | setIsOpen: (id: string, open: boolean) => void
6 | register: (id: string) => void
7 | unregister: (id: string) => void
8 | }
9 |
10 | export const StackedModalContext = createContext(null)
11 |
--------------------------------------------------------------------------------
/packages/nocto/src/components/modals/stacked-modal-provider/use-stacked-modal.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react"
2 | import { StackedModalContext } from "./stacked-modal-context"
3 |
4 | export const useStackedModal = () => {
5 | const context = useContext(StackedModalContext)
6 |
7 | if (!context) {
8 | throw new Error(
9 | "useStackedModal must be used within a StackedModalProvider"
10 | )
11 | }
12 |
13 | return context
14 | }
15 |
--------------------------------------------------------------------------------
/packages/nocto/src/plugins/extensions/draft-orders/components/modals/route-modal-provider/route-modal-context.tsx:
--------------------------------------------------------------------------------
1 | import { createContext } from "react"
2 |
3 | type RouteModalProviderState = {
4 | handleSuccess: (path?: string) => void
5 | setCloseOnEscape: (value: boolean) => void
6 | __internal: {
7 | closeOnEscape: boolean
8 | }
9 | }
10 |
11 | export const RouteModalProviderContext =
12 | createContext(null)
13 |
--------------------------------------------------------------------------------
/packages/nocto/src/plugins/routes/core/index.tsx:
--------------------------------------------------------------------------------
1 | import { ErrorBoundary } from "../../../components/utilities/error-boundary"
2 | import { RouteEntry } from "@rsc-labs/nocto-plugin-system"
3 |
4 | export const coreRoutes = {
5 | id: "@core-routes",
6 | routes: (): RouteEntry[] => [
7 | {
8 | path: "/",
9 | layout: "main",
10 | errorElement: ,
11 | lazy: () => import("../../../routes/home"),
12 | },
13 | ],
14 | }
--------------------------------------------------------------------------------
/packages/nocto/src/plugins/extensions/draft-orders/components/modals/route-modal-provider/use-route-modal.tsx:
--------------------------------------------------------------------------------
1 | import { useContext } from "react"
2 | import { RouteModalProviderContext } from "./route-modal-context"
3 |
4 | export const useRouteModal = () => {
5 | const context = useContext(RouteModalProviderContext)
6 |
7 | if (!context) {
8 | throw new Error("useRouteModal must be used within a RouteModalProvider")
9 | }
10 |
11 | return context
12 | }
13 |
--------------------------------------------------------------------------------
/packages/nocto/src/plugins/extensions/draft-orders/hooks/api/products.tsx:
--------------------------------------------------------------------------------
1 | import { useQuery } from "@tanstack/react-query"
2 | import { sdk } from "../../lib/queries/sdk"
3 |
4 | export const useProducts = (query: Record) => {
5 | const { data, ...rest } = useQuery({
6 | queryKey: ["products", query],
7 | queryFn: () => {
8 | return sdk.admin.product.list(query)
9 | },
10 | })
11 |
12 | return {
13 | ...data,
14 | ...rest,
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/orders/order-create-claim/components/claim-create-form/item-placeholder.tsx:
--------------------------------------------------------------------------------
1 | export const ItemPlaceholder = () => {
2 | return (
3 |
10 | )
11 | }
12 |
--------------------------------------------------------------------------------
/packages/nocto/src/plugins/extensions/draft-orders/components/modals/stacked-modal-provider/use-stacked-modal.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react"
2 | import { StackedModalContext } from "./stacked-modal-context"
3 |
4 | export const useStackedModal = () => {
5 | const context = useContext(StackedModalContext)
6 |
7 | if (!context) {
8 | throw new Error(
9 | "useStackedModal must be used within a StackedModalProvider"
10 | )
11 | }
12 |
13 | return context
14 | }
15 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/orders/order-create-shipment/components/order-create-shipment-form/constants.ts:
--------------------------------------------------------------------------------
1 | import { z } from "zod"
2 |
3 | export const CreateShipmentSchema = z.object({
4 | labels: z.array(
5 | z.object({
6 | tracking_number: z.string(),
7 | // TODO: this 2 are not optional in the API
8 | tracking_url: z.string().optional(),
9 | label_url: z.string().optional(),
10 | })
11 | ),
12 | send_notification: z.boolean().optional(),
13 | })
14 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/orders/order-list/const.ts:
--------------------------------------------------------------------------------
1 | export const DEFAULT_PROPERTIES = [
2 | "id",
3 | "status",
4 | "created_at",
5 | "email",
6 | "display_id",
7 | "custom_display_id",
8 | "payment_status",
9 | "fulfillment_status",
10 | "total",
11 | "currency_code",
12 | ]
13 |
14 | export const DEFAULT_RELATIONS = ["*customer", "*sales_channel"]
15 |
16 | export const DEFAULT_FIELDS = `${DEFAULT_PROPERTIES.join(
17 | ","
18 | )},${DEFAULT_RELATIONS.join(",")}`
19 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/settings/settings.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect } from "react"
2 | import { Outlet, useLocation, useNavigate } from "react-router-dom"
3 |
4 | export const Settings = () => {
5 | const navigate = useNavigate()
6 | const location = useLocation()
7 |
8 | useEffect(() => {
9 | if (location.pathname === "/settings") {
10 | navigate("/settings/store", { replace: true })
11 | }
12 | }, [location.pathname, navigate])
13 |
14 | return
15 | }
16 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/locations/common/components/shipping-option-price-provider/shipping-option-price-context.tsx:
--------------------------------------------------------------------------------
1 | import { createContext } from "react"
2 | import { ConditionalPriceInfo } from "../../types"
3 |
4 | type ShippingOptionPriceContextType = {
5 | onOpenConditionalPricesModal: (info: ConditionalPriceInfo) => void
6 | onCloseConditionalPricesModal: () => void
7 | }
8 |
9 | export const ShippingOptionPriceContext =
10 | createContext(null)
11 |
--------------------------------------------------------------------------------
/packages/nocto/src/hooks/table/filters/use-promotion-table-filters.tsx:
--------------------------------------------------------------------------------
1 | import { useTranslation } from "react-i18next"
2 | import { Filter } from "../../../components/table/data-table"
3 |
4 | export const usePromotionTableFilters = () => {
5 | const { t } = useTranslation()
6 |
7 | let filters: Filter[] = [
8 | { label: t("fields.createdAt"), key: "created_at", type: "date" },
9 | { label: t("fields.updatedAt"), key: "updated_at", type: "date" },
10 | ]
11 |
12 | return filters
13 | }
14 |
--------------------------------------------------------------------------------
/packages/nocto/src/i18n/config.ts:
--------------------------------------------------------------------------------
1 | import { InitOptions } from "i18next"
2 |
3 | export const defaultI18nOptions: InitOptions = {
4 | debug: process.env.NODE_ENV === "development",
5 | detection: {
6 | caches: ["cookie", "localStorage", "header"],
7 | lookupCookie: "lng",
8 | lookupLocalStorage: "lng",
9 | order: ["cookie", "localStorage", "header"],
10 | },
11 | fallbackLng: "en",
12 | fallbackNS: "translation",
13 | interpolation: {
14 | escapeValue: false,
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/products/product-media/components/product-media-view/use-product-media-view.tsx:
--------------------------------------------------------------------------------
1 | import { useContext } from "react"
2 | import { ProductMediaViewContext } from "./product-media-view-context"
3 |
4 | export const useProductMediaView = () => {
5 | const context = useContext(ProductMediaViewContext)
6 |
7 | if (!context) {
8 | throw new Error(
9 | "useProductMediaView must be used within a ProductMediaViewProvider"
10 | )
11 | }
12 |
13 | return context
14 | }
15 |
--------------------------------------------------------------------------------
/packages/nocto/src/components/search/types.ts:
--------------------------------------------------------------------------------
1 | import { SEARCH_AREAS } from "./constants"
2 |
3 | export type SearchArea = (typeof SEARCH_AREAS)[number]
4 |
5 | export type DynamicSearchResultItem = {
6 | id: string
7 | title: string
8 | subtitle?: string
9 | to: string
10 | thumbnail?: string
11 | value: string
12 | }
13 |
14 | export type DynamicSearchResult = {
15 | area: SearchArea
16 | title: string
17 | hasMore: boolean
18 | count: number
19 | items: DynamicSearchResultItem[]
20 | }
21 |
--------------------------------------------------------------------------------
/packages/nocto/src/lib/rma.ts:
--------------------------------------------------------------------------------
1 | import { AdminOrderLineItem } from "@medusajs/types"
2 |
3 | export function getReturnableQuantity(item: AdminOrderLineItem): number {
4 | const {
5 | delivered_quantity,
6 | return_received_quantity,
7 | return_dismissed_quantity,
8 | return_requested_quantity,
9 | } = item.detail
10 |
11 | return (
12 | delivered_quantity -
13 | (return_received_quantity +
14 | return_requested_quantity +
15 | return_dismissed_quantity)
16 | )
17 | }
18 |
--------------------------------------------------------------------------------
/packages/nocto/src/routes/customer-groups/customer-group-add-customers/customer-group-add-customers.tsx:
--------------------------------------------------------------------------------
1 | import { useParams } from "react-router-dom"
2 | import { RouteFocusModal } from "../../../components/modals"
3 | import { AddCustomersForm } from "./components/add-customers-form"
4 |
5 | export const CustomerGroupAddCustomers = () => {
6 | const { id } = useParams()
7 |
8 | return (
9 |
10 |
11 |
12 | )
13 | }
14 |
--------------------------------------------------------------------------------