Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update react template per discussion #1077

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/fast-experts-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 1 addition & 1 deletion examples/example-react-sdk-2.x/src/AuthCallback.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { auth } from "./client";
import { auth } from "./main";

/**
* Component to render at `/auth/callback`
Expand Down
30 changes: 1 addition & 29 deletions examples/example-react-sdk-2.x/src/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,11 @@
import { $Objects, $Actions, $Queries } from "@osdk/e2e.generated.catchall";
import css from "./Home.module.css";
import Layout from "./Layout";

// import { useOsdkClient } from "@osdk/react";
// import React from "react";
// import { Osdk } from "@osdk/client";

function Home() {

// const client = useOsdkClient();

// const [objects, setObjects] = React.useState<$Objects.Todo.OsdkInstance[]>();
// const [isLoading, setIsLoading] = React.useState(true);

// React.useEffect(() => {
// client($Objects.Todo).fetchPage().then((page) => {
// setObjects(page.data);
// setIsLoading(false);
// });
// }, []);

// if (isLoading) {
// return <Layout>Loading...</Layout>;
// } else {
// return (
// <Layout>
// <ul>
// {objects?.map((o) => (
// <li>{o.$primaryKey} - {o.$title}</li>
// ))}
// </ul>
// </Layout>
// )
// }

// See API Docs on Developer console on how to use the client object to access the ontology resource

const objectApiNames = Object.keys($Objects);
const actionApiNames = Object.keys($Actions);
Expand Down
46 changes: 0 additions & 46 deletions examples/example-react-sdk-2.x/src/client.ts

This file was deleted.

3 changes: 2 additions & 1 deletion examples/example-react-sdk-2.x/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import createClientAndAuth from "./createClientAndAuth";
import "./index.css";
import { router } from "./router";

const { client } = createClientAndAuth();
const { client, auth } = createClientAndAuth();
export { auth };

ReactDOM.createRoot(document.getElementById("root")!).render(
<OsdkProvider client={client}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { auth } from "./client";
import { auth } from "./main";

/**
* Component to render at `/auth/callback`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,11 @@
import { $Objects, $Actions, $Queries } from "{{osdkPackage}}";
import css from "./Home.module.css";
import Layout from "./Layout";

// import { useOsdkClient } from "@osdk/react";
// import React from "react";
// import { Osdk } from "@osdk/client";

function Home() {

// const client = useOsdkClient();

// const [objects, setObjects] = React.useState<$Objects.Todo.OsdkInstance[]>();
// const [isLoading, setIsLoading] = React.useState(true);

// React.useEffect(() => {
// client($Objects.Todo).fetchPage().then((page) => {
// setObjects(page.data);
// setIsLoading(false);
// });
// }, []);

// if (isLoading) {
// return <Layout>Loading...</Layout>;
// } else {
// return (
// <Layout>
// <ul>
// {objects?.map((o) => (
// <li>{o.$primaryKey} - {o.$title}</li>
// ))}
// </ul>
// </Layout>
// )
// }

// See API Docs on Developer console on how to use the client object to access the ontology resource

const objectApiNames = Object.keys($Objects);
const actionApiNames = Object.keys($Actions);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import createClientAndAuth from "./createClientAndAuth";
import "./index.css";
import { router } from "./router";

const { client } = createClientAndAuth();
const { client, auth } = createClientAndAuth();
export { auth };

ReactDOM.createRoot(document.getElementById("root")!).render(
<OsdkProvider client={client}>
Expand Down
2 changes: 1 addition & 1 deletion packages/example-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

Generates examples packages for `@osdk/create-app` and `@osdk/create-widget`.

Run `pnpm generate` to generate packages and `pnpm check` to verify if they are up to date.
Run `pnpm generate` to generate packages and `turbo check` to verify if they are up to date.
4 changes: 2 additions & 2 deletions packages/example-generator/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ async function checkExamples(
for (const q of compareResult.diffSet ?? []) {
if (q.state !== "equal") {
const aPath = q.path1 && q.name1
? path.join(q.path1, q.relativePath, q.name1)
? path.join(q.path1, q.name1)
: null;
const bPath = q.path2 && q.name2
? path.join(q.path2, q.relativePath, q.name2)
? path.join(q.path2, q.name2)
: null;

const aContents = getContents(aPath);
Expand Down
1 change: 1 addition & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
"inputs": [
"bin/**",
"src/**",
"templates/**",
"tsup.config.js",
"tsconfig.json",
"tsconfig.cjs.json"
Expand Down
Loading