-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat(frontend): adds vip qr code item to the menu #3990
Merged
BonomoAlessandro
merged 78 commits into
main
from
feature(frontend)/displays-vip-qr-codes-option-in-menu
Jan 7, 2025
Merged
Changes from 74 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
7ca84a2
adds vip qr code item to the menu
BonomoAlessandro 64cfb2e
adds alt text to button
BonomoAlessandro e12f611
removes unused import
BonomoAlessandro 1d7f8c1
resolves lint issue
BonomoAlessandro 1bb1789
resolves lint issue
BonomoAlessandro 872a275
🤖 Apply formatting changes
github-actions[bot] b2b46e9
🤖 Apply bindings changes
github-actions[bot] 401fe5f
makes vip in settings optional
BonomoAlessandro 3db52c7
Merge remote-tracking branch 'origin/feature(frontend)/displays-vip-q…
BonomoAlessandro 0ed7b08
tries to fix tests
BonomoAlessandro 903d651
🤖 Apply formatting changes
github-actions[bot] 446e377
🤖 Apply bindings changes
github-actions[bot] b7c0133
implements tests for vip menu item
BonomoAlessandro 55f3efd
reformat code
BonomoAlessandro 6da0dea
reformat code
BonomoAlessandro ba5e7aa
implements reward canister api
BonomoAlessandro 1fd8a1f
🤖 Apply formatting changes
github-actions[bot] ba49b3b
resolves lint issue
BonomoAlessandro 7ab28ed
🤖 Apply formatting changes
github-actions[bot] 0cec4de
Merge remote-tracking branch 'origin/feature(frontend)/displays-vip-q…
BonomoAlessandro 27b4373
updates backend.did
BonomoAlessandro ebe723e
implements reward canister tests
BonomoAlessandro d0725a5
🤖 Apply formatting changes
github-actions[bot] 983518f
Merge remote-tracking branch 'origin/main' into feature(frontend)/dis…
BonomoAlessandro af68afa
add is_vip function to reward canister
BonomoAlessandro f58477b
🤖 Apply formatting changes
github-actions[bot] 93addf3
Merge remote-tracking branch 'origin/main' into feature(frontend)/imp…
BonomoAlessandro 7560091
implements rewards api
BonomoAlessandro 6d394e9
updates reward canister tests
BonomoAlessandro 63d18aa
🤖 Apply formatting changes
github-actions[bot] a05b56c
implements reward canister
BonomoAlessandro 0b4e930
🤖 Apply formatting changes
github-actions[bot] 6e66f5c
Merge branch 'feature(frontend)/implement-reward-canister' into featu…
BonomoAlessandro 9a1e806
implements reward canister service test cases
BonomoAlessandro e24552c
🤖 Apply formatting changes
github-actions[bot] 063b64e
resolves lint issues
BonomoAlessandro b4f8a50
🤖 Apply formatting changes
github-actions[bot] 056ad5f
resolves lint issues
BonomoAlessandro 516e50c
Merge branch 'main' into feature(frontend)/implements-reward-canister…
BonomoAlessandro a33c282
renames getUserInfo endpoint
BonomoAlessandro 7d56943
Merge remote-tracking branch 'origin/main' into feature(frontend)/imp…
BonomoAlessandro 128805b
adds certified to reward code service
BonomoAlessandro 15e6a1f
🤖 Apply formatting changes
github-actions[bot] 5b0643c
adds rewards canister id
BonomoAlessandro 49d0f2b
changes order of code
BonomoAlessandro 60c50d3
updates reward service test cases
BonomoAlessandro cd4ee86
Merge branch 'main' into feature(frontend)/implements-reward-canister…
BonomoAlessandro 33b3124
fixes service implementation
BonomoAlessandro 067779d
🤖 Apply formatting changes
github-actions[bot] a8b9ef5
renames getVipStatus to isVipUser
BonomoAlessandro 5d1a290
improves service code
BonomoAlessandro e365bef
improves service code
BonomoAlessandro c82c209
implements error handling in service
BonomoAlessandro 61d03a8
reformat code
BonomoAlessandro 7164bc1
handles certified in reward service
BonomoAlessandro dcc7665
reformat code
BonomoAlessandro 25a91e9
🤖 Updated i18n files
github-actions[bot] 5bf2b59
resolves lint issue
BonomoAlessandro 4b8fc89
Merge branch 'main' into feature(frontend)/implements-reward-canister…
BonomoAlessandro 61de068
Merge branch 'main' into feature(frontend)/displays-vip-qr-codes-opti…
BonomoAlessandro 06b40fc
removes redundant data-tid definition
BonomoAlessandro fb48e03
Merge branch 'feature(frontend)/implements-reward-canister-api' into …
BonomoAlessandro 4f93f50
fixes Menu
BonomoAlessandro 220af6d
🤖 Apply formatting changes
github-actions[bot] e143ab7
fixes lint issue
BonomoAlessandro ef35d7f
fixes return values
BonomoAlessandro 362862e
🤖 Apply formatting changes
github-actions[bot] 3623b6b
Merge branch 'feature(frontend)/implements-reward-canister-api' into …
BonomoAlessandro be16955
adds Settings type
BonomoAlessandro ecf90d2
removes unused variables
BonomoAlessandro 9ee5ccb
Merge remote-tracking branch 'origin/main' into feature(frontend)/dis…
BonomoAlessandro 350040d
adds source to IconVipQr.svelte
BonomoAlessandro eeb1455
resolves lint issue
BonomoAlessandro f7a59e1
🤖 Apply formatting changes
github-actions[bot] ed304bd
Merge branch 'main' into feature(frontend)/displays-vip-qr-codes-opti…
BonomoAlessandro e2cb512
Merge branch 'main' into feature(frontend)/displays-vip-qr-codes-opti…
BonomoAlessandro 56e318f
adds TODO
BonomoAlessandro f784523
Merge branch 'main' into feature(frontend)/displays-vip-qr-codes-opti…
BonomoAlessandro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
<script lang="ts"> | ||
import { IconUser, Popover } from '@dfinity/gix-components'; | ||
import { nonNullish } from '@dfinity/utils'; | ||
import type { NavigationTarget } from '@sveltejs/kit'; | ||
import { onMount } from 'svelte'; | ||
import { afterNavigate, goto } from '$app/navigation'; | ||
import { page } from '$app/stores'; | ||
import AboutWhyOisy from '$lib/components/about/AboutWhyOisy.svelte'; | ||
import MenuAddresses from '$lib/components/core/MenuAddresses.svelte'; | ||
import SignOut from '$lib/components/core/SignOut.svelte'; | ||
import IconGitHub from '$lib/components/icons/IconGitHub.svelte'; | ||
import IconVipQr from '$lib/components/icons/IconVipQr.svelte'; | ||
import IconWallet from '$lib/components/icons/IconWallet.svelte'; | ||
import IconActivity from '$lib/components/icons/iconly/IconActivity.svelte'; | ||
import IconlySettings from '$lib/components/icons/iconly/IconlySettings.svelte'; | ||
|
@@ -24,9 +27,12 @@ | |
NAVIGATION_MENU, | ||
NAVIGATION_ITEM_ACTIVITY, | ||
NAVIGATION_ITEM_EXPLORER, | ||
NAVIGATION_ITEM_SETTINGS | ||
NAVIGATION_ITEM_SETTINGS, | ||
NAVIGATION_MENU_VIP_BUTTON | ||
} from '$lib/constants/test-ids.constants'; | ||
import { authIdentity } from '$lib/derived/auth.derived'; | ||
import { networkId } from '$lib/derived/network.derived'; | ||
import { isVipUser } from '$lib/services/reward-code.services'; | ||
import { i18n } from '$lib/stores/i18n.store'; | ||
import { | ||
isRouteActivity, | ||
|
@@ -42,6 +48,17 @@ | |
|
||
let fromRoute: NavigationTarget | null; | ||
|
||
let isVip = false; | ||
onMount(async () => { | ||
if (nonNullish($authIdentity)) { | ||
isVip = ( | ||
await isVipUser({ | ||
identity: $authIdentity | ||
}) | ||
).success; | ||
} | ||
}); | ||
|
||
afterNavigate(({ from }) => { | ||
fromRoute = from; | ||
}); | ||
|
@@ -140,6 +157,17 @@ | |
<Hr /> | ||
{/if} | ||
|
||
{#if isVip} | ||
<ButtonMenu | ||
ariaLabel={$i18n.navigation.alt.vip_qr_code} | ||
testId={NAVIGATION_MENU_VIP_BUTTON} | ||
on:click={() => {}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now nothing happens if the menu button is clicked. This is implemented in another PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just add a |
||
> | ||
<IconVipQr size="20" /> | ||
{$i18n.navigation.text.vip_qr_code} | ||
</ButtonMenu> | ||
{/if} | ||
|
||
<AboutWhyOisy asMenuItem on:icOpenAboutModal={hidePopover} /> | ||
|
||
<ChangelogLink /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<!-- source: DFINITY foundation --> | ||
<script lang="ts"> | ||
export let size = '24'; | ||
</script> | ||
|
||
<svg width={size} height={size} viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M1.83325 3.66683C1.83325 2.65431 2.65406 1.8335 3.66659 1.8335H6.41658C7.42911 1.8335 8.24992 2.65431 8.24992 3.66683V6.41683C8.24992 7.42935 7.42911 8.25016 6.41658 8.25016H3.66659C2.65406 8.25016 1.83325 7.42935 1.83325 6.41683V3.66683ZM6.41658 3.66683H3.66659V6.41683H6.41658V3.66683Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M13.75 3.66683C13.75 2.65431 14.5708 1.8335 15.5833 1.8335H18.3333C19.3459 1.8335 20.1667 2.65431 20.1667 3.66683V6.41683C20.1667 7.42935 19.3459 8.25016 18.3333 8.25016H15.5833C14.5708 8.25016 13.75 7.42935 13.75 6.41683V3.66683ZM18.3333 3.66683H15.5833V6.41683H18.3333V3.66683Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M1.83325 15.5833C1.83325 14.5708 2.65406 13.75 3.66659 13.75H6.41658C7.42911 13.75 8.24992 14.5708 8.24992 15.5833V18.3333C8.24992 19.3459 7.42911 20.1667 6.41658 20.1667H3.66659C2.65406 20.1667 1.83325 19.3459 1.83325 18.3333V15.5833ZM6.41658 15.5833H3.66659V18.3333H6.41658V15.5833Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M14.5555 14.5555C15.0712 14.0397 15.7707 13.75 16.5 13.75H19.25C19.7563 13.75 20.1667 14.1604 20.1667 14.6667C20.1667 15.1729 19.7563 15.5833 19.25 15.5833H16.5C16.2569 15.5833 16.0237 15.6799 15.8518 15.8518C15.6799 16.0237 15.5833 16.2569 15.5833 16.5V19.25C15.5833 19.7563 15.1729 20.1667 14.6667 20.1667C14.1604 20.1667 13.75 19.7563 13.75 19.25V16.5C13.75 15.7707 14.0397 15.0712 14.5555 14.5555Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M19.2499 18.3335C19.7562 18.3335 20.1666 18.7439 20.1666 19.2502V19.2593C20.1666 19.7656 19.7562 20.176 19.2499 20.176C18.7437 20.176 18.3333 19.7656 18.3333 19.2593V19.2502C18.3333 18.7439 18.7437 18.3335 19.2499 18.3335Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M11 5.5C11.5063 5.5 11.9167 5.91041 11.9167 6.41667V9.16667C11.9167 9.89601 11.6269 10.5955 11.1112 11.1112C10.5955 11.6269 9.89601 11.9167 9.16667 11.9167H6.41667C5.91041 11.9167 5.5 11.5063 5.5 11C5.5 10.4937 5.91041 10.0833 6.41667 10.0833H9.16667C9.40978 10.0833 9.64294 9.98676 9.81485 9.81485C9.98676 9.64294 10.0833 9.40978 10.0833 9.16667V6.41667C10.0833 5.91041 10.4937 5.5 11 5.5Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M1.83325 11.0002C1.83325 10.4939 2.24366 10.0835 2.74992 10.0835H2.75909C3.26535 10.0835 3.67575 10.4939 3.67575 11.0002C3.67575 11.5064 3.26535 11.9168 2.75909 11.9168H2.74992C2.24366 11.9168 1.83325 11.5064 1.83325 11.0002Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M10.0833 2.75016C10.0833 2.2439 10.4937 1.8335 10.9999 1.8335H11.0091C11.5153 1.8335 11.9258 2.2439 11.9258 2.75016C11.9258 3.25642 11.5153 3.66683 11.0091 3.66683H10.9999C10.4937 3.66683 10.0833 3.25642 10.0833 2.75016Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M10.9999 13.75C11.5062 13.75 11.9166 14.1604 11.9166 14.6667V14.6758C11.9166 15.1821 11.5062 15.5925 10.9999 15.5925C10.4937 15.5925 10.0833 15.1821 10.0833 14.6758V14.6667C10.0833 14.1604 10.4937 13.75 10.9999 13.75Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M13.75 11.0002C13.75 10.4939 14.1604 10.0835 14.6667 10.0835H15.5833C16.0896 10.0835 16.5 10.4939 16.5 11.0002C16.5 11.5064 16.0896 11.9168 15.5833 11.9168H14.6667C14.1604 11.9168 13.75 11.5064 13.75 11.0002Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M19.2499 10.0835C19.7562 10.0835 20.1666 10.4939 20.1666 11.0002V11.0093C20.1666 11.5156 19.7562 11.926 19.2499 11.926C18.7437 11.926 18.3333 11.5156 18.3333 11.0093V11.0002C18.3333 10.4939 18.7437 10.0835 19.2499 10.0835Z" | ||
fill="black" | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M10.9999 17.4165C11.5062 17.4165 11.9166 17.8269 11.9166 18.3332V19.2498C11.9166 19.7561 11.5062 20.1665 10.9999 20.1665C10.4937 20.1665 10.0833 19.7561 10.0833 19.2498V18.3332C10.0833 17.8269 10.4937 17.4165 10.9999 17.4165Z" | ||
fill="black" | ||
/> | ||
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import type { UserData } from '$declarations/rewards/rewards.did'; | ||
import * as rewardApi from '$lib/api/reward.api'; | ||
import Menu from '$lib/components/core/Menu.svelte'; | ||
import { | ||
NAVIGATION_MENU_BUTTON, | ||
NAVIGATION_MENU_VIP_BUTTON | ||
} from '$lib/constants/test-ids.constants'; | ||
import * as authStore from '$lib/derived/auth.derived'; | ||
import { userProfileStore } from '$lib/stores/user-profile.store'; | ||
import { mockIdentity } from '$tests/mocks/identity.mock'; | ||
import type { Identity } from '@dfinity/agent'; | ||
import { render, waitFor } from '@testing-library/svelte'; | ||
import { beforeEach } from 'node:test'; | ||
import { readable } from 'svelte/store'; | ||
|
||
describe('Menu', () => { | ||
const menuButtonSelector = `button[data-tid="${NAVIGATION_MENU_BUTTON}"]`; | ||
const menuItemVipButtonSelector = `button[data-tid="${NAVIGATION_MENU_VIP_BUTTON}"]`; | ||
|
||
beforeEach(() => { | ||
userProfileStore.reset(); | ||
}); | ||
|
||
const mockAuthStore = (value: Identity | null = mockIdentity) => | ||
vi.spyOn(authStore, 'authIdentity', 'get').mockImplementation(() => readable(value)); | ||
|
||
it('renders the vip menu item', async () => { | ||
const mockedUserData: UserData = { | ||
is_vip: [true], | ||
airdrops: [], | ||
sprinkles: [] | ||
}; | ||
vi.spyOn(rewardApi, 'getUserInfo').mockResolvedValue(mockedUserData); | ||
mockAuthStore(); | ||
|
||
const { container } = render(Menu); | ||
const menuButton: HTMLButtonElement | null = container.querySelector(menuButtonSelector); | ||
|
||
expect(menuButton).toBeInTheDocument(); | ||
|
||
menuButton?.click(); | ||
|
||
await waitFor(() => { | ||
const menuItemVipButton: HTMLButtonElement | null = | ||
container.querySelector(menuItemVipButtonSelector); | ||
if (menuItemVipButton == null) { | ||
throw new Error('menu item not yet loaded'); | ||
} | ||
|
||
expect(menuItemVipButton).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('does not render the vip menu item', async () => { | ||
const mockedUserData: UserData = { | ||
is_vip: [false], | ||
airdrops: [], | ||
sprinkles: [] | ||
}; | ||
vi.spyOn(rewardApi, 'getUserInfo').mockResolvedValue(mockedUserData); | ||
mockAuthStore(); | ||
|
||
const { container } = render(Menu); | ||
const menuButton: HTMLButtonElement | null = container.querySelector(menuButtonSelector); | ||
|
||
expect(menuButton).toBeInTheDocument(); | ||
|
||
menuButton?.click(); | ||
|
||
await waitFor(() => { | ||
const menuItemVipButton: HTMLButtonElement | null = | ||
container.querySelector(menuItemVipButtonSelector); | ||
if (menuItemVipButton == null) { | ||
expect(menuItemVipButton).toBeNull(); | ||
} else { | ||
throw new Error('menu item loaded'); | ||
} | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this run everytime we open the
Menu
? should it be maybe a state somewhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm it might be a good idea to but it into a state instead of calling every time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AntonioVentilii ok nevermind. I don't think that it is necessary to store the state somewhere. The Menu item is only loaded one time and the vip data are loaded in the
onMount
function.