mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
refactor(web/dialog): use locale for alert confirm button
This commit is contained in:
@@ -13,11 +13,11 @@ import ReactMarkdown from "react-markdown";
|
|||||||
import { useNuiEvent } from "../../hooks/useNuiEvent";
|
import { useNuiEvent } from "../../hooks/useNuiEvent";
|
||||||
import { debugData } from "../../utils/debugData";
|
import { debugData } from "../../utils/debugData";
|
||||||
import { fetchNui } from "../../utils/fetchNui";
|
import { fetchNui } from "../../utils/fetchNui";
|
||||||
|
import { useLocales } from "../../providers/LocaleProvider";
|
||||||
|
|
||||||
interface DialogProps {
|
interface DialogProps {
|
||||||
header: string;
|
header: string;
|
||||||
content: string;
|
content: string;
|
||||||
button: string;
|
|
||||||
centered?: boolean;
|
centered?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,19 +27,18 @@ debugData<DialogProps>([
|
|||||||
data: {
|
data: {
|
||||||
header: "Hello there",
|
header: "Hello there",
|
||||||
content: "General kenobi \n Markdown works",
|
content: "General kenobi \n Markdown works",
|
||||||
button: "Ok",
|
|
||||||
centered: true,
|
centered: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const AlertDialog: React.FC = () => {
|
const AlertDialog: React.FC = () => {
|
||||||
|
const { locale } = useLocales();
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
const cancelRef = useRef(null);
|
const cancelRef = useRef(null);
|
||||||
const [dialogData, setDialogData] = useState<DialogProps>({
|
const [dialogData, setDialogData] = useState<DialogProps>({
|
||||||
header: "",
|
header: "",
|
||||||
content: "",
|
content: "",
|
||||||
button: "",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const closeAlert = () => {
|
const closeAlert = () => {
|
||||||
@@ -71,7 +70,7 @@ const AlertDialog: React.FC = () => {
|
|||||||
<ReactMarkdown>{dialogData.content}</ReactMarkdown>
|
<ReactMarkdown>{dialogData.content}</ReactMarkdown>
|
||||||
</AlertDialogBody>
|
</AlertDialogBody>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<Button onClick={closeAlert}>{dialogData.button}</Button>
|
<Button onClick={closeAlert}>{locale.ui.confirm}</Button>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
Reference in New Issue
Block a user