-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rpkm baan announcement modal #184
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,245 @@ | ||
import { useRouter } from 'next/navigation'; | ||
import { useState } from 'react'; | ||
import Image from 'next/image'; | ||
import Link from 'next/link'; | ||
import CrossIcon from '@public/cross-white.svg'; | ||
import LineWhite from '@public/line-white.png'; | ||
import Baan from '@public/baan.svg'; | ||
import InstagramIcon from '@public/rpkm/instagram-icon.svg'; | ||
import { baanInfos } from '@/components/rpkm/Baan/baanInfos'; | ||
import BaseModal from '@/components/rpkm/Modal/BaseModal'; | ||
import { cn } from '@/lib/utils'; | ||
import { useBaan } from '@/context/BaanContext'; | ||
import { useAuth } from '@/context/AuthContext'; | ||
|
||
interface BaanResultModalProps { | ||
modal: boolean; | ||
setModal: (value: boolean) => void; | ||
checkBaanResult: () => void; | ||
} | ||
|
||
const BaanResultModal: React.FC<BaanResultModalProps> = ({ | ||
modal, | ||
setModal, | ||
checkBaanResult, | ||
}) => { | ||
const router = useRouter(); | ||
const [mode, setMode] = useState<'th' | 'en'>('th'); | ||
const { isConfirmed } = useBaan(); | ||
const { user } = useAuth(); | ||
|
||
const HandleOnClick = () => { | ||
checkBaanResult(); | ||
router.push('/rpkm/activities/home'); | ||
}; | ||
|
||
const findBaan = (result: string) => { | ||
return baanInfos.find((baan) => baan.name.en === result); | ||
}; | ||
|
||
if (!user) return; | ||
const baan = findBaan(user.baan); | ||
|
||
return ( | ||
<div> | ||
{isConfirmed && !!baan ? ( | ||
<BaseModal | ||
variant="blue" | ||
open={modal} | ||
> | ||
<div className="relative w-[75vw]"> | ||
<div className="absolute top-4 right-5"> | ||
<button | ||
className="z-10" | ||
onClick={() => { | ||
setModal(false); | ||
HandleOnClick(); | ||
}} | ||
> | ||
<Image | ||
src={CrossIcon} | ||
alt="cross" | ||
width={10} | ||
height={10} | ||
style={{ width: '1.76vh', height: '1.76vh' }} | ||
/> | ||
</button> | ||
</div> | ||
<div className="flex items-center justify-center w-full flex-col"> | ||
<div className="flex items-center my-2"> | ||
<button | ||
onClick={() => setMode('th')} | ||
className={cn( | ||
'px-[0.6rem] rounded-l-full text-sm', | ||
mode == 'th' | ||
? 'bg-rpkm-pink text-white' | ||
: 'bg-white text-black' | ||
)} | ||
> | ||
TH | ||
</button> | ||
<button | ||
onClick={() => setMode('en')} | ||
className={cn( | ||
'px-[0.6rem] rounded-r-full text-sm', | ||
mode == 'th' | ||
? 'bg-white text-black' | ||
: 'bg-rpkm-pink text-white' | ||
)} | ||
> | ||
EN | ||
</button> | ||
</div> | ||
<h1 className="text-3xl font-bold text-white mt-2"> | ||
{mode === 'th' ? 'ยินดีด้วย!' : 'Congratulations!'} | ||
</h1> | ||
<p className="text-white text-base text-center"> | ||
{mode === 'th' | ||
? 'คุณได้รับเลือกเข้าสู่...!' | ||
: 'You have been selected for...'} | ||
</p> | ||
<div className="flex justify-center w-full my-2"> | ||
<Image | ||
src={baan.logo} | ||
alt="baan" | ||
className="w-44 p-1 border-[#F5F5F5] bg-[#F5F5F5] border-1" | ||
/> | ||
</div> | ||
<h2 className="text-2xl font-semibold text-white"> | ||
{`'${mode === 'th' ? 'บ้าน' : 'Baan '}${baan.name[mode]}'`} | ||
</h2> | ||
<div className="my-3"> | ||
<Image | ||
src={LineWhite} | ||
alt="lineWhite" | ||
/> | ||
</div> | ||
<p | ||
className={cn( | ||
'text-center text-xl font-semibold text-white mt-1', | ||
{ | ||
'text-lg': mode === 'en', | ||
} | ||
)} | ||
> | ||
{mode === 'th' | ||
? 'ติดตามข่าวสารต่อได้ที่' | ||
: 'For more information, please visit'} | ||
</p> | ||
<div className="flex flex-row justify-center w-full gap-x-1 mt-2 mb-3"> | ||
<Image | ||
src={InstagramIcon} | ||
alt="instagram icon" | ||
/> | ||
<Link | ||
href={`https://www.instagram.com/${baan.ig}/`} | ||
className="text-white text-base text-center" | ||
> | ||
{baan.ig} | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</BaseModal> | ||
) : ( | ||
<BaseModal | ||
variant="blue" | ||
open={modal} | ||
> | ||
<div className="relative w-[75vw]"> | ||
<div className="absolute top-4 right-5"> | ||
<button | ||
className="z-10" | ||
onClick={() => { | ||
setModal(false); | ||
HandleOnClick(); | ||
}} | ||
> | ||
<Image | ||
src={CrossIcon} | ||
alt="cross" | ||
width={10} | ||
height={10} | ||
style={{ width: '1.76vh', height: '1.76vh' }} | ||
/> | ||
</button> | ||
</div> | ||
<div className="flex items-center justify-center w-full flex-col"> | ||
<div className="flex items-center my-2"> | ||
<button | ||
onClick={() => setMode('th')} | ||
className={cn( | ||
'px-[0.6rem] rounded-l-full text-sm', | ||
mode == 'th' | ||
? 'bg-rpkm-pink text-white' | ||
: 'bg-white text-black' | ||
)} | ||
> | ||
TH | ||
</button> | ||
<button | ||
onClick={() => setMode('en')} | ||
className={cn( | ||
'px-[0.6rem] rounded-r-full text-sm', | ||
mode == 'th' | ||
? 'bg-white text-black' | ||
: 'bg-rpkm-pink text-white' | ||
)} | ||
> | ||
EN | ||
</button> | ||
</div> | ||
<h1 className="text-3xl font-bold text-white mt-2"> | ||
{mode === 'th' ? 'น่าเสียดาย!' : 'Unfortunately!'} | ||
</h1> | ||
<p className="text-white text-base text-center"> | ||
{mode === 'th' | ||
? 'คุณไม่ได้ทำการเลือกบ้าน' | ||
: 'You did not select any Baans'} | ||
</p> | ||
<div className="flex justify-center w-full mt-6 mb-3"> | ||
<Image | ||
src={Baan} | ||
alt="baan" | ||
className="p-1 border-[#F5F5F5] bg-[#F5F5F5] border-1" | ||
/> | ||
</div> | ||
<div className="my-3"> | ||
<Image | ||
src={LineWhite} | ||
alt="lineWhite" | ||
/> | ||
</div> | ||
<p | ||
className={cn( | ||
'text-center text-xl font-semibold text-white mt-1', | ||
{ | ||
'text-md': mode === 'en', | ||
} | ||
)} | ||
> | ||
{mode === 'th' | ||
? 'ติดต่อสอบถามเพิ่มเติมได้ที่' | ||
: 'For further inquiries, please contact'} | ||
</p> | ||
<div className="flex flex-row justify-center w-full gap-x-1 mt-2 mb-3"> | ||
<Image | ||
src={InstagramIcon} | ||
alt="instagram icon" | ||
/> | ||
<Link | ||
href={`https://www.instagram.com/rubpuenkaomai2024/`} | ||
className="text-white text-base text-center" | ||
> | ||
rubpuenkaomai2024 | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</BaseModal> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default BaanResultModal; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ไม่ต้องขึ้น toast อันนี้เราไม่ได้ต้องการให้ user เห็น