Skip to content
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

feat: integrate shutdown status in game section and update owner address #36

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/images/tarot-game/shutdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 25 additions & 19 deletions src/components/pages/game/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { BaseTooltip } from '@/components/common/BaseTooltip';
import Solana from '@/components/common/Svg/Solana.tsx';
import { Button } from '@/components/ui/button.tsx';
import { env } from '@/env';
import useStatus from '@/hooks/api/use-status';
import useMakePrediction from '@/hooks/contracts/write/use-make-prediction';
import useSendSol from '@/hooks/contracts/write/use-send-sol';
import { cn } from '@/lib/utils';
Expand All @@ -29,6 +30,7 @@ const DEFAULT_IMAGE = 'images/tarot-game/bord.png';
const SHUFFLE_DECK = 'images/tarot-game/shuffle-deck.png';
const ORACLE_NEEDS_TIME = 'images/tarot-game/oracle-needs-time.png';
const THANKS_ORACLE = 'images/tarot-game/thanks-oracle.png';
const SHUTDOWN = 'images/tarot-game/shutdown.png';

const LOADING_IMAGES = [SHUFFLE_DECK, ORACLE_NEEDS_TIME] as const;
const CARD_ANIMATIONS = [
Expand All @@ -41,9 +43,11 @@ type TarotRequestSchemaType = z.infer<typeof TarotRequestSchema>;

export const GameSection = () => {
const { publicKey } = useWallet();

const { setIsOpen } = useWalletModalStore();
const { mutateAsync: transfer, isSuccess, isPending, data: predictionAnswer } = useMakePrediction();
const { mutateAsync: transferSol, isPending: isSolPending, isSuccess: isTipSuccess } = useSendSol();
const { data: status } = useStatus();

const [selectedTip, setSelectedTip] = useState<number>(0);
const [currentMainImage, setCurrentMainImage] = useState<string>(DEFAULT_IMAGE);
Expand Down Expand Up @@ -177,7 +181,7 @@ export const GameSection = () => {
</div>
)}
<img
src={currentMainImage}
src={status?.isShutDown ? SHUTDOWN : currentMainImage}
alt="bord"
className={cn(
'relative -z-50 mx-auto h-auto max-h-[484px] w-auto',
Expand Down Expand Up @@ -215,24 +219,26 @@ export const GameSection = () => {
</div>

{publicKey ? (
<Button
size="responsive"
variant="outline"
onClick={
isRetry
? () => {
setDontReload(true);
setTimeout(() => {
window.location.reload();
}, 10);
}
: handleSubmit(onSubmit)
}
disabled={isPending}
className="bg-[#9DA990] text-[22px]"
>
{isRetry ? 'Make a new Forecast' : 'Make a Forecast'}
</Button>
<BaseTooltip content={status?.isShutDown ? 'Contract is disabled' : ''}>
<Button
size="responsive"
variant="outline"
onClick={
isRetry
? () => {
setDontReload(true);
setTimeout(() => {
window.location.reload();
}, 10);
}
: handleSubmit(onSubmit)
}
disabled={isPending || status?.isShutDown}
className="h-full w-full bg-[#9DA990] text-[22px]"
>
{isRetry ? 'Make a new Forecast' : 'Make a Forecast'}
</Button>
</BaseTooltip>
) : (
<Button
size="responsive"
Expand Down
2 changes: 1 addition & 1 deletion src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export const wSolMint = new PublicKey('So111111111111111111111111111111111111111

export const OwnerAddress = {
[WalletAdapterNetwork.Mainnet]: new PublicKey('2Mko2nLhSiehXGJDseYCj6hYQdrK3cKNMetcGaXtbrJk'),
[WalletAdapterNetwork.Devnet]: new PublicKey('9Her7ga9XNUdjGj8utwkze9v2d1k6aZ9tac9SzJweED8'),
[WalletAdapterNetwork.Devnet]: new PublicKey('8LD69Ao7ULmWJNWULkUa5jhaLY9n7ucWcVGFcbfrFNwm'),
};
Loading