diff --git a/react-spa/bun.lockb b/react-spa/bun.lockb new file mode 100755 index 0000000..70c4c16 Binary files /dev/null and b/react-spa/bun.lockb differ diff --git a/react-spa/public/favicon.png b/react-spa/public/favicon.png new file mode 100644 index 0000000..4f4fd28 Binary files /dev/null and b/react-spa/public/favicon.png differ diff --git a/react-spa/src/main.jsx b/react-spa/src/main.jsx index 39ddd13..e8c9e91 100644 --- a/react-spa/src/main.jsx +++ b/react-spa/src/main.jsx @@ -7,7 +7,8 @@ import { import "./index.css"; import Root from "./routes/root"; import ErrorPage from "./error-page"; -import Contact from "./routes/contact"; +import You from "./routes/you"; +import Friend from "./routes/friend"; const router = createBrowserRouter([ { @@ -16,8 +17,12 @@ const router = createBrowserRouter([ errorElement: , children: [ { - path: "contacts/:contactId", - element: , + path: "you/", + element: , + }, + { + path: "friend/", + element: , }, ], }, diff --git a/react-spa/src/routes/contact.jsx b/react-spa/src/routes/friend.jsx similarity index 88% rename from react-spa/src/routes/contact.jsx rename to react-spa/src/routes/friend.jsx index cac4576..b07ace8 100644 --- a/react-spa/src/routes/contact.jsx +++ b/react-spa/src/routes/friend.jsx @@ -1,11 +1,10 @@ import { Form } from "react-router-dom"; -export default function Contact() { +export default function Friend() { const contact = { - first: "Your", - last: "Name", - avatar: "https://robohash.org/you.png?size=200x200", - twitter: "your_handle", + first: "Wall-e", + last: "Iceberg", + twitter: "@"+"mysten_labs", notes: "Some notes", favorite: true, }; @@ -17,7 +16,7 @@ export default function Contact() { key={contact.avatar} src={ contact.avatar || - `https://robohash.org/${contact.id}.png?size=200x200` + `https://robohash.org/${contact.first+contact.last}.png?size=200x200` } /> diff --git a/react-spa/src/routes/root.jsx b/react-spa/src/routes/root.jsx index 75e334b..17ac089 100644 --- a/react-spa/src/routes/root.jsx +++ b/react-spa/src/routes/root.jsx @@ -31,10 +31,10 @@ export default function Root() { diff --git a/react-spa/src/routes/you.jsx b/react-spa/src/routes/you.jsx new file mode 100644 index 0000000..85ce46b --- /dev/null +++ b/react-spa/src/routes/you.jsx @@ -0,0 +1,91 @@ +import { Form } from "react-router-dom"; + +export default function You() { + const contact = { + first: "Roby", + last: "Walson", + twitter: "@"+"suinetwork", + notes: "Some notes", + favorite: true, + }; + + return ( +
+
+ +
+ +
+

+ {contact.first || contact.last ? ( + <> + {contact.first} {contact.last} + + ) : ( + No Name + )}{" "} + +

+ + {contact.twitter && ( +

+ + {contact.twitter} + +

+ )} + + {contact.notes &&

{contact.notes}

} + +
+
+ +
+
{ + if ( + !confirm( + "Please confirm you want to delete this record." + ) + ) { + event.preventDefault(); + } + }} + > + +
+
+
+
+ ); +} + +function Favorite({ contact }) { + const favorite = contact.favorite; + return ( +
+ +
+ ); +} \ No newline at end of file