diff --git a/components/about/updates/ContentUpdate2024/index.tsx b/components/about/updates/ContentUpdate2024/index.tsx index 51c94547..dd07d2e2 100644 --- a/components/about/updates/ContentUpdate2024/index.tsx +++ b/components/about/updates/ContentUpdate2024/index.tsx @@ -7,6 +7,34 @@ const ContentUpdate2024 = () => { return ( <> + + void onOpenChange: () => void onClose?: () => void + sendValidity: (isValid: boolean) => void } // Constants @@ -47,10 +52,33 @@ const emptyWeaponKey: WeaponKey = { const WeaponKeySelect = React.forwardRef( function useFieldSet( - { open, weaponKey, series, slot, onChange, onOpenChange, onClose }, + { + open, + gridWeapon, + weaponKey, + series, + slot, + onChange, + onOpenChange, + onClose, + sendValidity, + }, ref ) { + const router = useRouter() + const locale = + router.locale && ['en', 'ja'].includes(router.locale) + ? router.locale + : 'en' + const { t } = useTranslation('common') + const [keys, setKeys] = useState([]) + const [error, setError] = useState('') + + const errorClasses = classNames({ + [styles.errors]: true, + [styles.visible]: error !== '', + }) useEffect(() => { const keys = flattenWeaponKeys() @@ -134,7 +162,18 @@ const WeaponKeySelect = React.forwardRef( const keys = flattenWeaponKeys() const found = keys.find((key) => key.id == value) const weaponKey = found ? found : emptyWeaponKey - if (onChange) onChange(weaponKey, slot) + + if ( + ['14005', '14006', '14007'].includes(`${weaponKey.granblue_id}`) && + gridWeapon.transcendence_step < 3 + ) { + setError(`${weaponKey.name[locale]} requires 3rd Transcendence`) + sendValidity(false) + } else if (onChange) { + setError('') + onChange(weaponKey, slot) + sendValidity(true) + } } const emptyOption = () => { @@ -148,26 +187,29 @@ const WeaponKeySelect = React.forwardRef( } return ( - + <> + +

{error}

+ ) } ) diff --git a/components/weapon/WeaponModal/index.tsx b/components/weapon/WeaponModal/index.tsx index d17255b6..c5a6bada 100644 --- a/components/weapon/WeaponModal/index.tsx +++ b/components/weapon/WeaponModal/index.tsx @@ -50,6 +50,12 @@ const WeaponModal = ({ // State: Component const [alertOpen, setAlertOpen] = useState(false) + const [keysValid, setKeysValid] = useState([ + true, + true, + true, + true, + ]) const [formValid, setFormValid] = useState(false) // State: Selects @@ -149,6 +155,12 @@ const WeaponModal = ({ setFormValid(isValid) } + function receiveKeyValidity(isValid: boolean, slot: number) { + const newKeysValid = keysValid + newKeysValid[slot] = isValid + setKeysValid(newKeysValid) + } + // Methods: Data submission function prepareObject() { let object: GridWeaponObject = { weapon: {} } @@ -159,9 +171,17 @@ const WeaponModal = ({ object.weapon.weapon_key1_id = weaponKey1.id } - if ([2, 3, 17, 34].includes(gridWeapon.object.series) && weaponKey2) + if ([2, 3, 17, 34].includes(gridWeapon.object.series) && weaponKey2) { object.weapon.weapon_key2_id = weaponKey2.id + if ( + ['14005', '14006', '14007'].includes(weaponKey2.granblue_id) && + gridWeapon.transcendence_step < 3 + ) { + object.weapon.weapon_key2_id = undefined + } + } + if ([17].includes(gridWeapon.object.series) && weaponKey3) object.weapon.weapon_key3_id = weaponKey3.id @@ -356,12 +376,14 @@ const WeaponModal = ({ {[2, 3, 17, 22, 34].includes(gridWeapon.object.series) ? ( openSelect(1)} onChange={receiveWeaponKey} onClose={() => setWeaponKey1Open(false)} + sendValidity={(valid: boolean) => receiveKeyValidity(valid, 0)} /> ) : ( '' @@ -370,12 +392,14 @@ const WeaponModal = ({ {[2, 3, 17, 34].includes(gridWeapon.object.series) ? ( openSelect(2)} onChange={receiveWeaponKey} onClose={() => setWeaponKey2Open(false)} + sendValidity={(valid: boolean) => receiveKeyValidity(valid, 1)} /> ) : ( '' @@ -384,12 +408,14 @@ const WeaponModal = ({ {[17].includes(gridWeapon.object.series) ? ( openSelect(3)} onChange={receiveWeaponKey} onClose={() => setWeaponKey3Open(false)} + sendValidity={(valid: boolean) => receiveKeyValidity(valid, 2)} /> ) : ( '' @@ -398,12 +424,14 @@ const WeaponModal = ({ {gridWeapon.object.series == 24 && gridWeapon.object.uncap.ulb ? ( openSelect(4)} onChange={receiveWeaponKey} onClose={() => setWeaponKey4Open(false)} + sendValidity={(valid: boolean) => receiveKeyValidity(valid, 4)} /> ) : ( '' @@ -496,7 +524,7 @@ const WeaponModal = ({ bound={true} onClick={handleUpdateWeapon} key="confirm" - disabled={!formValid} + disabled={!formValid || keysValid.includes(false)} text={t('modals.weapon.buttons.confirm')} />, ]} diff --git a/public/locales/en/updates.json b/public/locales/en/updates.json index ce16d109..1594be56 100644 --- a/public/locales/en/updates.json +++ b/public/locales/en/updates.json @@ -29,6 +29,14 @@ "uncap": "Uncap" }, "versions": { + "2024-05U1": { + "features": [ + "Added new raids: Colossus Ira Omega (Impossible) and Celeste Ater Omega (Impossible)", + "Pendulum of Extremity, Pendulum of Sagacity, and Pendulum of Supremacy added (I kept forgetting about these)", + "Only Dark Opus Weapons at Transcendence Lv3 or higher can equip the new Pendulums", + "Fixed a bug where users could not set the awakening level on some Grand weapons" + ] + }, "2024-03U3": { "features": [ "Added new raids: Tiamat Aura Omega (Impossible) and Luminiera Credo Omega (Impossible)", diff --git a/public/locales/ja/updates.json b/public/locales/ja/updates.json index 1995e173..4b406202 100644 --- a/public/locales/ja/updates.json +++ b/public/locales/ja/updates.json @@ -29,6 +29,14 @@ "uncap": "上限解放" }, "versions": { + "2024-05U1": { + "features": [ + "新マルチバトル追加「コロッサス・イラマグナHL」「セレスト・アーテルマグナHL」", + "新ペンデュラム追加「絶涯のペンデュラム」「窮理のペンデュラム」「天髄のペンデュラム」(忘れてしまいました、申し訳ありません)", + "限界超越レベル3以上の終末武器しか新ペンデュラムが装備することができません", + "リミテッド武器の覚醒Lvが変更できない不具合を修正" + ] + }, "2024-03U3": { "features": [ "新マルチバトル追加「ティアマト・アウラマグナHL」「シュヴァリエ・クレドマグナHL」",