diff --git a/web/components/contract/contract-info-dialog.tsx b/web/components/contract/contract-info-dialog.tsx index 1cae98f9..306b2587 100644 --- a/web/components/contract/contract-info-dialog.tsx +++ b/web/components/contract/contract-info-dialog.tsx @@ -40,8 +40,9 @@ export function ContractInfoDialog(props: { const isAdmin = useAdmin() const isCreator = user?.id === contract.creatorId const isUnlisted = contract.visibility === 'unlisted' - const wasUnlistedByCreator = - contract.unlistedById && contract.unlistedById === contract.creatorId + const wasUnlistedByCreator = contract.unlistedById + ? contract.unlistedById === contract.creatorId + : true const formatTime = (dt: number) => dayjs(dt).format('MMM DD, YYYY hh:mm a') @@ -173,32 +174,34 @@ export function ContractInfoDialog(props: { [ADMIN] Featured )} - {user && - (isAdmin || - (isCreator && - (isUnlisted ? wasUnlistedByCreator : true))) && ( - - {isAdmin ? '[ADMIN]' : ''} Unlisted - - - updateContract(id, { - visibility: b ? 'unlisted' : 'public', - unlistedById: b ? user.id : '', - }) - } - /> - - - )} + {user && ( + + {isAdmin ? '[ADMIN]' : ''} Unlisted + + + updateContract(id, { + visibility: b ? 'unlisted' : 'public', + unlistedById: b ? user.id : '', + }) + } + /> + + + )} diff --git a/web/components/widgets/short-toggle.tsx b/web/components/widgets/short-toggle.tsx index 339de361..d8baeebe 100644 --- a/web/components/widgets/short-toggle.tsx +++ b/web/components/widgets/short-toggle.tsx @@ -3,22 +3,27 @@ import { Switch } from '@headlessui/react' import clsx from 'clsx' export default function ShortToggle(props: { - enabled: boolean - setEnabled: (enabled: boolean) => void + on: boolean + setOn: (enabled: boolean) => void + disabled?: boolean onChange?: (enabled: boolean) => void }) { - const { enabled, setEnabled } = props + const { on, setOn, disabled } = props return ( { - setEnabled(e) + setOn(e) if (props.onChange) { props.onChange(e) } }} - className="group relative inline-flex h-5 w-10 flex-shrink-0 cursor-pointer items-center justify-center rounded-full focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2" + className={clsx( + 'group relative inline-flex h-5 w-10 flex-shrink-0 items-center justify-center rounded-full focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2', + !disabled ? 'cursor-pointer' : 'cursor-not-allowed opacity-50' + )} > Use setting