Skip to content

Commit

Permalink
fix application create form
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed May 22, 2024
1 parent 55aa7f4 commit 1403856
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 193 deletions.
2 changes: 1 addition & 1 deletion apps/landing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@mattrax/ui": "workspace:*",
"@solidjs/router": "^0.13.3",
"@solidjs/start": "1.0.0-rc.1",
"@tanstack/solid-form": "^0.19.5",
"@tanstack/solid-form": "^0.20.0",
"h3": "^1.11.1",
"solid-js": "^1.8.17",
"vinxi": "=0.3.11",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@solidjs/router": "=0.13.3",
"@solidjs/start": "1.0.0-rc.1",
"@t3-oss/env-core": "^0.10.1",
"@tanstack/solid-form": "^0.19.5",
"@tanstack/solid-form": "^0.20.0",
"@tanstack/solid-query": "^5.36.1",
"@tanstack/solid-query-devtools": "^5.36.1",
"@tanstack/solid-query-persist-client": "^5.36.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { PolymorphicCallbackProps, RadioGroup } from "@kobalte/core";
import {
DialogTriggerOptions,
DialogTriggerRenderProps,
} from "@kobalte/core/dialog";
import { RadioGroup } from "@kobalte/core";
import {
Button,
Input,
Expand All @@ -14,13 +10,15 @@ import {
Tabs,
TabsList,
TabsTrigger,
TabsIndicator,
} from "@mattrax/ui";
import { Form, createZodForm } from "@mattrax/ui/forms";
import { debounce } from "@solid-primitives/scheduled";
import { useNavigate } from "@solidjs/router";
import { createQuery } from "@tanstack/solid-query";
import clsx from "clsx";
import {
type Accessor,
For,
type JSX,
Suspense,
Expand All @@ -30,9 +28,42 @@ import {
} from "solid-js";
import { z } from "zod";
import { trpc } from "~/lib";
import { APPLICATION_TARGETS } from ".";
import { useTenantSlug } from "../../t.[tenantSlug]";

const IOS_APP_SCHEMA = z.object({
results: z.array(
z.object({
artworkUrl512: z.string(),
trackName: z.string(),
sellerName: z.string(),
bundleId: z.string(),
}),
),
});

const APPLICATION_TARGETS = {
iOS: {
display: "iOS/iPad OS",
queryOptions: (search) => ({
queryKey: ["appStoreSearch", search()],
queryFn: async () => {
// TODO: Pagination support
const res = await fetch(
`https://itunes.apple.com/search?${new URLSearchParams({
...(search() && { term: search() }),
entity: "software",
})}`,
);

return IOS_APP_SCHEMA.parse(await res.json());
},
}),
},
} satisfies Record<
string,
{ display: string; queryOptions: (search: Accessor<string>) => any }
>;

export function CreateApplicationSheet(props: {
children?: (props: any) => JSX.Element;
}) {
Expand Down Expand Up @@ -64,12 +95,15 @@ export function CreateApplicationSheet(props: {

const [search, setSearch] = createSignal("");

const query = createQuery(() => ({
...APPLICATION_TARGETS[form.getFieldValue("targetType")].queryOptions(
search,
),
enabled: open(),
}));
const query = createQuery(() => {
// debugger;
return {
...APPLICATION_TARGETS[form.getFieldValue("targetType")].queryOptions(
search,
),
enabled: open(),
};
});

createEffect(() => {
const results = query.data?.results;
Expand Down Expand Up @@ -98,13 +132,14 @@ export function CreateApplicationSheet(props: {
<SheetContent padding="none">
<Form
form={form}
class="h-full"
fieldsetClass="p-6 overflow-hidden space-y-4 h-full flex flex-col"
>
<SheetHeader>
<SheetTitle>Create Application</SheetTitle>
</SheetHeader>
<div class="flex flex-col space-y-1.5">
<form.Field name="targetType">
<form.Field name="targetType" preserveValue>
{(field) => (
<Tabs
value={field().state.value}
Expand All @@ -127,6 +162,7 @@ export function CreateApplicationSheet(props: {
{/*
<TabsTrigger value="macOS">macOS</TabsTrigger>
<TabsTrigger value="windows">Windows</TabsTrigger> */}
<TabsIndicator />
</TabsList>
</Tabs>
)}
Expand All @@ -138,7 +174,7 @@ export function CreateApplicationSheet(props: {
onInput={debounce((e) => setSearch(e.target.value), 200)}
/>
</div>
<form.Field name="targetId">
<form.Field name="targetId" preserveValue>
{(field) => (
<RadioGroup.Root
class="flex-1 overflow-y-auto !mt-1.5"
Expand Down
56 changes: 9 additions & 47 deletions apps/web/src/app/(dash)/o.[orgSlug]/t.[tenantSlug]/apps/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { Button, DropdownMenuTrigger } from "@mattrax/ui";
import { A, type RouteDefinition } from "@solidjs/router";
import { createColumnHelper } from "@tanstack/solid-table";
import { type Accessor, Suspense } from "solid-js";

import { Suspense } from "solid-js";
import { trpc } from "~/lib";
import { PageLayout, PageLayoutHeading } from "~c/PageLayout";
import {
ColumnsDropdown,
StandardTable,
createSearchParamFilter,
createStandardTable,
selectCheckboxColumn,
} from "~c/StandardTable";
import { TableSearchParamsInput } from "~c/TableSearchParamsInput";
import IconCarbonCaretDown from "~icons/carbon/caret-down.jsx";
import { useTenantSlug } from "../../t.[tenantSlug]";
import { cacheMetadata } from "../metadataCache";
import { CreateApplicationSheet } from "./CreateApplicationSheet";

export const route = {
load: ({ params }) => {
Expand Down Expand Up @@ -85,49 +93,3 @@ export default function Page() {
</PageLayout>
);
}

import { Button, DropdownMenuTrigger } from "@mattrax/ui";
import { A, type RouteDefinition } from "@solidjs/router";
import { queryOptions } from "@tanstack/solid-query";

import { z } from "zod";
import { trpc } from "~/lib";
import { PageLayout, PageLayoutHeading } from "~c/PageLayout";
import { TableSearchParamsInput } from "~c/TableSearchParamsInput";
import { useTenantSlug } from "../../t.[tenantSlug]";
import { cacheMetadata } from "../metadataCache";
import { CreateApplicationSheet } from "./CreateApplicationSheet";

const IOS_APP_SCHEMA = z.object({
results: z.array(
z.object({
artworkUrl512: z.string(),
trackName: z.string(),
sellerName: z.string(),
bundleId: z.string(),
}),
),
});

export const APPLICATION_TARGETS = {
iOS: {
display: "iOS/iPad OS",
queryOptions: (search) => ({
queryKey: ["appStoreSearch", search()],
queryFn: async () => {
// TODO: Pagination support
const res = await fetch(
`https://itunes.apple.com/search?${new URLSearchParams({
...(search() && { term: search() }),
entity: "software",
})}`,
);

return IOS_APP_SCHEMA.parse(await res.json());
},
}),
},
} satisfies Record<
string,
{ display: string; queryOptions: (search: Accessor<string>) => any }
>;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"db:rs": "bun run ./apps/web/src/db/rust.ts",
"typecheck": "tsc -b",
"lint": "biome lint .",
"fix": "biome lint --config-path biome.fix.json --apply . || biome format --write .",
"fix": "biome lint --config-path biome.json --apply . && biome format --write . && biome check . --apply",
"format": "biome format --write .",
"prepare": "husky"
},
Expand All @@ -42,12 +42,12 @@
"pnpm": {
"patchedDependencies": {
"@solidjs/[email protected]": "patches/@[email protected]",
"@tanstack/[email protected]": "patches/@[email protected]",
"[email protected]": "patches/[email protected]",
"@react-email/[email protected]": "patches/@[email protected]",
"[email protected]": "patches/[email protected]",
"@solid-mediakit/[email protected]": "patches/@[email protected]",
"@solidjs/[email protected]": "patches/@[email protected]"
"@solidjs/[email protected]": "patches/@[email protected]",
"@tanstack/[email protected]": "patches/@[email protected]"
}
}
}
4 changes: 2 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"dependencies": {
"@kobalte/core": "^0.13.1",
"@solidjs/router": "^0.13.3",
"@tanstack/form-core": "^0.19.5",
"@tanstack/solid-form": "^0.19.5",
"@tanstack/form-core": "^0.20.0",
"@tanstack/solid-form": "^0.20.0",
"@tanstack/zod-form-adapter": "^0.19.5",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
Expand Down
110 changes: 0 additions & 110 deletions patches/@[email protected]

This file was deleted.

Binary file added patches/@[email protected]
Binary file not shown.
Loading

0 comments on commit 1403856

Please sign in to comment.