Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Oct 31, 2024
1 parent 575684c commit 1e12c9b
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 90 deletions.
40 changes: 8 additions & 32 deletions apps/www/src/components/types/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { useSheetStack } from "@/hooks/use-sheet-stack";
import { ConfirmationModal } from "@/components/confirmation-modal";
import { InspectThing } from "../thing/inspect";
import { useAccount } from "@/lib/providers/jazz";
import { useType } from "@/lib/graph";
import { InspectType } from "./inspect";

export const typesColumns: ColumnDef<unknown>[] = [
{
Expand All @@ -39,49 +41,23 @@ export const typesColumns: ColumnDef<unknown>[] = [
{
id: "actions",
cell: ({ row }) => {
const thing = row.original as Thing;
const type = row.original;
console.log("type", type)

const { openSheet } = useSheetStack();
const { openModal } = useModalStack();

const handleEditClick = () => {
openSheet(
EditThing,
{ thing },
{
title: "Edit Thing",
description: "Select confirm when you're done"
}
);
};

const handleInspectClick = () => {
openSheet(
InspectThing,
{ thing },
InspectType,
{ typeId: type.id },
{
title: "Inspect Type",
description: "Select confirm when you're done"
}
);
};

const handleDeleteClick = () => {
console.log("deleting...");
openModal(
ConfirmationModal,
{
onConfirm: () => {
deleteItem(thing);
},
onCancel: () => {}
},
{
title: "Are you sure you want to delete this?",
description: "Please confirm your selection."
}
);
};

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
Expand All @@ -93,7 +69,7 @@ export const typesColumns: ColumnDef<unknown>[] = [
<DropdownMenuContent align="end">
<DropdownMenuLabel>Actions</DropdownMenuLabel>
<DropdownMenuItem
onClick={() => navigator.clipboard.writeText(thing.id)}
onClick={() => navigator.clipboard.writeText(type.id)}
>
Copy ID
</DropdownMenuItem>
Expand Down
25 changes: 25 additions & 0 deletions apps/www/src/components/types/inspect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useType } from "@/lib/graph";
import { ThingSchema } from "@/lib/schema";
import { FormGenerator } from "../form/generator";

interface InspectTypeProps {
typeId: string;
}

export const InspectType: React.FC<InspectTypeProps> = ({ typeId }) => {
const { data, isLoading, isError } = useType({ typeId });

if (isLoading) {
return <p>Loading...</p>;
}

if (isError) {
return <p>Failed to load types</p>;
}

return (
<>
<FormGenerator data={data} schema={ThingSchema} readonly />
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function InventoryPage() {

return (
<>
<div className="flex gap-2">
<div className="flex gap-2 mb-2">
<Button
onClick={handleShareInventory}
disabled={
Expand Down
107 changes: 50 additions & 57 deletions apps/www/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { defineConfig } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";

export default defineConfig(({ mode }) => {
const isDevelopment = mode === "development";

return {
plugins: [
TanStackRouterVite(),
Expand All @@ -20,65 +18,60 @@ export default defineConfig(({ mode }) => {
}
},
server: {
...(isDevelopment && {
// Local development server settings
host: "every.near.page",
https: {
key: fs.readFileSync("./_wildcard.near.page-key.pem"),
cert: fs.readFileSync("./_wildcard.near.page.pem")
},
proxy: {
"/web4": {
target: "https://localhost:3000",
secure: false,
changeOrigin: true,
ws: true,
configure: (proxy, options) => {
// Add error logging for /web4 proxy
proxy.on("error", (err, req, res) => {
console.error("proxy error", err);
});
// Local development server settings
host: "every.near.page",
https: {
key: fs.readFileSync("./_wildcard.near.page-key.pem"),
cert: fs.readFileSync("./_wildcard.near.page.pem")
},
proxy: {
"/web4": {
target: "https://localhost:3000",
secure: false,
changeOrigin: true,
ws: true,
configure: (proxy, options) => {
console.log("RUNNING?")
// Add error logging for /web4 proxy
proxy.on("error", (err, req, res) => {
console.error("proxy error", err);
});

proxy.on("proxyReq", (proxyReq, req, res, options) => {
// Ensure proper host header
proxyReq.setHeader("Host", "every.near.page");
console.log("Outgoing cookies:", req.headers.cookie);
});
proxy.on("proxyReq", (proxyReq, req, res, options) => {
// Ensure proper host header
proxyReq.setHeader("Host", "every.near.page");
console.log("Outgoing cookies:", req.headers.cookie);
});

proxy.on("proxyRes", (proxyRes, req, res) => {
console.log("Incoming cookies:", proxyRes.headers["set-cookie"]);
proxy.on("proxyRes", (proxyRes, req, res) => {
console.log("Incoming cookies:", proxyRes.headers["set-cookie"]);

if (proxyRes.headers["set-cookie"]) {
proxyRes.headers["set-cookie"] = proxyRes.headers[
"set-cookie"
].map((cookie) =>
cookie.replace("Secure;", "Secure; SameSite=None;")
);
}
if (proxyRes.headers["set-cookie"]) {
proxyRes.headers["set-cookie"] = proxyRes.headers[
"set-cookie"
].map((cookie) =>
cookie.replace("Secure;", "Secure; SameSite=None;")
);
}

proxyRes.headers["Access-Control-Allow-Origin"] = "*";
proxyRes.headers["Access-Control-Allow-Methods"] =
"GET,HEAD,PUT,PATCH,POST,DELETE";
proxyRes.headers["Access-Control-Allow-Headers"] =
"Content-Type, Authorization";
proxyRes.headers["Access-Control-Allow-Credentials"] = "true";
});
},
headers: {
Connection: "keep-alive",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
"Access-Control-Allow-Credentials": "true"
}
proxyRes.headers["Access-Control-Allow-Origin"] = "*";
proxyRes.headers["Access-Control-Allow-Methods"] =
"GET,HEAD,PUT,PATCH,POST,DELETE";
proxyRes.headers["Access-Control-Allow-Headers"] =
"Content-Type, Authorization";
proxyRes.headers["Access-Control-Allow-Credentials"] = "true";
});
},
headers: {
Connection: "keep-alive",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
"Access-Control-Allow-Credentials": "true"
}
}
}),
proxy: {
"/ai": isDevelopment
? "http://localhost:3005"
: "https://everything-api-production.up.railway.app"
},
"/ai": "http://localhost:3005"
}
}
};
});
}
});

0 comments on commit 1e12c9b

Please sign in to comment.