Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into refactor/add-formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
posaune0423 committed Jul 4, 2024
2 parents ea19143 + 143b6b8 commit 013725f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useState, useEffect, useRef } from 'react';
// import { Link } from 'react-router-dom';
import { SketchPicker } from 'react-color';
import Select, {
type CSSObjectWithLabel,
type GroupBase,
type OptionProps,
type CSSObjectWithLabel,
type SingleValue,
} from 'react-select';
import { ProposalType } from '@/global/types';
Expand All @@ -16,11 +15,10 @@ import useAllowedColors from '@/hooks/useAllowedColors.ts';
const NewProposalPopupForMain: React.FC = () => {
const [proposalType, setProposalType] = useState('Add Color');
const [color, setColor] = useState('#FFFFFF00');

const [isCreatingNewProposal, setIsCreatingNewProposal] = useState(false);
const [showColorPicker, setShowColorPicker] = useState(false);
const colorPickerRef = useRef<HTMLDivElement>(null);
const popupRef = useRef<HTMLDivElement>(null);
const colorPickerRef = useRef<HTMLDivElement | null>(null);
const popupRef = useRef<HTMLDivElement | null>(null);

const { gameData } = usePixelawProvider();

Expand Down Expand Up @@ -75,7 +73,10 @@ const NewProposalPopupForMain: React.FC = () => {
setIsCreatingNewProposal(false);
// toastProposalAdded('Proposal Added'); // should be broadcast for everyone.
})
.catch((e) => toastContractError(e));
.catch((e) => {
console.error('handleSubmit error: ', e);
toastContractError(e);
});
}
};

Expand Down Expand Up @@ -170,8 +171,6 @@ const NewProposalPopupForMain: React.FC = () => {

{isCreatingNewProposal && (
<div className='fixed inset-0 z-20 flex items-center justify-center bg-black bg-opacity-50 backdrop-blur'>
{/* <div className='min-h-screen bg-gray-900 text-white flex flex-col'> */}
{/* <div className='flex justify-center items-center flex-grow p-4'> */}
<div ref={popupRef} className='w-1/3'>
<div className='w-full max-w-xl rounded-lg bg-gray-800 p-12 text-white shadow-lg'>
<h2 className='mb-6 text-3xl font-bold'>New Proposal</h2>
Expand Down
43 changes: 22 additions & 21 deletions src/components/NewProposalPopupForMain/ProposalListForMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useState, useRef, useEffect } from 'react';
import ProposalItem, { type StartVoteParam } from '../ProposalList/ProposalItem';
import { usePixelawProvider } from '@/providers/PixelawProvider';
import { GAME_ID } from '@/global/constants.ts';
import { toastContractError, toastProposalAdded } from '@/global/utils.ts';
import { toastContractError } from '@/global/utils.ts';
import useProposals from '@/hooks/useProposals.ts';

interface ProposalListForMainProps {
Expand Down Expand Up @@ -49,25 +49,25 @@ const ProposalListForMain: React.FC<ProposalListForMainProps> = ({
const proposals = useProposals(GAME_ID);
const proposalArray = proposals?.data ?? [];

// const getStatusColor = (status: string) => {
// if (status.startsWith('end in')) {
// return 'bg-green-500';
// } else if (status === 'closed') {
// return 'bg-purple-500';
// } else {
// return 'bg-gray-500';
// }
// };

// const getStatusColorForBg = (status: string) => {
// if (status.startsWith('end in')) {
// return 'bg-black-800';
// } else if (status === 'closed') {
// return 'bg-gray-500';
// } else {
// return 'bg-black-800';
// }
// };
const getStatusColor = (status: string) => {
if (status.startsWith('end in')) {
return 'bg-green-500';
} else if (status === 'closed') {
return 'bg-purple-500';
} else {
return 'bg-gray-500';
}
};

const getStatusColorForBg = (status: string) => {
if (status.startsWith('end in')) {
return 'bg-black-800';
} else if (status === 'closed') {
return 'bg-gray-500';
} else {
return 'bg-black-800';
}
};

const handleVote = (proposal: StartVoteParam) => {
setSelectedProposal(proposal);
Expand All @@ -86,6 +86,7 @@ const ProposalListForMain: React.FC<ProposalListForMainProps> = ({
)
.then(() => setSelectedProposal(null))
.catch((e) => {
console.error('handleVoteProposal error: ', e);
toastContractError(e);
});
};
Expand All @@ -110,7 +111,7 @@ const ProposalListForMain: React.FC<ProposalListForMainProps> = ({
};

return (
<div className=''>
<div>
<div
className={`overflow-y-auto px-2`}
style={{ height: `calc(100vh - ${headerHeight}px - 30vh)` }}
Expand Down
1 change: 1 addition & 0 deletions src/components/ProposalList/ProposalItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const ProposalItem: React.FC<PropsType> = ({ proposal, onStartVote, filter, sear
.activateProposal(gameData.account.account, GAME_ID, proposal.index)
.then(() => console.log('activateProposal'))
.catch((e) => {
console.error('handleActivateProposal error: ', e);
toastContractError(e);
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useDojoInteractHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export const useDojoInteractHandler = (pixelStore: PixelStore, gameData: IPixela
// Do something with the UI?
})
.catch((e) => {
console.error(e);
console.error('dojocall error', e);
toastContractError(e);
});
setClickedCell(undefined);
}, [setClickedCell, clickedCell]);
}, [setClickedCell, clickedCell, color, selectedApp, pixelStore, gameData]);
};

0 comments on commit 013725f

Please sign in to comment.