Skip to content

Commit

Permalink
Merge pull request #6736 from opengovsg/release_v6.78.0
Browse files Browse the repository at this point in the history
build: release v6.78.0
  • Loading branch information
LinHuiqing authored Sep 20, 2023
2 parents 5d7f95b + 9862b60 commit 114aeeb
Show file tree
Hide file tree
Showing 65 changed files with 2,568 additions and 360 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/deploy-virus-scanner-production.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
name: Deploy to production

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

permissions:
id-token: write
contents: read

on:
push:
branches:
- production
- release-al2
# schedule builds for 12:00AM GMT+8 everyday to get latest virus definitions
schedule:
- cron: '0 16 * * *'
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/deploy-virus-scanner-uat.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Deploy to uat

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

permissions:
id-token: write
contents: read
Expand Down
122 changes: 80 additions & 42 deletions CHANGELOG.md

Large diffs are not rendered by default.

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.77.0",
"version": "6.78.0",
"homepage": ".",
"private": true,
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
import { useMemo } from 'react'
import { BiDotsHorizontalRounded, BiEditAlt, BiTrash } from 'react-icons/bi'
import {
Box,
ButtonGroup,
Divider,
Drawer,
DrawerBody,
DrawerContent,
DrawerOverlay,
Flex,
Table,
TableContainer,
Tbody,
Td,
Text,
Tr,
useDisclosure,
} from '@chakra-ui/react'

import { Product } from '~shared/types'
import { centsToDollars } from '~shared/utils/payments'

import { useIsMobile } from '~hooks/useIsMobile'
import Button, { ButtonProps } from '~components/Button'
import IconButton from '~components/IconButton'

export const ProductItem = ({
product,
onEditClick,
onDeleteClick,
isDisabled,
}: {
product: Product
onEditClick: () => void
onDeleteClick: () => void
isDisabled: boolean
}) => {
const isMobile = useIsMobile()
return (
<>
<Box px="1rem" py="1rem" backgroundColor={'#F8F9FD'}>
<Flex justifyContent="center" alignItems="center">
<Box flexGrow={1}>
<Flex justifyContent="space-between">
<Text textStyle="subhead-1" pb="0.25rem" color="secondary.500">
{product.name}
</Text>
{isMobile && (
<MobileProductItemMenu
isDisabled={isDisabled}
onDeleteClick={onDeleteClick}
onEditClick={onEditClick}
/>
)}
</Flex>
<TableContainer>
<Table
style={{
borderCollapse: 'separate',
borderSpacing: '0 0',
}}
>
<Tbody>
<ProductItemTableContent
label="Amount"
value={`S$${centsToDollars(product.amount_cents)}`}
/>
{product.multi_qty && (
<ProductItemTableContent
label="Quantity limit"
value={`between ${product.min_qty} to ${product.max_qty}`}
/>
)}
</Tbody>
</Table>
</TableContainer>
</Box>

{!isMobile && (
<DesktopProductItemButtonGroup
isDisabled={isDisabled}
onDeleteClick={onDeleteClick}
onEditClick={onEditClick}
/>
)}
</Flex>
</Box>
</>
)
}

const DesktopProductItemButtonGroup = ({
isDisabled,
onEditClick,
onDeleteClick,
}: {
isDisabled: boolean
onEditClick: () => void
onDeleteClick: () => void
}) => {
return (
<ButtonGroup variant="clear" colorScheme="secondary" spacing={0}>
<IconButton
isDisabled={isDisabled}
icon={<BiEditAlt type="solid" />}
color="primary.500"
aria-label={'Edit'}
onClick={onEditClick}
/>
<IconButton
isDisabled={isDisabled}
icon={<BiTrash />}
color="danger.500"
aria-label={'Delete'}
onClick={onDeleteClick}
/>
</ButtonGroup>
)
}

const MobileProductItemMenu = ({
isDisabled,
onEditClick,
onDeleteClick,
}: {
isDisabled: boolean
onEditClick: () => void
onDeleteClick: () => void
}) => {
const { isOpen, onOpen, onClose } = useDisclosure()

const buttonProps: Partial<ButtonProps> = useMemo(
() => ({
isFullWidth: true,
iconSpacing: '1rem',
justifyContent: 'flex-start',
textStyle: 'body-1',
}),
[],
)

return (
<Box display={{ md: 'none' }}>
<IconButton
variant="clear"
aria-label="More options"
icon={<BiDotsHorizontalRounded fontSize="1.25rem" />}
onClick={onOpen}
size="xs"
isDisabled={isDisabled}
/>
<Drawer placement="bottom" onClose={onClose} isOpen={isOpen}>
<DrawerOverlay />
<DrawerContent borderTopRadius="0.25rem">
<DrawerBody px={0} py="0.5rem">
<ButtonGroup
flexDir="column"
spacing={0}
w="100%"
variant="clear"
colorScheme="secondary"
>
<Button
onClick={onEditClick}
leftIcon={<BiEditAlt fontSize="1.25rem" />}
{...buttonProps}
>
Edit
</Button>
<Divider />
<Button
onClick={onDeleteClick}
color="danger.500"
leftIcon={<BiTrash fontSize="1.25rem" />}
{...buttonProps}
>
Delete
</Button>
</ButtonGroup>
</DrawerBody>
</DrawerContent>
</Drawer>
</Box>
)
}

const ProductItemTableContent = ({
label,
value,
}: {
label: string
value: string
}) => {
return (
<Tr>
<Td
py="0"
pl="0"
pr="1rem"
borderBottom="0"
textStyle={{ base: 'caption-1', md: 'body-2' }}
color="secondary.400"
w="1%"
>
{label}
</Td>
<Td
p="0"
borderBottom="0"
textStyle={{ base: 'caption-1', md: 'body-2' }}
color="secondary.500"
>
{value}
</Td>
</Tr>
)
}
Loading

0 comments on commit 114aeeb

Please sign in to comment.