mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
feat(web/alert): allow defining alert dialog button labels
This commit is contained in:
@@ -3,6 +3,10 @@ interface AlertDialogProps {
|
|||||||
content: string;
|
content: string;
|
||||||
centered?: boolean;
|
centered?: boolean;
|
||||||
cancel?: boolean;
|
cancel?: boolean;
|
||||||
|
labels?: {
|
||||||
|
cancel?: string;
|
||||||
|
confirm?: string;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
type alertDialog = (data: AlertDialogProps) => Promise<'cancel' | 'confirm'>;
|
type alertDialog = (data: AlertDialogProps) => Promise<'cancel' | 'confirm'>;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ local alert = nil
|
|||||||
---@field content string;
|
---@field content string;
|
||||||
---@field centered? boolean?;
|
---@field centered? boolean?;
|
||||||
---@field cancel? boolean?;
|
---@field cancel? boolean?;
|
||||||
|
---@field labels? {cancel?: string, confirm?: string}
|
||||||
|
|
||||||
---@param data AlertDialogProps
|
---@param data AlertDialogProps
|
||||||
---@return 'cancel' | 'confirm' | nil
|
---@return 'cancel' | 'confirm' | nil
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ export const debugAlert = () => {
|
|||||||
content: 'General kenobi \n Markdown works',
|
content: 'General kenobi \n Markdown works',
|
||||||
centered: true,
|
centered: true,
|
||||||
cancel: true,
|
cancel: true,
|
||||||
|
labels: {
|
||||||
|
confirm: 'Ok',
|
||||||
|
cancel: 'Not ok',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ export interface AlertProps {
|
|||||||
content: string;
|
content: string;
|
||||||
centered?: boolean;
|
centered?: boolean;
|
||||||
cancel?: boolean;
|
cancel?: boolean;
|
||||||
|
labels?: {
|
||||||
|
cancel?: string;
|
||||||
|
confirm?: string;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const AlertDialog: React.FC = () => {
|
const AlertDialog: React.FC = () => {
|
||||||
@@ -65,11 +69,11 @@ const AlertDialog: React.FC = () => {
|
|||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
{dialogData.cancel && (
|
{dialogData.cancel && (
|
||||||
<Button onClick={() => closeAlert('cancel')} mr={3}>
|
<Button onClick={() => closeAlert('cancel')} mr={3}>
|
||||||
{locale.ui.cancel}
|
{dialogData.labels?.cancel || locale.ui.cancel}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button colorScheme={dialogData.cancel ? 'blue' : undefined} onClick={() => closeAlert('confirm')}>
|
<Button colorScheme={dialogData.cancel ? 'blue' : undefined} onClick={() => closeAlert('confirm')}>
|
||||||
{locale.ui.confirm}
|
{dialogData.labels?.confirm || locale.ui.confirm}
|
||||||
</Button>
|
</Button>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user