Skip to content

Commit

Permalink
metadata form adjusts
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkplug0025 committed Sep 4, 2024
1 parent f00caec commit 85130c6
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 101 deletions.
68 changes: 0 additions & 68 deletions services/user/AppRegistry/ui/src/components/app-card-list.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { RadioGroup, RadioGroupItem } from "@shadcn/radio-group";

const slugifyOptions = { lower: true, strict: true };

const AppRegistrySchema = z.object({
const AppMetadataSchema = z.object({
icon: z.instanceof(File).nullable(),
name: z.string().min(1, "Name is required"),
shortDescription: z
Expand Down Expand Up @@ -60,9 +60,9 @@ const AppRegistrySchema = z.object({
status: z.enum(["DRAFT", "PUBLISHED", "UNPUBLISHED"]),
});

export type AppRegistryFormData = z.infer<typeof AppRegistrySchema>;
export type AppMetadataFormData = z.infer<typeof AppMetadataSchema>;

export function AppRegistryForm() {
export function AppMetadataForm() {
const navigate = useNavigate();
const location = useLocation() as { state?: { app: RegisteredApp } };
const id = location.state?.app?.id;
Expand All @@ -75,8 +75,8 @@ export function AppRegistryForm() {
const [isSubmitting, setIsSubmitting] = useState(false);
const isUpdating = !!id;

const form = useForm<AppRegistryFormData>({
resolver: zodResolver(AppRegistrySchema),
const form = useForm<AppMetadataFormData>({
resolver: zodResolver(AppMetadataSchema),
defaultValues: {
icon: null,
name: "",
Expand Down Expand Up @@ -117,7 +117,7 @@ export function AppRegistryForm() {
}
}, [isUpdating, location.state, form, selectedAccount, navigate]);

const onSubmit = async (data: AppRegistryFormData) => {
const onSubmit = async (data: AppMetadataFormData) => {
setIsSubmitting(true);

try {
Expand Down
6 changes: 3 additions & 3 deletions services/user/AppRegistry/ui/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from "react-dom/client";
import { createHashRouter, RouterProvider } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

import { Home, About, AppRegistryPage } from "@routes";
import { Home, About, ManageAppMetadataPage } from "@routes";
import { TooltipProvider } from "@shadcn/tooltip";

import DefaultLayout from "./layouts/default";
Expand All @@ -24,12 +24,12 @@ const router = createHashRouter([
},
{
path: "/register",
element: <AppRegistryPage />,
element: <ManageAppMetadataPage />,
children: [],
},
{
path: "/register/:id",
element: <AppRegistryPage />,
element: <ManageAppMetadataPage />,
children: [],
},
{
Expand Down
24 changes: 11 additions & 13 deletions services/user/AppRegistry/ui/src/routes/home.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { AppCardList } from "@components/app-card-list";
import { Separator } from "@shadcn/separator";

import { useEffect } from "react";
import { Button } from "@shadcn/button";
import { useNavigate } from "react-router-dom";

export function Home() {
// const { query, selectedMessage, setSelectedMessageId } =
Expand All @@ -11,18 +9,18 @@ export function Home() {
// setSelectedMessageId("");
// }, []);

const navigate = useNavigate();

const onClickManageAppMetadata = () => {
navigate("/register");
};

return (
<div className="container mx-auto py-8">
<h1 className="mb-2 text-2xl font-bold">Home</h1>

<div className="py-4">Want to register your app?</div>
<a
href="#/register"
className="mb-8 inline-flex h-10 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground ring-offset-background transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"
>
Click Here
</a>
<AppCardList />
<Button onClick={onClickManageAppMetadata}>
Manage App Metadata
</Button>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion services/user/AppRegistry/ui/src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./home";
export * from "./about";
export * from "./register";
export * from "./manage-metadata";
10 changes: 10 additions & 0 deletions services/user/AppRegistry/ui/src/routes/manage-metadata.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AppMetadataForm } from "@components/app-metadata-form";

export function ManageAppMetadataPage() {
return (
<div className="container mx-auto py-8">
<h1 className="mb-6 text-2xl font-bold">Manage App Metadata</h1>
<AppMetadataForm />
</div>
);
}
10 changes: 0 additions & 10 deletions services/user/AppRegistry/ui/src/routes/register.tsx

This file was deleted.

0 comments on commit 85130c6

Please sign in to comment.