-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d80ca1b
commit ba22ed4
Showing
9 changed files
with
276 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { FunctionComponent } from "react"; | ||
import styles from "../../styles/discount.module.css"; | ||
import SearchBar from "../UI/searchBar"; | ||
import Timer from "../UI/timer"; | ||
|
||
type DiscountOfferScreenVariantProps = { | ||
setSearchResult: (searchResult: SearchResult) => void; | ||
setScreen: (screen: number) => void; | ||
title: { desc: string; catch: string; descAfter?: string }; | ||
desc: string; | ||
image: string; | ||
expiry: number; | ||
}; | ||
|
||
const DiscountOfferScreenVariant: FunctionComponent< | ||
DiscountOfferScreenVariantProps | ||
> = ({ setSearchResult, setScreen, title, desc, image, expiry }) => { | ||
function onSearch(searchResult: SearchResult) { | ||
setSearchResult(searchResult); | ||
setScreen(2); | ||
} | ||
|
||
return ( | ||
<div className={styles.wrapperScreen}> | ||
<div className={styles.containerVariant}> | ||
<div className="max-w-4xl flex flex-col items-start justify-start gap-5 mx-5 mb-5"> | ||
<div className="flex flex-col lg:items-start items-center text-center sm:text-start gap-3"> | ||
<h1 className={styles.titleVariant}> | ||
{title.desc} <span className="text-primary">{title.catch}</span> | ||
{title.descAfter && " " + title.descAfter} | ||
</h1> | ||
<p className={styles.descriptionVariant}>{desc}</p> | ||
</div> | ||
<div className={styles.searchBarVariant}> | ||
<SearchBar onSearch={onSearch} showHistory={false} /> | ||
</div> | ||
</div> | ||
<div className={styles.illustrationContainerVariant}> | ||
<img src={image} className={styles.illustrationVariant} /> | ||
<Timer expiry={expiry} fixed /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DiscountOfferScreenVariant; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import type { NextPage } from "next"; | ||
import homeStyles from "../styles/Home.module.css"; | ||
import DiscountEndScreen from "../components/discount/discountEndScreen"; | ||
import DiscountCheckoutScreen from "../components/discount/discountCheckoutScreen"; | ||
|
||
// Create a new discount in utils to create a new discount campaign | ||
import { domainGift } from "../utils/discounts/domainGift"; | ||
import DiscountOfferScreenVariant from "@/components/discount/discountOfferScreenVariant"; | ||
|
||
const DomainGift: NextPage = () => { | ||
const [searchResult, setSearchResult] = useState<SearchResult | undefined>(); | ||
const [screen, setScreen] = useState<number>(1); | ||
|
||
useEffect(() => { | ||
const currentDate = new Date(); | ||
const timestamp = currentDate.getTime(); | ||
|
||
if (timestamp >= domainGift.expiry) setScreen(0); | ||
}, []); | ||
|
||
function goBack() { | ||
setScreen(screen - 1); | ||
} | ||
|
||
return ( | ||
<div className={homeStyles.screen}> | ||
{screen === 0 ? ( | ||
<DiscountEndScreen | ||
title={`${domainGift.name} discount has ended`} | ||
image={domainGift.image} | ||
/> | ||
) : null} | ||
{screen === 1 ? ( | ||
<DiscountOfferScreenVariant | ||
title={domainGift.offer.title} | ||
desc={domainGift.offer.desc} | ||
image={domainGift.offer.image ?? domainGift.image} | ||
setSearchResult={setSearchResult} | ||
setScreen={setScreen} | ||
expiry={domainGift.expiry} | ||
/> | ||
) : null} | ||
{screen === 2 ? ( | ||
<DiscountCheckoutScreen | ||
domain={searchResult?.name ?? ""} | ||
duration={domainGift.offer.duration} | ||
discountId={domainGift.offer.discountId} | ||
customMessage={domainGift.offer.customMessage} | ||
price={domainGift.offer.price} | ||
goBack={goBack} | ||
mailGroupId={domainGift.discountMailGroupId} | ||
couponCode={domainGift.offer.couponCode} | ||
couponHelper={domainGift.offer.couponHelper} | ||
banner={domainGift.image} | ||
/> | ||
) : null} | ||
</div> | ||
); | ||
}; | ||
|
||
export default DomainGift; |
Binary file not shown.
Oops, something went wrong.