Skip to content

Commit

Permalink
fix: adjust Quantity on Shopping List Button Does not function, and e…
Browse files Browse the repository at this point in the history
…rror messaging is not accurate
  • Loading branch information
kris-liu-smile authored and BrianJiang2021 committed Feb 22, 2023
1 parent affad64 commit 9b7b777
Show file tree
Hide file tree
Showing 19 changed files with 139 additions and 105 deletions.
2 changes: 2 additions & 0 deletions apps/storefront/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ export default function App() {
// background login enter judgment
if (!href.includes('checkout')) {
setOpenApp(!(customerId && !window.location.hash))
} else {
showPageMask(false)
}
}

Expand Down
6 changes: 3 additions & 3 deletions apps/storefront/src/components/B3Tip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@/shared/global/context/config'

interface B3TipProps extends TipMessagesProps {
handleItemClose?: (id: number | string) => void,
handleItemClose: (id: number | string) => void,
handleAllClose: () => void,
}

Expand Down Expand Up @@ -41,13 +41,13 @@ export const B3Tip = ({
width: '100%',
alignItems: 'center',
'& button[title="Close"]': {
display: `${handleItemClose ? 'block' : 'none'}`,
display: `${msg.isClose ? 'block' : 'none'}`,
},
}}
variant="filled"
key={msg.id}
severity={msg.type}
onClose={() => handleItemClose && handleItemClose(msg.id)}
onClose={() => msg.isClose && handleItemClose(msg.id)}
>
{msg?.title && <AlertTitle>{msg.title}</AlertTitle>}
{
Expand Down
8 changes: 6 additions & 2 deletions apps/storefront/src/components/layout/B3LayoutTip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const B3LayoutTip = () => {
window.tipDispatch = dispatch
}, [])

// useEffect(() => {
// window.b3Tipmessage = tipMessage?.msgs || []
// }, [tipMessage])

