Skip to content

Commit

Permalink
added hardcoded campaign specific prices. TODO: need to move them to …
Browse files Browse the repository at this point in the history
…db campaign config (#1450)
  • Loading branch information
quantum-grit authored Jun 19, 2023
1 parent 69c6dad commit 62b3a46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
8 changes: 0 additions & 8 deletions src/common/hooks/donation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { authQueryFnFactory } from 'service/restRequests'
import {
CheckoutSessionInput,
CheckoutSessionResponse,
DonationPrice,
DonationResponse,
DonorsCountResult,
TotalDonatedMoneyResponse,
Expand All @@ -20,13 +19,6 @@ import { createCheckoutSession } from 'service/donation'
import { CampaignDonationHistoryResponse } from 'gql/campaigns'
import { FilterData, PaginationData } from 'gql/types'

export function usePriceList() {
return useQuery<DonationPrice[]>([endpoints.donation.prices.url])
}
export function useSinglePriceList() {
return useQuery<DonationPrice[]>([endpoints.donation.singlePrices.url])
}

export function useDonationSession() {
const { t } = useTranslation()
const mutation = useMutation<
Expand Down
13 changes: 8 additions & 5 deletions src/components/client/one-time-donation/steps/FirstStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Trans, useTranslation } from 'next-i18next'
import { useField, useFormikContext } from 'formik'
import { Box, Collapse, Divider, Grid, InputAdornment, List, Typography } from '@mui/material'
import theme from 'common/theme'
import { useSinglePriceList } from 'common/hooks/donation'
import RadioButtonGroup from 'components/common/form/RadioButtonGroup'
import { moneyPublic, moneyPublicDecimals2, toMoney } from 'common/util/money'
import { ibanNumber } from 'common/iban'
Expand Down Expand Up @@ -43,7 +42,6 @@ const Root = styled('div')(() => ({

export default function FirstStep() {
const { data: session } = useSession()
const { data: oneTimePrices } = useSinglePriceList()
const { t } = useTranslation('one-time-donation')
const mobile = useMediaQuery('(max-width:600px)')
const paymentOptions = [
Expand All @@ -61,6 +59,12 @@ export default function FirstStep() {
const formik = useFormikContext<OneTimeDonation>()

const { campaign } = useContext(StepsContext)

const oneTimePrices =
campaign.slug === 'petar-v-cambridge' //needed specific prices for this campaign
? [2000, 5000, 10000, 20000, 50000, 100000] //TODO: move this to camapign specific config in db
: [1000, 2000, 5000, 10000, 50000, 100000] //these are default values for all other campaigns

const bankAccountInfo = {
owner: t('third-step.owner'),
bank: t('third-step.bank'),
Expand Down Expand Up @@ -185,10 +189,9 @@ export default function FirstStep() {
name="amount"
options={
oneTimePrices
?.sort((a, b) => Number(a.unit_amount) - Number(b.unit_amount))
.map((v) => ({
label: moneyPublic(Number(v.unit_amount)),
value: String(Number(v.unit_amount)),
label: moneyPublic(Number(v)),
value: String(Number(v)),
}))
.concat({ label: t('first-step.other'), value: 'other' }) || []
}
Expand Down

0 comments on commit 62b3a46

Please sign in to comment.