Fix remix toasts and alerts from both locations
The remix toast and alert was barely hooked up and not showing up when invoked from PartyHeader. It now shows up whether you remix your own team (from PartyDropdown) or if you remix another person's team (from PartyHeader).
This commit is contained in:
parent
445c2773b5
commit
a77be2b068
4 changed files with 66 additions and 10 deletions
|
|
@ -46,7 +46,7 @@ const RemixTeamAlert = ({
|
||||||
<Trans i18nKey="modals.remix_team.description.viewer">
|
<Trans i18nKey="modals.remix_team.description.viewer">
|
||||||
Remixing a team makes a copy of it in your account so you can make
|
Remixing a team makes a copy of it in your account so you can make
|
||||||
your own changes.\n\nWould you like to remix{' '}
|
your own changes.\n\nWould you like to remix{' '}
|
||||||
<strong>{{ name: 'HEY' }}</strong>?
|
<strong>{{ name: name }}</strong>?
|
||||||
</Trans>
|
</Trans>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ const PartyDropdown = ({
|
||||||
setCopyToastOpen(false)
|
setCopyToastOpen(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toasts / Remix team
|
// Toasts: Remix team
|
||||||
function handleRemixToastOpenChanged(open: boolean) {
|
function handleRemixToastOpenChanged(open: boolean) {
|
||||||
setRemixToastOpen(!open)
|
setRemixToastOpen(!open)
|
||||||
}
|
}
|
||||||
|
|
@ -140,6 +140,11 @@ const PartyDropdown = ({
|
||||||
setRemixToastOpen(false)
|
setRemixToastOpen(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remixCallback() {
|
||||||
|
setRemixToastOpen(true)
|
||||||
|
remixTeamCallback()
|
||||||
|
}
|
||||||
|
|
||||||
const editableItems = () => {
|
const editableItems = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -184,17 +189,19 @@ const PartyDropdown = ({
|
||||||
|
|
||||||
<RemixTeamAlert
|
<RemixTeamAlert
|
||||||
creator={editable}
|
creator={editable}
|
||||||
name={partySnapshot.name ? partySnapshot.name : t('no_title')}
|
name={partySnapshot.name || t('no_title')}
|
||||||
open={remixAlertOpen}
|
open={remixAlertOpen}
|
||||||
onOpenChange={handleRemixTeamAlertChange}
|
onOpenChange={handleRemixTeamAlertChange}
|
||||||
remixCallback={remixTeamCallback}
|
remixCallback={remixCallback}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RemixedToast
|
<RemixedToast
|
||||||
open={remixToastOpen}
|
open={remixToastOpen}
|
||||||
partyName={originalName}
|
partyName={partySnapshot.name || t('no_title')}
|
||||||
onOpenChange={handleRemixToastOpenChanged}
|
onOpenChange={handleRemixToastOpenChanged}
|
||||||
onCloseClick={handleRemixToastCloseClicked}
|
onCloseClick={handleRemixToastCloseClicked}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UrlCopiedToast
|
<UrlCopiedToast
|
||||||
open={copyToastOpen}
|
open={copyToastOpen}
|
||||||
onOpenChange={handleCopyToastOpenChanged}
|
onOpenChange={handleCopyToastOpenChanged}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ import SaveIcon from '~public/icons/Save.svg'
|
||||||
import type { DetailsObject } from 'types'
|
import type { DetailsObject } from 'types'
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
import RemixTeamAlert from '~components/dialogs/RemixTeamAlert'
|
||||||
|
import RemixedToast from '~components/toasts/RemixedToast'
|
||||||
|
import { set } from 'local-storage'
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -44,13 +47,16 @@ const PartyHeader = (props: Props) => {
|
||||||
|
|
||||||
const { party: partySnapshot } = useSnapshot(appState)
|
const { party: partySnapshot } = useSnapshot(appState)
|
||||||
|
|
||||||
const [name, setName] = useState('')
|
// State: Component
|
||||||
|
const [remixAlertOpen, setRemixAlertOpen] = useState(false)
|
||||||
|
const [remixToastOpen, setRemixToastOpen] = useState(false)
|
||||||
|
|
||||||
|
// State: Data
|
||||||
|
const [name, setName] = useState('')
|
||||||
const [chargeAttack, setChargeAttack] = useState(true)
|
const [chargeAttack, setChargeAttack] = useState(true)
|
||||||
const [fullAuto, setFullAuto] = useState(false)
|
const [fullAuto, setFullAuto] = useState(false)
|
||||||
const [autoGuard, setAutoGuard] = useState(false)
|
const [autoGuard, setAutoGuard] = useState(false)
|
||||||
const [autoSummon, setAutoSummon] = useState(false)
|
const [autoSummon, setAutoSummon] = useState(false)
|
||||||
|
|
||||||
const [buttonCount, setButtonCount] = useState<number | undefined>(undefined)
|
const [buttonCount, setButtonCount] = useState<number | undefined>(undefined)
|
||||||
const [chainCount, setChainCount] = useState<number | undefined>(undefined)
|
const [chainCount, setChainCount] = useState<number | undefined>(undefined)
|
||||||
const [turnCount, setTurnCount] = useState<number | undefined>(undefined)
|
const [turnCount, setTurnCount] = useState<number | undefined>(undefined)
|
||||||
|
|
@ -157,6 +163,32 @@ const PartyHeader = (props: Props) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actions: Remix team
|
||||||
|
function remixTeamCallback() {
|
||||||
|
setRemixToastOpen(true)
|
||||||
|
props.remixCallback()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alerts: Remix team
|
||||||
|
function openRemixTeamAlert() {
|
||||||
|
setRemixAlertOpen(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRemixTeamAlertChange(open: boolean) {
|
||||||
|
setRemixAlertOpen(open)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toasts: Remix team
|
||||||
|
function handleRemixToastOpenChanged(open: boolean) {
|
||||||
|
setRemixToastOpen(!open)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRemixToastCloseClicked() {
|
||||||
|
setRemixToastOpen(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
|
||||||
const userBlock = (username?: string, picture?: string, element?: string) => {
|
const userBlock = (username?: string, picture?: string, element?: string) => {
|
||||||
return (
|
return (
|
||||||
<div className={userClass}>
|
<div className={userClass}>
|
||||||
|
|
@ -354,7 +386,7 @@ const PartyHeader = (props: Props) => {
|
||||||
leftAccessoryIcon={<RemixIcon />}
|
leftAccessoryIcon={<RemixIcon />}
|
||||||
className="Remix"
|
className="Remix"
|
||||||
text={t('buttons.remix')}
|
text={t('buttons.remix')}
|
||||||
onClick={props.remixCallback}
|
onClick={openRemixTeamAlert}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)
|
)
|
||||||
|
|
@ -423,6 +455,21 @@ const PartyHeader = (props: Props) => {
|
||||||
</div>
|
</div>
|
||||||
<section className={classes}>{renderTokens()}</section>
|
<section className={classes}>{renderTokens()}</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<RemixTeamAlert
|
||||||
|
creator={props.editable}
|
||||||
|
name={partySnapshot.name ? partySnapshot.name : t('no_title')}
|
||||||
|
open={remixAlertOpen}
|
||||||
|
onOpenChange={handleRemixTeamAlertChange}
|
||||||
|
remixCallback={remixTeamCallback}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<RemixedToast
|
||||||
|
open={remixToastOpen}
|
||||||
|
partyName={props.party?.name || t('no_title')}
|
||||||
|
onOpenChange={handleRemixToastOpenChanged}
|
||||||
|
onCloseClick={handleRemixToastCloseClicked}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import Toast from '~components/common/Toast'
|
import Toast from '~components/common/Toast'
|
||||||
import { Trans, useTranslation } from 'next-i18next'
|
import { Trans, useTranslation } from 'next-i18next'
|
||||||
|
|
||||||
|
|
@ -17,7 +17,9 @@ const RemixedToast = ({
|
||||||
onCloseClick,
|
onCloseClick,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { t } = useTranslation('common')
|
const { t } = useTranslation('common')
|
||||||
|
useEffect(() => {
|
||||||
|
console.log(partyName)
|
||||||
|
}, [])
|
||||||
// Methods: Event handlers
|
// Methods: Event handlers
|
||||||
function handleOpenChange() {
|
function handleOpenChange() {
|
||||||
onOpenChange(open)
|
onOpenChange(open)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue