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

Client: Fix hard-coded qualifier dropdown options #14

Open
jdtech3 opened this issue Jun 29, 2023 · 2 comments
Open

Client: Fix hard-coded qualifier dropdown options #14

jdtech3 opened this issue Jun 29, 2023 · 2 comments
Assignees

Comments

@jdtech3
Copy link
Contributor

jdtech3 commented Jun 29, 2023

Migrate to pulling qualifier options from server (new API endpoints required) rather than hard-coding the values. This logic will have to be implemented once editing is enabled.

@jdtech3 jdtech3 self-assigned this Jun 29, 2023
@jdtech3 jdtech3 added this to the Read-Write (Build V2) milestone Jun 29, 2023
@DM1122
Copy link
Contributor

DM1122 commented Nov 4, 2023

@dosu-bot how can this feature be implemented?

Copy link

dosubot bot commented Nov 5, 2023

🤖

To migrate from hard-coded qualifier dropdown options to pulling them from the server, you'll need to make use of the Notion API client that the application is already interacting with.

First, you'll need to create a new API endpoint that will return the qualifier options. This can be done in the server-side code of your application. The endpoint should interact with the Notion API to fetch the necessary data.

Here's a basic example of how you might set up this endpoint:

const { Client } = require("@notionhq/client");

// Initialize Notion client
const notion = new Client({ auth: process.env.NOTION_TOKEN });

app.get('/api/qualifiers', async (req, res) => {
  const databaseId = process.env.NOTION_DATABASE_ID;
  const response = await notion.databases.query({ database_id: databaseId });
  
  // Extract qualifier options from response
  const qualifiers = response.results.map(result => result.properties.Qualifier.select.name);
  
  res.json(qualifiers);
});

In this example, the endpoint /api/qualifiers fetches data from a Notion database and extracts the qualifier options, which are then returned in the response.

Next, you'll need to modify the client-side code to fetch the qualifier options from this new endpoint instead of using the hard-coded values. This can be done using the fetch function or any HTTP client like axios.

Here's how you might modify the inspector.component.ts file:

qualifiers: string[] = [];

ngOnInit() {
  this.fetchQualifiers();
}

fetchQualifiers() {
  fetch('/api/qualifiers')
    .then(response => response.json())
    .then(data => this.qualifiers = data)
    .catch(error => console.error('Error:', error));
}

In this example, the fetchQualifiers method fetches the qualifier options from the new endpoint and assigns them to the qualifiers array. This method is called in the ngOnInit lifecycle hook, so the qualifiers are fetched when the component is initialized.

Please note that this is a basic example and might need to be adjusted based on your application's structure and requirements. Also, remember to handle errors and edge cases appropriately in your actual implementation.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants