Skip to content

Commit

Permalink
Continous payment
Browse files Browse the repository at this point in the history
  • Loading branch information
dianafulga committed May 17, 2024
1 parent 9acbf19 commit 6c79b4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
10 changes: 1 addition & 9 deletions src/popup/components/layout/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import React, { useContext, useMemo } from 'react'
import { Link, useLocation } from 'react-router-dom'
import browser from 'webextension-polyfill'
import { ArrowBack, Settings } from '../Icons'
import { Switch } from '../ui/Switch'
import { ROUTES_PATH } from '@/popup/Popup'
import { PopupStateContext, ReducerActionType } from '@/popup/lib/context'
import { toggleWM } from '@/popup/lib/messages'
import { PopupStateContext } from '@/popup/lib/context'

const Logo = browser.runtime.getURL('assets/images/logo.svg')

Expand All @@ -30,11 +28,6 @@ const NavigationButton = () => {
}

export const Header = () => {
const { state, dispatch } = useContext(PopupStateContext)
const onChange = async () => {
await toggleWM()
dispatch({ type: ReducerActionType.TOGGLE_WM, data: {} })
}
return (
<header className="flex h-8 flex-row items-center justify-between">
<div className="flex flex-row items-center gap-3">
Expand All @@ -43,7 +36,6 @@ export const Header = () => {
</div>
<div className="flex flex-row items-center gap-3">
<NavigationButton />
<Switch checked={state.enabled} onChange={onChange} />
</div>
</header>
)
Expand Down
15 changes: 13 additions & 2 deletions src/popup/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import React from 'react'
import { PopupStateContext, ReducerActionType } from '@/popup/lib/context'
import { WarningSign } from '@/popup/components/Icons'
import { Slider } from '../components/ui/Slider'
import { updateRateOfPay as updateRateOfPay_ } from '../lib/messages'
import { toggleWM, updateRateOfPay as updateRateOfPay_ } from '../lib/messages'
import { Label } from '../components/ui/Label'
import { getCurrencySymbol, roundWithPrecision } from '../lib/utils'
import { debounceAsync } from '@/shared/helpers'
import { PayWebsiteForm } from '../components/PayWebsiteForm'
import { Switch } from '../components/ui/Switch'

const updateRateOfPay = debounceAsync(updateRateOfPay_, 500);
const updateRateOfPay = debounceAsync(updateRateOfPay_, 500)

export const Component = () => {
const {
Expand Down Expand Up @@ -46,6 +47,11 @@ export const Component = () => {
}
}

const onChangeWM = () => {
toggleWM()
dispatch({ type: ReducerActionType.TOGGLE_WM, data: {} })
}

return (
<div className="space-y-8">
{enabled ? (
Expand Down Expand Up @@ -74,6 +80,11 @@ export const Component = () => {
</p>
</div>
)}
<Switch
checked={enabled}
onChange={onChangeWM}
label="Continous payment stream"
/>

<hr />

Expand Down

0 comments on commit 6c79b4b

Please sign in to comment.