Skip to content

Commit

Permalink
fix: fix QO page and SL page bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 committed Feb 22, 2023
1 parent 9799af6 commit 0e5a76a
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 3 deletions.
9 changes: 9 additions & 0 deletions apps/storefront/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,15 @@ <h1>Ugly Cornerstone Store Theme with Weird CSS</h1>
<div class="cart-actions cart-content-padding-right">
<a class="button button--primary" href="/checkout" title="Click here to proceed to checkout">Check out</a>
</div>

<li class="navUser-item navUser-item--cart">
<a class="navUser-action navUser-item--cart__hidden-s" data-cart-preview="" data-dropdown="cart-preview-dropdown" data-options="align:right" href="/cart.php" aria-label="Cart with 0 items">
<span class="navUser-item-cartLabel">Cart</span>
<span class="countPill cart-quantity">0</span>
</a>

<div class="dropdown-menu" id="cart-preview-dropdown" data-dropdown-content="" aria-hidden="true"></div>
</li>
</div>
<style>
body {
Expand Down
6 changes: 6 additions & 0 deletions apps/storefront/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import {
showPageMask,
} from '@/utils'

import {
removeCartPermissions,
} from '@/utils/b3RolePermissions'

import {
GlobaledContext,
} from '@/shared/global'
Expand Down Expand Up @@ -212,6 +216,8 @@ export default function App() {
},
})
}

removeCartPermissions(role)
}, [isB2BUser, isAgenting, role, quoteConfig, storefrontConfig])

useRegisteredbctob2b(setOpenPage, isB2BUser, customerId)
Expand Down
7 changes: 5 additions & 2 deletions apps/storefront/src/components/filter/B3FilterSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ const B3FilterSearch = ({
}

const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
setIsInitLoading(false)
setIsInitLoading(true)
setSearch(e.target.value)
}

// 防抖
useEffect(() => {
if (isInitLoading) return
handleChange(search)
}, [debouncedValue])
}, [debouncedValue, isInitLoading])

return (
<Paper
Expand Down Expand Up @@ -91,6 +91,9 @@ const B3FilterSearch = ({
value={search}
placeholder={placeholder}
onChange={handleOnChange}
onBlur={() => {
setIsInitLoading(false)
}}
/>
</Paper>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const DeleteAddressDialog = (props: DeleteAddressDialogProps) => {
rightStyleBtn={{
color: '#D32F2F',
}}
isShowBordered={false}
>
<Box
sx={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ const QuickorderTable = ({
}

const handleUpdateProductQty = (id: number | string, value: number | string) => {
if (value !== '' && value <= 0) return
const listItems = paginationTableRef.current?.getList() || []
const newListItems = listItems?.map((item: ListItemProps) => {
const {
Expand Down Expand Up @@ -351,7 +352,7 @@ const QuickorderTable = ({
padding: '12px 0',
}}
>
{format(+row.lastOrderedAt * 1000, 'dd MMM yy')}
{format(+row.lastOrderedAt * 1000, 'dd MMM yyyy')}
</Typography>
</Box>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const ShoppingDetailTable = (props: ShoppingDetailTableProps, ref: Ref<unknown>)
const [originProducts, setOriginProducts] = useState<ListItemProps[]>([])

const handleUpdateProductQty = (id: number | string, value: number | string) => {
if (value !== '' && value <= 0) return
const currentItem = originProducts.find((item: ListItemProps) => {
const {
node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ const Usermanagement = () => {
rightStyleBtn={{
color: '#D32F2F',
}}
isShowBordered={false}
>
<Box
sx={{
Expand Down
7 changes: 7 additions & 0 deletions apps/storefront/src/utils/b3RolePermissions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {
removeCartPermissions,
} from './juniorRolePermissions'

export {
removeCartPermissions,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const removeCartPermissions = (role: number | string) => {
if (+role !== 2) return
const carts = document.querySelectorAll('[href="/cart.php"]')
const cartBtn = document.querySelectorAll('#form-action-addToCart')
const quickViewCartBtn = document.querySelectorAll('[data-button-type="add-cart"]')
console.log(cartBtn, quickViewCartBtn)

// remove cart Entrance
if (carts.length > 0) {
carts.forEach((cart: any) => {
cart.style.display = 'none'
})
}

// remove add to cart button
if (cartBtn.length > 0) {
cartBtn.forEach((cart: any) => {
cart.style.display = 'none'
})
}

// remove quick view page add to cart button
if (quickViewCartBtn.length > 0) {
quickViewCartBtn.forEach((cart: any) => {
cart.style.display = 'none'
})
}
}

0 comments on commit 0e5a76a

Please sign in to comment.