const setMsgs = (msgs: [] | Array<MsgsProps> = []) => {
dispatch({
type: 'common',
Expand All @@ -56,7 +60,6 @@ const B3LayoutTip = () => {
autoHideDuration = 3000,
vertical = `${isMobile ? 'top' : 'top'}`,
horizontal = 'right',
isClose = false,
} = tipMessage

return (
Expand All @@ -65,7 +68,8 @@ const B3LayoutTip = () => {
msgs={msgs}
handleAllClose={setMsgs}
autoHideDuration={autoHideDuration}
handleItemClose={isClose ? handleClose : undefined}
handleItemClose={handleClose}
// handleItemClose={isClose ? handleClose : undefined}
vertical={vertical}
horizontal={horizontal}
/>
Expand Down
3 changes: 1 addition & 2 deletions apps/storefront/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ declare interface CustomFieldStringItems {

declare interface Window {
tipDispatch: DispatchProps
b3Tipmessage: any
}

// declare module '@mui-treasury/components/chatMsg/ChatMsg'
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import {
ThemeFrameContext,
} from '@/components/ThemeFrame'

import {
GlobaledContext,
} from '@/shared/global'

import {
createB2BShoppingList,
} from '@/shared/service/b2b'
Expand Down Expand Up @@ -80,6 +84,12 @@ const CreateShoppingList = ({

const [loading, setLoading] = useState<boolean>(false)

const {
state: {
role,
},
} = useContext(GlobaledContext)

const {
control,
handleSubmit,
Expand Down Expand Up @@ -107,7 +117,7 @@ const CreateShoppingList = ({
}
const createShoppingData = {
...data,
status: 0,
status: +role === 2 ? 30 : 0,
}
await createB2BShoppingList(createShoppingData)
setLoading(false)
Expand Down
7 changes: 7 additions & 0 deletions apps/storefront/src/pages/quickorder/Quickorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const Quickorder = () => {
<Grid
item
xs={isMobile ? 12 : 8}
sx={{
backgroundColor: '#ffffff',
}}
>
<QuickorderTable
setCheckedArr={setCheckedArr}
Expand All @@ -68,6 +71,10 @@ const Quickorder = () => {
<Grid
item
xs={isMobile ? 12 : 4}
sx={{
pt: !isMobile ? '0px !important' : '16px',
pl: isMobile ? '0px !important' : '16px',
}}
>
<QuickOrderPad />
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const QuickorderTable = ({

const handleSearchProduct = async (q: string) => {
setSearch({
...search,
q,
})
}
Expand Down Expand Up @@ -456,7 +457,7 @@ const QuickorderTable = ({
<B3PaginationTable
ref={paginationTableRef}
columnItems={columnItems}
rowsPerPageOptions={[10, 20, 50]}
rowsPerPageOptions={[12, 24, 36]}
getRequestList={getList}
searchParams={search}
isCustomRender={false}
Expand Down
13 changes: 7 additions & 6 deletions apps/storefront/src/pages/quote/QuoteDraft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ import {
import {
QuoteSummary,
} from './components/QuoteSummary'
// import {
// QuoteNote,
// } from './components/QuoteNote'
import {
QuoteNote,
} from './components/QuoteNote'
import {
QuoteAttachment,
} from './components/QuoteAttachment'
Expand Down Expand Up @@ -383,7 +383,7 @@ const QuoteDraft = ({
fileUrl: file.fileUrl,
fileName: file.fileName,
fileType: file.fileType,
fileSize: `${file.fileSize}`,
fileSize: file.fileSize,
}))
}

Expand Down Expand Up @@ -483,7 +483,8 @@ const QuoteDraft = ({
const fileList = getFileList(info.fileInfo || [])

const data = {
notes: note,
// notes: note,
message: note,
legalTerms: '',
totalAmount: allPrice.toFixed(2),
grandTotal: allPrice.toFixed(2),
Expand Down Expand Up @@ -759,7 +760,7 @@ const QuoteDraft = ({
addToQuote={addToQuote}
/>

{/* <QuoteNote /> */}
<QuoteNote />

{
role !== 100 && <QuoteAttachment status={0} />
Expand Down
8 changes: 7 additions & 1 deletion apps/storefront/src/pages/quote/components/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ interface FileUploadProps {
fileList: FileObjects[],
allowUpload?: boolean,
onDelete?: (id: string) => void,
limitUploadFn?: () => boolean,
isEndLoadding?: boolean,
}

Expand All @@ -133,6 +134,7 @@ const FileUpload = (props: FileUploadProps, ref: Ref<unknown>) => {
tips = 'You can add up to 3 files,not bigger that 2MB each.',
maxFileSize = 2097152, // 2MB
fileNumber = 3,
limitUploadFn,
acceptedFiles = FILE_UPLOAD_ACCEPT_TYPE,
onchange = noop,
fileList = [],
Expand Down Expand Up @@ -196,7 +198,11 @@ const FileUpload = (props: FileUploadProps, ref: Ref<unknown>) => {
const handleChange = async (files: File[]) => {
const file = files.length > 0 ? files[0] : null

if (file && fileList.length >= fileNumber) {
if (file && limitUploadFn && limitUploadFn()) {
return
}

if (!limitUploadFn && file && fileList.length >= fileNumber) {
snackbar.error(`You can add up to ${fileNumber} files`)
return
}
Expand Down
106 changes: 39 additions & 67 deletions apps/storefront/src/pages/quote/components/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {

import {
format,
formatDistanceStrict,
} from 'date-fns'

import {
updateB2BQuote,
updateBCQuote,
Expand Down Expand Up @@ -54,17 +56,21 @@ interface MsgsProps {
}

interface CustomerMessageProps {
msg: MessageProps
msg: MessageProps,
isEndMessage?: boolean,
isCustomer?: boolean,
}

const CustomerMessage = ({
const ChatMessage = ({
msg,
isEndMessage,
isCustomer,
}: CustomerMessageProps) => (
<Box
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-end',
alignItems: `${isCustomer ? 'flex-end' : 'flex-start'}`,
}}
>
{
Expand Down Expand Up @@ -92,7 +98,7 @@ const CustomerMessage = ({
height: '34px',
lineHeight: '34px',
padding: '0 10px',
background: 'rgba(25, 118, 210, 0.3)',
background: `${isCustomer ? 'rgba(25, 118, 210, 0.3)' : 'rgba(0, 0, 0, 0.12)'}`,
borderRadius: '18px',
m: '1px',
}}
Expand All @@ -106,72 +112,39 @@ const CustomerMessage = ({
{msg.message}
</Box>
</Tooltip>
{
isEndMessage && (
<Box
sx={{
height: '14px',
fontWeight: 400,
lineHeight: '14px',
fontSize: '10px',
letterSpacing: '0.17px',
color: 'rgba(0, 0, 0, 0.38)',
}}
>
{`Sent ${formatDistanceStrict(new Date((msg.sendTime || 0) * 1000), new Date(), {
addSuffix: true,
})}`}

</Box>
)
}
</Box>
)
}

</Box>
)

const SalesRepMessage = ({
msg,
}: CustomerMessageProps) => (
<Box
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-start',
}}
>
{
msg?.role && (
<Box
sx={{
height: '14px',
fontWeight: 400,
lineHeight: '14px',
fontSize: '10px',
letterSpacing: '0.17px',
color: 'rgba(0, 0, 0, 0.38)',
}}
>
{msg.role}
</Box>
)
}

{
msg?.message && (
<Box
sx={{
display: 'inline-block',
height: '34px',
lineHeight: '34px',
padding: '0 10px',
background: 'rgba(0, 0, 0, 0.12)',
borderRadius: '18px',
m: '1px',
}}
>
<Tooltip
title={format((msg.sendTime || 0) * 1000, 'K:m aa')}
placement="top"
arrow
>
<Box>
{msg.message}
</Box>
</Tooltip>
</Box>
)
}

</Box>
)
interface DateMessageProps {
msg: MessageProps,
}

const DateMessage = ({
msg,
}: CustomerMessageProps) => (
}: DateMessageProps) => (
<Box
sx={{
color: 'rgba(0, 0, 0, 0.6)',
Expand Down Expand Up @@ -398,14 +371,13 @@ const Message = ({
}}
>
{
messages.map((item: MessageProps) => (
messages.map((item: MessageProps, index: number) => (
<Box key={item.key}>
{
item.isCustomer && <CustomerMessage msg={item} />
}
{
!item.isCustomer && <SalesRepMessage msg={item} />
}
<ChatMessage
msg={item}
isEndMessage={index === messages.length - 1}
isCustomer={!!item.isCustomer}
/>
{
item.date && <DateMessage msg={item} />
}
Expand Down
Loading

0 comments on commit 9b7b777

Please sign in to comment.