Skip to content

Commit

Permalink
Improve wac url implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
yuli-ferna committed Nov 26, 2024
1 parent ea41874 commit f1e2fda
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
app-domain:
type: string
default: "portalbridge.com"
wac-url:
wac-url-template:
type: string
default: "https://wac.staging.gfx.town"
project-branch:
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
- name: Build Rewards Dashboard
env:
PUBLIC_URL: ${{ inputs.public-url }}
VITE_WAC_URL: ${{ inputs.wac-url }}
VITE_WAC_URL_TEMPLATE: ${{ inputs.wac-url-template }}
VITE_APP_WALLET_CONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}
VITE_APP_DOMAIN: ${{ inputs.app-domain }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
advanced-tools-branch: advanced-tools
environment: Cloudflare-Preview
public-url: "/${{ needs.branch-sha.outputs.value }}"
wac-url: "https://allez-xyz--usds-"
wac-url-template: "https://allez-xyz--usds-*.modal.run"
project-branch: ${{ github.event.pull_request.head.ref }}
app-domain: preview.portalbridge.com
secrets: inherit
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ jobs:
environment: ${{inputs.environment}}
project-branch: main
public-url: ''
wac-url: "https://allez-xyz--usds-"
wac-url-template: "https://allez-xyz--usds-*.modal.run"
app-domain: portalbridge.com
secrets: inherit
4 changes: 4 additions & 0 deletions apps/rewards-dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ generate lingui:
```
npm run lingui:extract
```

## VITE_WAC_URL_TEMPLATE configuration

Take in account the ENV variable `VITE_WAC_URL_TEMPLATE` is a template of the WAC URL, if you want any part of the URL to be custom, add the symbol `*` (for example: `https://xlabs-*.xyz`), and then use this function `getWACUrl(custom)`, where `custom` is the string that will replace `*`.
10 changes: 7 additions & 3 deletions apps/rewards-dashboard/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export const WAC_URL = import.meta.env.VITE_WAC_URL
? import.meta.env.VITE_WAC_URL
: "https://allez-xyz--usds-";
export const WAC_URL_TEMPLATE = import.meta.env.VITE_WAC_URL_TEMPLATE
? import.meta.env.VITE_WAC_URL_TEMPLATE
: "https://allez-xyz--usds-*.modal.run";

export const getWACUrl = (custom: string) => {
return WAC_URL_TEMPLATE.replace("*", custom);
}
6 changes: 3 additions & 3 deletions apps/rewards-dashboard/src/layouts/DashboardLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { InfoStatWindow, StatWindow } from "../quarks/StatWindow";
import { PortalLogo } from "../quarks/LogoVectors";
import { Trans, t } from "@lingui/macro";
import { useQuery } from "@tanstack/react-query";
import { WAC_URL } from "../constants";
import { getWACUrl } from "../constants";
import { useAppKitAccount } from "@reown/appkit/react";

interface DashboardQueryResult {
Expand Down Expand Up @@ -62,7 +62,7 @@ const ConnectedDashboard = () => {
queryKey: ["overview"],
staleTime: 5000,
queryFn: () => {
return fetch(`${WAC_URL}overview.modal.run`).then((res) => {
return fetch(`${getWACUrl("overview")}`).then((res) => {
return res.json();
});
},
Expand All @@ -72,7 +72,7 @@ const ConnectedDashboard = () => {
enabled: !!address,
staleTime: 5000,
queryFn: () => {
return fetch(`${WAC_URL}usersummary.modal.run?address=${address}`).then(
return fetch(`${getWACUrl("usersummary")}?address=${address}`).then(
(res) => {
return res.json();
}
Expand Down

0 comments on commit f1e2fda

Please sign in to comment.