Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(entrance): error when moving an entrance to another cave #975 #979

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/web-app/public/lang/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@
"Entrance name language": "Език за името на входа",
"Entrance properties": "свойства на Входа",
"Entrance successfully created!": "Входът е създаден успешно!",
"Entrance successfully moved from {intialCave} to {finalCave}!": "Вход успешно преместен от {intialCave} в {finalCave}!",
"Entrance successfully moved from {initialCave} to {finalCave}!": "Вход успешно преместен от {initialCave} в {finalCave}!",
"Entrance successfully updated!": "Входът е актуализиран успешно!",
"entrances": "входове",
"Entrances": "Входове",
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app/public/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@
"Entrance name language": "Entrance name language",
"Entrance properties": "Entrance properties",
"Entrance successfully created!": "Entrance successfully created!",
"Entrance successfully moved from {intialCave} to {finalCave}!": "Entrance successfully moved from {intialCave} to {finalCave}!",
"Entrance successfully moved from {initialCave} to {finalCave}!": "Entrance successfully moved from {initialCave} to {finalCave}!",
"Entrance successfully updated!": "Entrance successfully updated!",
"entrances": "entrances",
"Entrances": "Entrances",
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app/public/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@
"Entrance name language": "Idioma del nombre de la entrada",
"Entrance properties": "Propiedades de la entrada",
"Entrance successfully created!": "¡Entrada creada con éxito!",
"Entrance successfully moved from {intialCave} to {finalCave}!": "¡Entrada movida con éxito de {intialCave} a {finalCave}!",
"Entrance successfully moved from {initialCave} to {finalCave}!": "¡Entrada movida con éxito de {initialCave} a {finalCave}!",
"Entrance successfully updated!": "¡Entrada actualizada con éxito!",
"entrances": "entradas",
"Entrances": "Entradas",
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app/public/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@
"Entrance name language": "Langue du nom de l'entrée",
"Entrance properties": "Propriétés de l'entrée",
"Entrance successfully created!": "Entrée créée avec succès !",
"Entrance successfully moved from {intialCave} to {finalCave}!": "Entrée déplacée avec succès depuis {initialCave} vers {finalCave} !",
"Entrance successfully moved from {initialCave} to {finalCave}!": "Entrée déplacée avec succès depuis {initialCave} vers {finalCave} !",
"Entrance successfully updated!": "Entrée mise à jour avec succès !",
"entrances": "entrées",
"Entrances": "Entrées",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export const EntranceForm = ({ caveValues = null, entranceValues = null }) => {
const dispatch = useDispatch();
const entityTypeInitialValue = useMemo(
() =>
caveValues?.entrances.length > 1 ? ENTRANCE_ONLY : ENTRANCE_AND_CAVE,
[caveValues?.entrances.length]
caveValues?.entrances?.length > 1 ? ENTRANCE_ONLY : ENTRANCE_AND_CAVE,
[caveValues?.entrances?.length]
);
const [entityType, setEntityType] = useState(entityTypeInitialValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const SpacedButton = styled(Button)`

const FormActions = ({ apiError, entrance, loading, newCave, onReset }) => {
const { formatMessage } = useIntl();

const isSameCave = newCave && Number(newCave.id) === entrance.cave.id;
const isSameCave =
newCave && entrance.cave && Number(newCave.id) === entrance.cave.id;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const MoveEntranceToCaveForm = ({ entrance }) => {
const { loading, error: apiError } = useSelector(
state => state.moveEntranceToCave
);
const isLinkedToANetwork = entrance.cave.entrances.length > 1;
const isLinkedToANetwork = entrance.cave?.entrances?.length > 1;

const handleOnSelection = selectedCave => {
onNewCaveChange({ ...selectedCave, id: Number(selectedCave.id) });
Expand Down Expand Up @@ -77,12 +77,14 @@ const MoveEntranceToCaveForm = ({ entrance }) => {
<Alert
content={formatMessage(
{
id: 'Entrance successfully moved from {intialCave} to {finalCave}!',
id: 'Entrance successfully moved from {initialCave} to {finalCave}!',
defaultMessage:
'Entrance successfully moved from {intialCave} to {finalCave}!'
'Entrance successfully moved from {initialCave} to {finalCave}!'
},
{
intialCave: <b>{entrance.cave.name}</b>,
initialCave: (
<b>{entrance.cave?.name ?? formatMessage({ id: 'none' })}</b>
),
finalCave: <b>{newCave.name}</b>
}
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const OperationSummary = ({ entrance, isLinkedToANetwork, newCave }) => {
label={formatMessage({
id: isLinkedToANetwork ? 'Previous network' : 'Previous cave'
})}
url={`/ui/caves/${entrance.cave.id}`}
value={entrance.cave.name}
url={entrance.cave ? `/ui/caves/${entrance.cave?.id}` : null}
value={entrance.cave?.name ?? formatMessage({ id: 'none' })}
/>
</Box>
<Box mx={4}>
Expand Down
Loading