Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,24 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v6.66.0](https://github.com/opengovsg/FormSG/compare/v6.65.0...v6.66.0)

- fix(deps): [Snyk] Security upgrade mongoose from 5.13.15 to 5.13.20 [`#6541`](https://github.com/opengovsg/FormSG/pull/6541)
- feat: indicate if GST has been applied to a payment transaction [`#6538`](https://github.com/opengovsg/FormSG/pull/6538)
- chore: reduce max payment limit [`#6543`](https://github.com/opengovsg/FormSG/pull/6543)
- fix: updating csp to fix bypass [`#6535`](https://github.com/opengovsg/FormSG/pull/6535)
- build(deps): bump winston-cloudwatch version to "6.2.0" [`#6542`](https://github.com/opengovsg/FormSG/pull/6542)
- feat: add description to form issue modal [`#6536`](https://github.com/opengovsg/FormSG/pull/6536)
- fix: presub remove additional underscore [`#6533`](https://github.com/opengovsg/FormSG/pull/6533)
- feat: presub-change-icon-to-help [`#6532`](https://github.com/opengovsg/FormSG/pull/6532)
- build: merge v6.65.0 into develop [`#6531`](https://github.com/opengovsg/FormSG/pull/6531)
- build: release v6.65.0 [`#6528`](https://github.com/opengovsg/FormSG/pull/6528)
- fix: add FE validation rule that email domains must be non empty [`#6529`](https://github.com/opengovsg/FormSG/pull/6529)

#### [v6.65.0](https://github.com/opengovsg/FormSG/compare/v6.64.0...v6.65.0)

> 11 July 2023

- fix: issue report icon for mobile [`#6527`](https://github.com/opengovsg/FormSG/pull/6527)
- feat: Create issue feedback UI on public form interface [`#6452`](https://github.com/opengovsg/FormSG/pull/6452)
- chore: variable payments UI review changes [`#6524`](https://github.com/opengovsg/FormSG/pull/6524)
Expand All @@ -26,6 +42,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- build: release v6.64.0 [`#6509`](https://github.com/opengovsg/FormSG/pull/6509)
- chore: fix typo maxmium -> maximum [`#6510`](https://github.com/opengovsg/FormSG/pull/6510)
- feat: deep link myinfo settings message in builder [`#6503`](https://github.com/opengovsg/FormSG/pull/6503)
- chore: bump version to v6.65.0 [`3ca3ca7`](https://github.com/opengovsg/FormSG/commit/3ca3ca76a7d347953ea5b4153de4575c2f4be3c0)

#### [v6.64.0](https://github.com/opengovsg/FormSG/compare/v6.63.0...v6.64.0)

Expand Down Expand Up @@ -352,7 +369,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- fix: only return previous payment id [`#6210`](https://github.com/opengovsg/FormSG/pull/6210)
- build: merge release v6.45.0 to develop [`#6205`](https://github.com/opengovsg/FormSG/pull/6205)
- build: release v6.45.0 [`#6200`](https://github.com/opengovsg/FormSG/pull/6200)
- chore: bump version to v6.46.0 [`767e7e5`](https://github.com/opengovsg/FormSG/commit/767e7e55c3e8f058963e890b1c249704d6db1459)
- chore: bump version to v6.46.0 [`87fda0e`](https://github.com/opengovsg/FormSG/commit/87fda0e0ec4c937350ebd013a4a9762f4acee802)

#### [v6.45.0](https://github.com/opengovsg/FormSG/compare/v6.44.1...v6.45.0)

Expand Down Expand Up @@ -515,7 +532,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- build: merge v6.37.0 into develop [`#5989`](https://github.com/opengovsg/FormSG/pull/5989)
- build: release v6.37.0 [`#5988`](https://github.com/opengovsg/FormSG/pull/5988)

#### [v6.37.0](https://github.com/opengovsg/FormSG/compare/v6.36.1...v6.37.0)
#### [v6.37.0](https://github.com/opengovsg/FormSG/compare/v6.36.0...v6.37.0)

> 24 March 2023

Expand Down Expand Up @@ -545,17 +562,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- chore(deps-dev): bump @typescript-eslint/parser from 5.54.1 to 5.55.0 in /shared [`#5922`](https://github.com/opengovsg/FormSG/pull/5922)
- test(e2e/email): add form auth tests [`#5876`](https://github.com/opengovsg/FormSG/pull/5876)
- build: merge v6.36.0 into develop [`#5914`](https://github.com/opengovsg/FormSG/pull/5914)
- build: release v6.36.0 [`#5913`](https://github.com/opengovsg/FormSG/pull/5913)
- chore: bump version to v6.37.0 [`b4d24eb`](https://github.com/opengovsg/FormSG/commit/b4d24eb14f8a80bff56d19e6fa23975d5661cce9)
- chore: bump version to 6.36.1 [`faf75b5`](https://github.com/opengovsg/FormSG/commit/faf75b5a7d0d12745e9a0104c541fb66cca17258)

#### [v6.36.1](https://github.com/opengovsg/FormSG/compare/v6.36.0...v6.36.1)

> 17 March 2023

- build: release v6.36.0 [`#5913`](https://github.com/opengovsg/FormSG/pull/5913)
- chore: bump version to 6.36.1 [`7bc8b06`](https://github.com/opengovsg/FormSG/commit/7bc8b0669b29565be1d7a8b4cb8b76801a9a44ba)
- fix: trim dropdown options for logic check [`25e197a`](https://github.com/opengovsg/FormSG/commit/25e197a22eecec527b2b284aee0b95ccb1cd3797)

#### [v6.36.0](https://github.com/opengovsg/FormSG/compare/v6.35.0...v6.36.0)

> 9 March 2023
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form-frontend",
"version": "6.65.0",
"version": "6.66.0",
"homepage": ".",
"private": true,
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,27 @@ export const VariablePaymentAmountField = ({
minPaymentAmountCents = Number.MIN_SAFE_INTEGER,
} = {},
} = useEnv()

const minAmountInDollars = `S${formatCurrency(
Number(centsToDollars(minPaymentAmountCents)),
)}`
const maxAmountInDollars = `S${formatCurrency(
Number(centsToDollars(maxPaymentAmountCents)),
)}`

const minAmountValidation: RegisterOptions<
FormPaymentsInput,
typeof MIN_FIELD_KEY
> = usePaymentFieldValidation<FormPaymentsInput, typeof MIN_FIELD_KEY>({
lesserThanCents: dollarsToCents(input[MAX_FIELD_KEY] || ''),
msgWhenEmpty: `The minimum amount is S${formatCurrency(
Number(centsToDollars(minPaymentAmountCents)),
)}`,
msgWhenEmpty: `The minimum amount is ${minAmountInDollars}`,
})
const maxAmountValidation: RegisterOptions<
FormPaymentsInput,
typeof MAX_FIELD_KEY
> = usePaymentFieldValidation<FormPaymentsInput, typeof MAX_FIELD_KEY>({
greaterThanCents: dollarsToCents(input[MIN_FIELD_KEY] || ''),
msgWhenEmpty: `The maximum amount is S${formatCurrency(
Number(centsToDollars(maxPaymentAmountCents)),
)}`,
msgWhenEmpty: `The maximum amount is ${maxAmountInDollars}`,
})
return (
<FormControl
Expand Down Expand Up @@ -77,7 +81,7 @@ export const VariablePaymentAmountField = ({
flex={1}
step={0}
inputMode="decimal"
placeholder="S$0.50"
placeholder={minAmountInDollars}
{...field}
/>
)}
Expand All @@ -97,7 +101,7 @@ export const VariablePaymentAmountField = ({
flex={1}
step={0}
inputMode="decimal"
placeholder="S$1,000,000"
placeholder={maxAmountInDollars}
{...field}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ export const updateBusinessInfo: UpdateStorageFormFn<'business'> = async (
return updateFormSettings(formId, { business: newBusinessField })
}

export const updateGstEnabledFlag = async (
formId: string,
gstEnabledFlag: StorageFormSettings['payments_field']['gst_enabled'],
) => {
return updateFormSettings(formId, {
payments_field: { gst_enabled: gstEnabledFlag },
})
}

/**
* Internal function that calls the PATCH API.
* @param formId the id of the form to update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,18 @@ const BusinessInfoBlock = ({
}
return (
<>
{settings.payments_field.gst_enabled ? (
<FormControl mb="2.5rem" isReadOnly={mutateFormBusiness.isLoading}>
<FormLabel isRequired>GST Registration Number</FormLabel>
<BusinessFieldInput
placeholder={agencyDefaults?.gstRegNo || ''}
initialValue={settings.business?.gstRegNo || ''}
handleMutation={handleGstRegNoMutation}
/>
</FormControl>
) : null}
<FormControl mb="2.5rem" isReadOnly={mutateFormBusiness.isLoading}>
<FormLabel
description="Leave blank to use your agency's GST Registration Number"
isRequired
>
GST Registration Number
</FormLabel>
<BusinessFieldInput
placeholder={agencyDefaults?.gstRegNo || ''}
initialValue={settings.business?.gstRegNo || ''}
handleMutation={handleGstRegNoMutation}
/>
</FormControl>
<FormControl mb="2.5rem" isReadOnly={mutateFormBusiness.isLoading}>
<FormLabel
description="Leave blank to use your agency's business address"
isRequired
>
Business Address
</FormLabel>
<FormLabel isRequired>Business Address</FormLabel>
<BusinessFieldInput
placeholder={agencyDefaults?.address || ''}
initialValue={settings.business?.address || ''}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { useCallback, useMemo } from 'react'
import { Skeleton } from '@chakra-ui/react'

import { FormResponseMode } from '~shared/types'

import Toggle from '~components/Toggle'

import { useMutateFormSettings } from '../../mutations'
import { useAdminFormSettings } from '../../queries'

export const GstToggleSection = (): JSX.Element => {
const { data: settings, isLoading: isLoadingSettings } =
useAdminFormSettings()

const hasGST = useMemo(
() =>
settings &&
settings.responseMode === FormResponseMode.Encrypt &&
settings?.payments_field.gst_enabled,
[settings],
)

const { mutateGST } = useMutateFormSettings()

const handleToggleGST = useCallback(() => {
if (
!settings ||
isLoadingSettings ||
mutateGST.isLoading ||
settings.responseMode !== FormResponseMode.Encrypt
) {
return
}
const nextHasGst = !settings.payments_field.gst_enabled
return mutateGST.mutate(nextHasGst)
}, [isLoadingSettings, mutateGST, settings])

return (
<Skeleton isLoaded={!isLoadingSettings && !!settings}>
<Toggle
mb="2.5rem"
isLoading={mutateGST.isLoading}
isChecked={hasGST}
label="GST applicable"
description="GST will be mentioned in proof of payment"
onChange={() => handleToggleGST()}
/>
</Skeleton>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useEnv } from '~features/env/queries'
import { useAdminFormPayments, useAdminFormSettings } from '../../queries'

import { BusinessInfoSection } from './BusinessInfoSection'
import { GstToggleSection } from './GstToggleSection'
import { usePaymentGuideLink } from './queries'
import {
StripeConnectButton,
Expand Down Expand Up @@ -231,6 +232,7 @@ export const PaymentSettingsSection = (): JSX.Element => {
{hasPaymentCapabilities && (
<>
<Divider my="2.5rem" />
<GstToggleSection />
<BusinessInfoSection />
</>
)}
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/features/admin-form/settings/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
updateFormTitle,
updateFormWebhookRetries,
updateFormWebhookUrl,
updateGstEnabledFlag,
updateTwilioCredentials,
} from './SettingsService'

Expand Down Expand Up @@ -303,6 +304,20 @@ export const useMutateFormSettings = () => {
},
)

const mutateGST = useMutation(
(gstEnabledFlag: StorageFormSettings['payments_field']['gst_enabled']) =>
updateGstEnabledFlag(formId, gstEnabledFlag),
{
onSuccess: (newData) => {
handleSuccess({
newData,
toastDescription: `GST setting has been updated.`,
})
},
onError: handleError,
},
)

return {
mutateWebhookRetries,
mutateFormWebhookUrl,
Expand All @@ -315,6 +330,7 @@ export const useMutateFormSettings = () => {
mutateFormAuthType,
mutateFormEsrvcId,
mutateFormBusiness,
mutateGST,
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BiMessage } from 'react-icons/bi'
import { BiQuestionMark } from 'react-icons/bi'
import { Flex, useDisclosure } from '@chakra-ui/react'

import { noPrintCss } from '~utils/noPrintCss'
Expand Down Expand Up @@ -26,7 +26,7 @@ export const FormIssueFeedbackButton = (): JSX.Element | null => {
variant="outline"
cursor="pointer"
aria-label="issue feedback"
icon={<BiMessage color="primary.500" />}
icon={<BiQuestionMark color="primary.500" />}
onClick={onOpen}
/>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,23 @@ export const FormIssueFeedbackModal = ({
pr="4rem"
>
<Text textStyle={{ base: '1.25rem', md: '1.5rem' }}>
Have trouble filling out this form?
Report an issue
</Text>
</ModalHeader>
<ModalBody>
<Text pb="1.5rem" textStyle="body-2" mt="0">
Fill this in only{' '}
<span style={{ fontWeight: 'bold' }}>
if you are experiencing issues and are unable to submit this
form
</span>
. If you would like to provide feedback, you can do so after
submitting the form.
</Text>
<Stack>
<FormControl isInvalid={!!errors.issue}>
<FormLabel
isRequired={true}
description={'This will be sent to the form creator.'}
>
Please describe the issue you encountered.
<FormLabel isRequired={true}>
Please describe the issue you encountered
</FormLabel>
<Textarea
{...register('issue', {
Expand All @@ -121,12 +127,7 @@ export const FormIssueFeedbackModal = ({
</FormControl>

<FormControl isInvalid={!!errors.email}>
<FormLabel
pt="1rem"
description="Leave your email so the form creator can reach out to you if needed."
>
Contact
</FormLabel>
<FormLabel pt="1rem">Contact</FormLabel>
<Input
type={BasicField.Email}
placeholder="me@example.com"
Expand Down
Loading