Skip to content

Conversation

@blacktoast
Copy link
Contributor

@blacktoast blacktoast commented Dec 15, 2025

Pull Request

Thank you for raising a Pull Request. Please follow the instruction.

  • I’ve read CONTRIBUTING.md and followed the guidelines.

Summary

  • Add a Theme column to the existing Customers table
  • Add the ability to modify the Theme when editing customer information in the CT Dashboard
  • Added @oko-wallet-attached-api/ to enable theme loading via hostOrigin in attached.
  • Modify determineTheme to retrieve the theme from the server via the API and apply the changes.

Links (Issue References, etc, if there's any)

@blacktoast blacktoast requested review from chihunmanse and eldenpark and removed request for chihunmanse December 15, 2025 11:15
@blacktoast blacktoast marked this pull request as ready for review December 15, 2025 11:30
@eldenpark
Copy link
Collaborator

@blacktoast Is this review ready?

@blacktoast
Copy link
Contributor Author

Yes.
Is there anything lacking?

@blacktoast blacktoast marked this pull request as draft December 17, 2025 04:48
@blacktoast blacktoast marked this pull request as ready for review December 22, 2025 05:52
VALUES (
$1, $2, $3,
$4, $5
$4, $5, COALESCE($6, 'system')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we decide the "theme" value in the TS scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the code below, system is assigned when the value is null in the TS scope.

I just added it just in case, Should it be removed?

 try {
    const values = [
      customer.customer_id,
      customer.label,
      customer.status,
      customer.url?.length ? customer.url : null,
      customer.logo_url?.length ? customer.logo_url : null,
      customer.theme ?? "system",
    ];

    const res = await db.query<Customer>(query, values);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the schema definition, PG will automatically insert "system" if nothing is given. Plus, even if there is no "default" value set up in the database side, I'd rather make the system explicitly "fail" if an invalid value (such as undefined) is given.

So for now, I think we can replace w/ just $6

if (updates.theme !== undefined) {
updateFields.push(`theme = $${paramIndex}`);
values.push(updates.theme);
paramIndex++;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try not to use the unary operator. Instead use "+= 1"

import { useAppState } from "@oko-wallet-attached/store/app";

export function useSetThemeInCallback(providerType: OAuthProvider) {
const { setTheme, getTheme } = useAppState();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is "setTheme" used?

eldenpark and others added 3 commits December 22, 2025 01:11
- Since the callback is executed after the attached function is already running on the host,
there is no need to call setTheme here.
@blacktoast blacktoast requested a review from eldenpark December 22, 2025 09:53
@eldenpark
Copy link
Collaborator

@blacktoast Just so we know, I'm quite against the idea of having "attached-api", a separate package. This is a functionality related to "user", so later we may merge this "attached-api"

@eldenpark eldenpark merged commit 568c3b0 into main Dec 22, 2025
3 checks passed
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

Successfully merging this pull request may close these issues.

3 participants