Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
clothe09986 committed Oct 30, 2023
2 parents 7a7dcf4 + 297ab39 commit 293cd38
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 40 deletions.
3 changes: 3 additions & 0 deletions src/components/activity/ActivityTicketPaymentButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ type ActivityTicketPaymentButtonProps = {
ticketId: string
ticketPrice: number
ticketCurrencyId: string
isPublished: boolean
}
const ActivityTicketPaymentButton: React.VFC<ActivityTicketPaymentButtonProps> = ({
ticketId,
ticketPrice,
ticketCurrencyId,
isPublished,
}) => {
const { formatMessage } = useIntl()
const { settings, id: appId } = useApp()
Expand Down Expand Up @@ -87,6 +89,7 @@ const ActivityTicketPaymentButton: React.VFC<ActivityTicketPaymentButtonProps> =
<Button
colorScheme="primary"
isFullWidth
disabled={!isPublished}
onClick={() => {
const resource = resourceCollection.find(notEmpty)
resource && tracking.addToCart(resource, { direct: true })
Expand Down
4 changes: 3 additions & 1 deletion src/components/common/PaymentButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const PaymentButton: React.VFC<{
currencyId?: string
isSubscription?: boolean
quantity?: number
}> = ({ type, target, price, isSubscription, currencyId, quantity }) => {
isPublished?: boolean
}> = ({ type, target, price, isSubscription, currencyId, quantity, isPublished }) => {
const tracking = useTracking()
const { isAuthenticated } = useAuth()
const { formatMessage } = useIntl()
Expand Down Expand Up @@ -110,6 +111,7 @@ const PaymentButton: React.VFC<{
<Button
colorScheme="primary"
isFullWidth
disabled={!isPublished}
onClick={() => {
const resource = resourceCollection.find(notEmpty)
resource && tracking.addToCart(resource, { direct: true })
Expand Down
4 changes: 3 additions & 1 deletion src/components/merchandise/MerchandiseBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ const MerchandiseBlock: React.VFC<{
) : (
<StyledButtonBlock>
<Link to={`/merchandises/${merchandise.id}`}>
<StyledButton colorScheme="primary">{formatMessage(commonMessages.ui.purchase)}</StyledButton>
<Button colorScheme="primary" color="var(--gray-darker)" disabled={!merchandise.publishedAt}>
{formatMessage(commonMessages.ui.purchase)}
</Button>
</Link>
</StyledButtonBlock>
)}
Expand Down
6 changes: 4 additions & 2 deletions src/components/merchandise/MerchandiseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { Link, useHistory } from 'react-router-dom'
import styled from 'styled-components'
import EmptyCover from '../../images/empty-cover.png'
import { MerchandiseBriefProps } from '../../types/merchandise'
import { MerchandiseBasicProps, MerchandiseBriefProps, MerchandiseSpecBasicProps } from '../../types/merchandise'
import { CustomRatioImage } from '../common/Image'

const StyledTitle = styled.h3`
Expand All @@ -15,8 +15,10 @@ const StyledTitle = styled.h3`
`

const MerchandiseCard: React.VFC<
Omit<MerchandiseBriefProps, 'tags' | 'categories' | 'isPhysical'> & {
Omit<MerchandiseBasicProps, 'tags' | 'categories' | 'isPhysical'> & {
specs: MerchandiseSpecBasicProps[]
onClick?: () => void
publishedAt?: Date | null
}
> = ({ id, title, minPrice, maxPrice, images, currencyId, specs, soldAt, onClick }) => {
const isOnSale = (soldAt?.getTime() || 0) > Date.now()
Expand Down
1 change: 1 addition & 0 deletions src/components/merchandise/MerchandiseCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const MerchandiseCollection: React.FC<{ merchandises: MerchandiseBriefProps[] }>
currencyId={merchandise.currencyId}
specs={merchandise.specs}
images={merchandise.images}
publishedAt={merchandise.publishedAt}
onClick={() => {
const resource = resourceCollection[idx]
resource && tracking.click(resource, { position: idx + 1 })
Expand Down
10 changes: 7 additions & 3 deletions src/components/merchandise/MerchandisePaymentButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ const GeneralMerchandisePaymentBlock: React.VFC<{
<Button
className="d-flex align-items-center mr-2"
variant="outline"
isDisabled={merchandise.isLimited && (quantity === 0 || quantity > remainQuantity)}
isDisabled={
!merchandise.publishedAt || (merchandise.isLimited && (quantity === 0 || quantity > remainQuantity))
}
onClick={() => {
const resource = resourceCollection.find(notEmpty)
if (quantity) {
Expand All @@ -132,7 +134,9 @@ const GeneralMerchandisePaymentBlock: React.VFC<{
<Button
colorScheme="primary"
isFullWidth
isDisabled={merchandise.isLimited && (quantity === 0 || quantity > remainQuantity)}
isDisabled={
!merchandise.publishedAt || (merchandise.isLimited && (quantity === 0 || quantity > remainQuantity))
}
onClick={() => {
const resource = resourceCollection.find(notEmpty)
if (quantity) {
Expand Down Expand Up @@ -180,7 +184,7 @@ const CustomizedMerchandisePaymentBlock: React.VFC<{
<Button
colorScheme="primary"
isFullWidth
isDisabled={(isAuthenticated && isLoading) || quantity <= 0}
isDisabled={!merchandise.publishedAt || (isAuthenticated && isLoading) || quantity <= 0}
onClick={() => {
if (isModalDisable) {
toast({
Expand Down
46 changes: 23 additions & 23 deletions src/hasura.d.ts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/hooks/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export const usePost = (search: string) => {
is_customized
is_countdown_timer_visible
currency_id
published_at
merchandise_tags(order_by: { position: asc }) {
tag_name
}
Expand Down Expand Up @@ -416,6 +417,7 @@ export const usePost = (search: string) => {
),
),
currencyId: v.merchandise.currency_id,
publishedAt: v.merchandise.published_at ? new Date(v.merchandise.published_at) : null,
abstract: v.merchandise.abstract || '',
description: v.merchandise.description || '',
startedAt: v.merchandise.started_at ? new Date(v.merchandise.started_at) : null,
Expand Down
5 changes: 4 additions & 1 deletion src/hooks/merchandise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const useMerchandiseCollection = (options?: {
sold_at
is_physical
currency_id
published_at
merchandise_tags(order_by: { position: asc }) {
tag_name
}
Expand Down Expand Up @@ -96,6 +97,7 @@ export const useMerchandiseCollection = (options?: {
),
),
currencyId: merchandise.currency_id,
publishedAt: merchandise.published_at ? new Date(merchandise.published_at) : null,
tags: merchandise.merchandise_tags.map(v => v.tag_name),
categories: merchandise.merchandise_categories.map(v => ({
id: v.category.id,
Expand Down Expand Up @@ -184,6 +186,7 @@ export const useMerchandise = (merchandiseId: string) => {
is_customized
is_countdown_timer_visible
currency_id
published_at
merchandise_tags(order_by: { position: asc }) {
tag_name
}
Expand Down Expand Up @@ -251,7 +254,7 @@ export const useMerchandise = (merchandiseId: string) => {
isPhysical: data.merchandise_by_pk.is_physical,
isCustomized: data.merchandise_by_pk.is_customized,
isCountdownTimerVisible: data.merchandise_by_pk.is_countdown_timer_visible,

publishedAt: data.merchandise_by_pk.published_at ? new Date(data.merchandise_by_pk.published_at) : null,
images: data.merchandise_by_pk.merchandise_imgs.map(image => ({
id: image.id,
url: image.url,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export const useProgram = (programId: string) => {
coverThumbnailUrl: data?.program_by_pk?.cover_thumbnail_url || null,
title: data?.program_by_pk?.title || '',
abstract: data?.program_by_pk?.abstract || '',
publishedAt: new Date(data?.program_by_pk?.published_at),
publishedAt: data?.program_by_pk?.published_at ? new Date(data?.program_by_pk?.published_at) : null,
isSoldOut: data?.program_by_pk?.is_sold_out || false,
description: data?.program_by_pk?.description || '',
coverVideoUrl: data?.program_by_pk?.cover_video_url || null,
Expand Down
1 change: 1 addition & 0 deletions src/pages/ActivityPage/ActivityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const ActivityPage: React.VFC = () => {
ticketId={ticket.id}
ticketPrice={ticket.price}
ticketCurrencyId={ticket.currencyId}
isPublished={Boolean(activity.publishedAt)}
/>
) : (
<Button
Expand Down
1 change: 1 addition & 0 deletions src/pages/ActivityPage/ActivityPageHelmet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const ActivityPageHelmet: React.VFC<{ activity: ActivityPageHelmetProps }> = ({
title={activity.title}
description={getBraftContent(activity.description || app.settings['description'])}
keywords={activity.tags}
isNoIndex={!activity.publishedAt}
jsonLd={[
{
'@context': 'https://schema.org',
Expand Down
5 changes: 5 additions & 0 deletions src/pages/AppPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ const AppPage: React.VFC<{ renderFallback?: (path: string) => React.ReactElement

refreshTokenAsync()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location.pathname])

if (loadingAppPage) {
Expand All @@ -200,6 +201,7 @@ const AppPage: React.VFC<{ renderFallback?: (path: string) => React.ReactElement
title={appPage?.metaTag?.seo?.pageTitle || appPage?.title || ''}
description={appPage?.metaTag?.seo?.description || appPage.defaultSettings.description || ''}
keywords={appPage?.metaTag?.seo?.keywords?.split(',')}
isNoIndex={!appPage.publishedAt}
openGraph={[
{ property: 'fb:app_id', content: settings['auth.facebook_app_id'] },
{ property: 'og:site_name', content: settings['name'] },
Expand Down Expand Up @@ -287,6 +289,7 @@ export const usePage = (path: string) => {
options
craft_data
meta_tag
published_at
app_page_sections(order_by: { position: asc }) {
id
options
Expand Down Expand Up @@ -330,6 +333,7 @@ export const usePage = (path: string) => {
craftData: { [key: string]: any } | null
options: { [key: string]: string } | null
metaTag: MetaTag | null
publishedAt: Date | null
appPageSections: AppPageSectionProps[]
defaultSettings: { img: string; description: string }
} | null = data?.app_page[0]
Expand All @@ -340,6 +344,7 @@ export const usePage = (path: string) => {
craftData: data.app_page[0].craft_data,
options: data.app_page[0].options || null,
metaTag: data.app_page[0].meta_tag || null,
publishedAt: data.app_page[0].published_at || null,
appPageSections: data.app_page[0]
? data.app_page[0].app_page_sections.map(v => ({
id: v.id,
Expand Down
1 change: 1 addition & 0 deletions src/pages/BlogPostPage/BlogPostPageHelmet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const BlogPostPageHelmet: React.VFC<{ post: Post }> = ({ post }) => {
title={post.metaTag?.seo?.pageTitle || post.title}
description={post.metaTag?.seo?.description || post.description || post.abstract || ''}
keywords={post.metaTag?.seo?.keywords?.split(',') || post.tags}
isNoIndex={!post.publishedAt}
jsonLd={[
{
'@context': 'https://schema.org',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MerchandisePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const MerchandisePage: React.VFC = () => {
<DefaultLayout white>
{resourceCollection[0] && <Tracking.Detail resource={resourceCollection[0]} />}
{/* // TODO: need to extend page helmet */}
{!loadingApp && <PageHelmet title={merchandise?.title} />}
{!loadingApp && <PageHelmet title={merchandise?.title} isNoIndex={!merchandise?.publishedAt} />}
<StyledContainer className="container">
<div className="my-4">{merchandise && <MerchandiseBlock merchandise={merchandise} withPaymentButton />}</div>

Expand Down
1 change: 1 addition & 0 deletions src/pages/ProgramPage/ProgramPageHelmet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const ProgramPageHelmet: React.VFC<{ program: Program } & Pick<React.ComponentPr
description={program.metaTag?.seo?.description || program.description || ''}
keywords={program.metaTag?.seo?.keywords?.split(',') || program.tags}
onLoaded={onLoaded}
isNoIndex={program.isPrivate || !program.publishedAt}
jsonLd={[
{
'@context': 'https://schema.org',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const ProgramPlanPaymentButton: React.VFC<{
programPlan: ProgramPlan & {
isSubscription: boolean
groupBuyingPeople: number
}
}> = ({ programPlan }) => {
} & { isPublished?: boolean }
}> = ({ programPlan }, isPublished) => {
const tracking = useTracking()
const { formatMessage } = useIntl()
const { addCartProduct, isProductInCart } = useContext(CartContext)
Expand Down Expand Up @@ -91,6 +91,7 @@ const ProgramPlanPaymentButton: React.VFC<{
<Button
colorScheme="primary"
isFullWidth
disabled={!isPublished}
onClick={() => {
const resource = resourceCollection.find(notEmpty)
resource && tracking.addToCart(resource, { direct: true })
Expand Down
6 changes: 4 additions & 2 deletions src/pages/ProgramPage/ProgramPlanCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const ProgramPlanCard: React.VFC<{
}
enrollmentCount?: number
isProgramSoldOut?: boolean
}> = ({ programId, programPlan, enrollmentCount, isProgramSoldOut }) => {
isPublished?: boolean
}> = ({ programId, programPlan, enrollmentCount, isProgramSoldOut, isPublished }) => {
const { formatMessage } = useIntl()
const history = useHistory()
const { isAuthenticated } = useAuth()
Expand Down Expand Up @@ -201,7 +202,8 @@ const ProgramPlanCard: React.VFC<{
price={isOnSale && salePrice ? salePrice : listPrice}
currencyId={currency.id}
isSubscription={isSubscription}
></PaymentButton>
isPublished={isPublished}
/>
</>
)}
</StyledAdminCard>
Expand Down
1 change: 1 addition & 0 deletions src/pages/ProgramPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ const ProgramPageContent: React.VFC = () => {
programPlansEnrollmentsAggregateList.find(v => v.id === programPlan.id)?.enrollmentCount
}
isProgramSoldOut={Boolean(program.isSoldOut)}
isPublished={Boolean(program.publishedAt)}
/>
</div>
))}
Expand Down
9 changes: 8 additions & 1 deletion src/pages/ProjectPage/FundingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const FundingPage: React.VFC<ProjectProps> = ({
isCountdownTimerVisible,
totalSales,
enrollmentCount,
publishedAt,
}) => {
const { formatMessage } = useIntl()
const isDesktop = useMediaQuery({ minWidth: BREAK_POINT })
Expand Down Expand Up @@ -148,7 +149,13 @@ const FundingPage: React.VFC<ProjectProps> = ({
{formatMessage(commonMessages.button.cutoff)}
</Button>
) : (
<Button type="primary" size="large" block onClick={() => handleTabsChange('plans')}>
<Button
type="primary"
size="large"
block
onClick={() => handleTabsChange('plans')}
disabled={!publishedAt}
>
{formatMessage(commonMessages.button.pledge)}
</Button>
)}
Expand Down
1 change: 1 addition & 0 deletions src/pages/ProjectPage/ProjectPageHelmet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const ProjectPageHelmet: React.VFC<{ project: ProjectProps }> = ({ project }) =>
title={project.metaTag?.seo?.pageTitle || project.title}
description={project.metaTag?.seo?.description || project.abstract || app.settings['description']}
keywords={project.metaTag?.seo?.keywords?.split(',') || []}
isNoIndex={!project.publishedAt}
jsonLd={[
{
'@context': 'https://schema.org',
Expand Down
8 changes: 6 additions & 2 deletions src/pages/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { hasJsonStructure, notEmpty } from '../helpers'
import { ReactComponent as SearchIcon } from '../images/search.svg'
import { Activity } from '../types/activity'
import { PostPreviewProps } from '../types/blog'
import { MerchandiseBriefProps } from '../types/merchandise'
import { MerchandiseBasicProps, MerchandiseSpecBasicProps } from '../types/merchandise'
import { PodcastProgramBriefProps } from '../types/podcast'
import {
PeriodType,
Expand Down Expand Up @@ -882,6 +882,7 @@ const useSearchProductCollection = (
abstract
sold_at
currency_id
published_at
member {
id
name
Expand Down Expand Up @@ -1005,7 +1006,9 @@ const useSearchProductCollection = (
name: string
abstract: string | null
}[]
merchandises: (MerchandiseBriefProps & { shopkeeper: string; abstract: string })[]
merchandises: (MerchandiseBasicProps & {
specs: MerchandiseSpecBasicProps[]
} & { shopkeeper: string; abstract: string })[]
fundingProjects: (ProjectIntroProps & { authorSearchString: string })[]
preOrderProjects: (ProjectIntroProps & { authorSearchString: string })[]
portfolioProjects: (ProjectIntroProps & { authorSearchString: string })[]
Expand Down Expand Up @@ -1271,6 +1274,7 @@ const useSearchProductCollection = (
),
),
currencyId: merchandise.currency_id,
publishedAt: merchandise.published_at ? new Date(merchandise.published_at) : null,
tags: merchandise.merchandise_tags.map(v => v.tag_name),
categories: merchandise.merchandise_categories.map(v => ({
id: v.category.id,
Expand Down
1 change: 1 addition & 0 deletions src/types/merchandise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type MerchandiseBasicProps = {
url: string
isCover: boolean
}[]
publishedAt: Date | null
}

export type MerchandiseBriefProps = MerchandiseBasicProps & {
Expand Down

0 comments on commit 293cd38

Please sign in to comment.