diff --git a/components/Alert/index.tsx b/components/Alert/index.tsx
index 8c7d6864..a9564424 100644
--- a/components/Alert/index.tsx
+++ b/components/Alert/index.tsx
@@ -39,7 +39,7 @@ const Alert = (props: Props) => {
diff --git a/components/CharacterGrid/index.tsx b/components/CharacterGrid/index.tsx
index 48cc0ca8..3532caf0 100644
--- a/components/CharacterGrid/index.tsx
+++ b/components/CharacterGrid/index.tsx
@@ -171,6 +171,15 @@ const CharacterGrid = (props: Props) => {
setIncoming(undefined)
}
+ async function removeCharacter(id: string) {
+ try {
+ const response = await api.endpoints.grid_characters.destroy({ id: id })
+ appState.grid.characters[response.data.position] = undefined
+ } catch (error) {
+ console.error(error)
+ }
+ }
+
// Methods: Saving job and job skills
const saveJob = async function (job?: Job) {
const payload = {
@@ -371,6 +380,7 @@ const CharacterGrid = (props: Props) => {
position={i}
updateObject={receiveCharacterFromSearch}
updateUncap={initiateUncapUpdate}
+ removeCharacter={removeCharacter}
/>
)
diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx
index f9312a5d..8ffc549f 100644
--- a/components/WeaponGrid/index.tsx
+++ b/components/WeaponGrid/index.tsx
@@ -7,18 +7,18 @@ import { useTranslation } from 'next-i18next'
import { AxiosResponse } from 'axios'
import debounce from 'lodash.debounce'
+import Alert from '~components/Alert'
import WeaponUnit from '~components/WeaponUnit'
import ExtraWeapons from '~components/ExtraWeapons'
+import WeaponConflictModal from '~components/WeaponConflictModal'
import api from '~utils/api'
import { appState } from '~utils/appState'
+import { accountState } from '~utils/accountState'
import type { DetailsObject, SearchableObject } from '~types'
import './index.scss'
-import WeaponConflictModal from '~components/WeaponConflictModal'
-import Alert from '~components/Alert'
-import { accountState } from '~utils/accountState'
// Props
interface Props {
@@ -198,6 +198,21 @@ const WeaponGrid = (props: Props) => {
setIncoming(undefined)
}
+ async function removeWeapon(id: string) {
+ try {
+ const response = await api.endpoints.grid_weapons.destroy({ id: id })
+ const data = response.data
+
+ if (data.position === -1) {
+ appState.grid.weapons.mainWeapon = undefined
+ } else {
+ appState.grid.weapons.allWeapons[response.data.position] = undefined
+ }
+ } catch (error) {
+ console.error(error)
+ }
+ }
+
// Methods: Updating uncap level
// Note: Saves, but debouncing is not working properly
async function saveUncap(id: string, position: number, uncapLevel: number) {
@@ -254,7 +269,7 @@ const WeaponGrid = (props: Props) => {
)
const updateUncapLevel = (position: number, uncapLevel: number) => {
- console.log(`Updating uncap level at position ${position} to ${uncapLevel}`)
+ // console.log(`Updating uncap level at position ${position} to ${uncapLevel}`)
if (appState.grid.weapons.mainWeapon && position == -1)
appState.grid.weapons.mainWeapon.uncap_level = uncapLevel
else {
@@ -292,6 +307,7 @@ const WeaponGrid = (props: Props) => {
key="grid_mainhand"
position={-1}
unitType={0}
+ removeWeapon={removeWeapon}
updateObject={receiveWeaponFromSearch}
updateUncap={initiateUncapUpdate}
/>
@@ -305,6 +321,7 @@ const WeaponGrid = (props: Props) => {
editable={party.editable}
position={i}
unitType={1}
+ removeWeapon={removeWeapon}
updateObject={receiveWeaponFromSearch}
updateUncap={initiateUncapUpdate}
/>
diff --git a/components/WeaponUnit/index.tsx b/components/WeaponUnit/index.tsx
index 31c04371..2c18cf53 100644
--- a/components/WeaponUnit/index.tsx
+++ b/components/WeaponUnit/index.tsx
@@ -480,11 +480,11 @@ const WeaponUnit = ({
setAlertOpen(false)}
cancelActionText={t('buttons.cancel')}
message={
-
+
Are you sure you want to remove{' '}
{{ weapon: gridWeapon?.object.name[locale] }} from
your team?
diff --git a/public/locales/en/common.json b/public/locales/en/common.json
index cb495881..dbf343fe 100644
--- a/public/locales/en/common.json
+++ b/public/locales/en/common.json
@@ -253,7 +253,8 @@
"weapon": {
"title": "Modify Weapon",
"buttons": {
- "confirm": "Save weapon"
+ "confirm": "Save weapon",
+ "remove": "Remove weapon"
},
"subtitles": {
"element": "Element",
diff --git a/public/locales/ja/common.json b/public/locales/ja/common.json
index 207cea38..e5acc9d6 100644
--- a/public/locales/ja/common.json
+++ b/public/locales/ja/common.json
@@ -254,7 +254,8 @@
"weapon": {
"title": "武器変更",
"buttons": {
- "confirm": "武器を変更する"
+ "confirm": "武器を変更する",
+ "remove": "武器を削除する"
},
"subtitles": {
"element": "属性",