mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 17:01:14 +00:00
fix(web): display correct gender
This commit is contained in:
+6
-6
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>ESX MULTICHARACTER</title>
|
||||
<script type="module" crossorigin src="./assets/index-DejQJnIG.js"></script>
|
||||
<script type="module" crossorigin src="./assets/index-OCpTJ5nO.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-Kwy28xkx.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -1,48 +1,62 @@
|
||||
import CharacterSelection from './components/CharacterSelection';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useNuiEvent } from './utils/useNuiEvent'
|
||||
import { Character, Locale } from './types/Character';
|
||||
import { fetchNui } from './utils/fetchNui';
|
||||
import CharacterSelection from "./components/CharacterSelection";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useNuiEvent } from "./utils/useNuiEvent";
|
||||
import { Character, Locale } from "./types/Character";
|
||||
import { fetchNui } from "./utils/fetchNui";
|
||||
|
||||
function App() {
|
||||
const [isVisible, setIsVisible] = useState<boolean>(false);
|
||||
const [characters, setCharacters] = useState<Character[]>([]);
|
||||
const [Candelete, setCandelete] = useState<boolean>(false);
|
||||
const [MaxAllowedSlot, setMaxAllowedSlot] = useState<number>(0);
|
||||
const [locale, setLocale] = useState<Locale>({ char_info_title: '', play: '', title: '' });
|
||||
const [locale, setLocale] = useState<Locale>({
|
||||
char_info_title: "",
|
||||
play: "",
|
||||
title: "",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
fetchNui('nuiReady')
|
||||
}, [])
|
||||
fetchNui("nuiReady");
|
||||
}, []);
|
||||
|
||||
useNuiEvent('ToggleMulticharacter', (data:any) => {
|
||||
useNuiEvent("ToggleMulticharacter", (data: any) => {
|
||||
if (data.show) {
|
||||
const validCharacters = data.Characters.filter((char: any) => char !== null);
|
||||
const parsedCharacters: Character[] = validCharacters.map((char: any, index: number) => ({
|
||||
id: char.id.toString(),
|
||||
name: `${char.firstname} ${char.lastname}`,
|
||||
birthDate: char.dateofbirth,
|
||||
gender: char.sex?.toUpperCase() === 'MALE' ? 'MALE' : 'FEMALE',
|
||||
occupation: char.job,
|
||||
disabled: char.disabled,
|
||||
isActive: index === 0,
|
||||
}));
|
||||
const validCharacters = data.Characters.filter(
|
||||
(char: any) => char !== null
|
||||
);
|
||||
const parsedCharacters: Character[] = validCharacters.map(
|
||||
(char: any, index: number) => ({
|
||||
id: char.id.toString(),
|
||||
name: `${char.firstname} ${char.lastname}`,
|
||||
birthDate: char.dateofbirth,
|
||||
gender: char.sex,
|
||||
occupation: char.job,
|
||||
disabled: char.disabled,
|
||||
isActive: index === 0,
|
||||
})
|
||||
);
|
||||
|
||||
setIsVisible(true);
|
||||
setCharacters(parsedCharacters);
|
||||
setCandelete(data.CanDelete);
|
||||
setMaxAllowedSlot(data.AllowedSlot)
|
||||
setLocale(data.Locale)
|
||||
setMaxAllowedSlot(data.AllowedSlot);
|
||||
setLocale(data.Locale);
|
||||
} else {
|
||||
setIsVisible(false);
|
||||
setCharacters([]);
|
||||
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
return isVisible && (
|
||||
<CharacterSelection initialCharacters={characters} Candelete={Candelete} MaxAllowedSlot={MaxAllowedSlot} locale={locale} />
|
||||
return (
|
||||
isVisible && (
|
||||
<CharacterSelection
|
||||
initialCharacters={characters}
|
||||
Candelete={Candelete}
|
||||
MaxAllowedSlot={MaxAllowedSlot}
|
||||
locale={locale}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
export default App;
|
||||
|
||||
Reference in New Issue
Block a user