diff --git a/src/components/ResourceTable.tsx b/src/components/ResourceTable.tsx
index f6ce3a9..9d15515 100644
--- a/src/components/ResourceTable.tsx
+++ b/src/components/ResourceTable.tsx
@@ -1,15 +1,10 @@
import {
type PlatformLink,
- type PaymentType,
type AuditoryResource,
type Skill,
type SkillLevel,
type Manufacturer,
} from "@prisma/client";
-import {
- CurrencyDollarIcon,
- ArrowPathRoundedSquareIcon,
-} from "@heroicons/react/24/solid";
import { ClipboardDocumentListIcon } from "@heroicons/react/24/outline";
import Image from "next/image";
import Link from "next/link";
@@ -18,6 +13,7 @@ import { type ChangeEvent } from "react";
import { ChevronDownIcon } from "@heroicons/react/24/outline";
import { type ParsedUrlQuery, type ParsedUrlQueryInput } from "querystring";
import { useRouter } from "next/router";
+import { PriceIcon } from "~/prices/Icons";
export const ResourceInfo = ({
resource,
@@ -26,34 +22,6 @@ export const ResourceInfo = ({
resource: AuditoryResource;
showMoreInfo?: boolean;
}) => {
- const PriceIcons = ({ type }: { type: PaymentType }) => {
- switch (type) {
- case "FREE": {
- return (
-
-
- free
-
-
- );
- }
- case "SUBSCRIPTION_MONTHLY": {
- ;
- }
- case "SUBSCRIPTION_WEEKLY": {
- return (
-
- );
- }
- }
- };
-
const PlatformInfo = ({
platformLinks,
}: {
@@ -105,7 +73,7 @@ export const ResourceInfo = ({
{resource.name}
-
+
diff --git a/src/components/admin/resources/form.tsx b/src/components/admin/resources/form.tsx
index ba1f2f2..3ab1603 100644
--- a/src/components/admin/resources/form.tsx
+++ b/src/components/admin/resources/form.tsx
@@ -1,7 +1,13 @@
-import { type AuditoryResource } from "@prisma/client";
+import { PaymentType, type AuditoryResource } from "@prisma/client";
import Image from "next/image";
import { PencilSquareIcon } from "@heroicons/react/24/solid";
-import { useState } from "react";
+import {
+ MultiSelector,
+ MultiSelectorContext,
+ MultiSelectorOption,
+} from "../../forms/selectors";
+import { InfoInputLine } from "~/components/forms/textInput";
+import { PriceIcon } from "~/prices/Icons";
/**
* Renders the image selector for resource form.
@@ -56,29 +62,38 @@ const ResourceLinkSubForm = ({}) => {
);
};
-/**
- * Single line input for the fields found to the right of the
- * resource logo.
- */
-const InfoInputLine = ({
- value,
- placeholder,
+const PaymentTypeOption = ({
+ type,
+ label,
}: {
- value: string;
- placeholder: string;
+ type: PaymentType;
+ label: string;
}) => {
- const [currentValue, setCurrentValue] = useState(value);
-
return (
- {
- setCurrentValue(event.target.value);
- }}
- placeholder={placeholder}
- value={currentValue}
- type="text"
- className="w-full border-b border-neutral-300 px-2"
- />
+
+
+ {({ selected }) => (
+
+ )}
+
+
);
};
@@ -91,41 +106,67 @@ const ResourceSummarySubForm = ({
resource?: AuditoryResource;
}) => {
return (
- <>
-
+
+
-
+
-
-
+
+
Edit the fields above
-
-
-
- Ages {/** Age range here */}
-
+
- >
+
);
};
+// TODO:
+// const ResourceDescriptionSubForm = ({
+// resource,
+// }: {
+// resource?: AuditoryResource;
+// }) => {
+// return
;
+// };
+
const ResourceForm = ({ resource }: { resource?: AuditoryResource }) => {
return (
{/** //resource={resource} /> */}
-
diff --git a/src/components/forms/selectors.tsx b/src/components/forms/selectors.tsx
new file mode 100644
index 0000000..e258099
--- /dev/null
+++ b/src/components/forms/selectors.tsx
@@ -0,0 +1,61 @@
+import { createContext, useContext, useState } from "react";
+
+// Define contexts
+const MultiSelectorContext = createContext({
+ selected: "",
+ updateCallback: (_value: string) => {
+ return;
+ },
+});
+
+function MultiSelector
string }>({
+ label,
+ defaultValue,
+ children,
+}: {
+ label: string;
+ defaultValue: T;
+ children: undefined | JSX.Element | JSX.Element[];
+}) {
+ const [selected, setSelected] = useState(defaultValue.toString());
+
+ return (
+
+
+
+
+ Select one from below
+
+
+
+ {children}
+
+
+
+ );
+}
+
+function MultiSelectorOption string }>({
+ value,
+ children,
+}: {
+ value: T;
+ children: undefined | JSX.Element | JSX.Element[];
+}) {
+ const { updateCallback } = useContext(MultiSelectorContext);
+
+ return (
+
+ );
+}
+
+export { MultiSelectorContext, MultiSelector, MultiSelectorOption };
diff --git a/src/components/forms/textInput.tsx b/src/components/forms/textInput.tsx
new file mode 100644
index 0000000..21a92ac
--- /dev/null
+++ b/src/components/forms/textInput.tsx
@@ -0,0 +1,38 @@
+import { useState } from "react";
+
+/**
+ * Single line input for the fields found to the right of the
+ * resource logo.
+ */
+const InfoInputLine = ({
+ value,
+ placeholder,
+ hint,
+}: {
+ value: string;
+ placeholder: string;
+ hint?: string;
+}) => {
+ const [currentValue, setCurrentValue] = useState(value);
+
+ return (
+
+ {
+ setCurrentValue(event.target.value);
+ }}
+ placeholder={placeholder}
+ value={currentValue}
+ type="text"
+ className="w-full border-b border-neutral-300 px-2"
+ />
+
+
+ );
+};
+
+export { InfoInputLine };
diff --git a/src/prices/Icons.tsx b/src/prices/Icons.tsx
new file mode 100644
index 0000000..3a6f4bf
--- /dev/null
+++ b/src/prices/Icons.tsx
@@ -0,0 +1,35 @@
+import { type PaymentType } from "@prisma/client";
+import {
+ CurrencyDollarIcon,
+ ArrowPathRoundedSquareIcon,
+} from "@heroicons/react/24/solid";
+
+const PriceIcon = ({ type }: { type: PaymentType }) => {
+ switch (type) {
+ case "FREE": {
+ return (
+
+
+ free
+
+
+ );
+ }
+ case "SUBSCRIPTION_MONTHLY": {
+ ;
+ }
+ case "SUBSCRIPTION_WEEKLY": {
+ return (
+
+ );
+ }
+ }
+};
+
+export { PriceIcon };