Refactor translation and use only a parametric item

This commit is contained in:
Nicola Benaglia
2025-05-10 08:26:04 +02:00
parent 7cd3d10d67
commit 69b811b520
14 changed files with 84 additions and 36 deletions

View File

@@ -118,7 +118,8 @@ export const AddGroup = ({ address, open, setOpen }) => {
const fee = await getFee('CREATE_GROUP');
await show({
message: t('group:question.create_group', {
message: t('group:question.perform_transaction', {
action: 'CREATE_GROUP',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',

View File

@@ -113,7 +113,8 @@ export const AddGroupList = ({ setInfoSnack, setOpenSnack }) => {
const fee = await getFee('JOIN_GROUP');
await show({
message: t('group:question.join_group', {
message: t('group:question.perform_transaction', {
action: 'JOIN_GROUP',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',

View File

@@ -208,12 +208,6 @@ export const NewThread = ({
}
if (errorMsg) {
// dispatch(
// setNotification({
// msg: errorMsg,
// alertType: "error",
// })
// );
throw new Error(errorMsg);
}
@@ -221,13 +215,18 @@ export const NewThread = ({
if (!htmlContent?.trim() || htmlContent?.trim() === '<p></p>')
throw new Error('Please provide a first message to the thread');
const fee = await getFee('ARBITRARY');
let feeToShow = fee.fee;
if (!isMessage) {
feeToShow = +feeToShow * 2;
}
await show({
message: 'Would you like to perform a ARBITRARY transaction?',
message: t('group:question.perform_transaction', {
action: 'ARBITRARY',
postProcess: 'capitalize',
}),
publishFee: feeToShow + ' QORT',
});
@@ -516,7 +515,6 @@ export const NewThread = ({
overrideMobile
customEditorHeight="240px"
/>
</Box>
</InstanceListContainer>

View File

@@ -16,7 +16,8 @@ export const InviteMember = ({ groupId, setInfoSnack, setOpenSnack, show }) => {
try {
const fee = await getFee('GROUP_INVITE');
await show({
message: t('group:question.group_invite', {
message: t('group:question.perform_transaction', {
action: 'GROUP_INVITE',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',

View File

@@ -88,7 +88,10 @@ export const ListOfBans = ({ groupId, setInfoSnack, setOpenSnack, show }) => {
try {
const fee = await getFee('CANCEL_GROUP_BAN');
await show({
message: t('group:question.cancel_ban', { postProcess: 'capitalize' }),
message: t('group:question.perform_transaction', {
action: 'CANCEL_GROUP_BAN',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',
});
setIsLoadingUnban(true);

View File

@@ -51,6 +51,11 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
import { getFee } from '../../background';
import { useAtom, useSetAtom } from 'jotai';
import { useTranslation } from 'react-i18next';
const THIRTY_MINUTES = 30 * 60 * 1000; // 30 minutes in milliseconds
const uid = new ShortUniqueId({ length: 8 });
export const requestQueuePromos = new RequestQueueWithPromise(3);
export function utf8ToBase64(inputString: string): string {
@@ -65,13 +70,11 @@ export function utf8ToBase64(inputString: string): string {
return base64String;
}
const uid = new ShortUniqueId({ length: 8 });
export function getGroupId(str) {
const match = str.match(/group-(\d+)-/);
return match ? match[1] : null;
}
const THIRTY_MINUTES = 30 * 60 * 1000; // 30 minutes in milliseconds
export const ListOfGroupPromotions = () => {
const [popoverAnchor, setPopoverAnchor] = useState(null);
const [openPopoverIndex, setOpenPopoverIndex] = useState(null);
@@ -98,6 +101,7 @@ export const ListOfGroupPromotions = () => {
const setTxList = useSetAtom(txListAtom);
const theme = useTheme();
const { t } = useTranslation(['core', 'group']);
const listRef = useRef();
const rowVirtualizer = useVirtualizer({
count: promotions.length,
@@ -120,6 +124,7 @@ export const ListOfGroupPromotions = () => {
console.log(error);
}
}, []);
const getPromotions = useCallback(async () => {
try {
setPromotionTimeInterval(Date.now());
@@ -213,6 +218,7 @@ export const ListOfGroupPromotions = () => {
setPopoverAnchor(null);
setOpenPopoverIndex(null);
};
const publishPromo = async () => {
try {
setIsLoadingPublish(true);
@@ -264,7 +270,10 @@ export const ListOfGroupPromotions = () => {
const groupId = group.groupId;
const fee = await getFee('JOIN_GROUP');
await show({
message: 'Would you like to perform an JOIN_GROUP transaction?',
message: t('group:question.perform_transaction', {
action: 'JOIN_GROUP',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',
});
setIsLoadingJoinGroup(true);

View File

@@ -18,6 +18,7 @@ import { getNameInfo } from './Group';
import { getFee } from '../../background';
import { LoadingButton } from '@mui/lab';
import { getBaseApiReact } from '../../App';
import { useTranslation } from 'react-i18next';
export const getMemberInvites = async (groupNumber) => {
const response = await fetch(
@@ -59,7 +60,7 @@ export const ListOfInvites = ({
const [popoverAnchor, setPopoverAnchor] = useState(null); // Track which list item the popover is anchored to
const [openPopoverIndex, setOpenPopoverIndex] = useState(null); // Track which list item has the popover open
const [isLoadingCancelInvite, setIsLoadingCancelInvite] = useState(false);
const { t } = useTranslation(['core', 'group']);
const listRef = useRef();
const getInvites = async (groupId) => {
@@ -92,8 +93,12 @@ export const ListOfInvites = ({
try {
// TODO translate
const fee = await getFee('CANCEL_GROUP_INVITE');
await show({
message: 'Would you like to perform a CANCEL_GROUP_INVITE transaction?',
message: t('group:question.perform_transaction', {
action: 'CANCEL_GROUP_INVITE',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',
});
setIsLoadingCancelInvite(true);

View File

@@ -95,7 +95,10 @@ export const ListOfJoinRequests = ({
try {
const fee = await getFee('GROUP_INVITE'); // TODO translate
await show({
message: 'Would you like to perform a GROUP_INVITE transaction?',
message: t('group:question.perform_transaction', {
action: 'GROUP_INVITE',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',
});
setIsLoadingAccept(true);

View File

@@ -19,6 +19,7 @@ import {
import { LoadingButton } from '@mui/lab';
import { getFee } from '../../background';
import { getBaseApiReact } from '../../App';
import { useTranslation } from 'react-i18next';
const cache = new CellMeasurerCache({
fixedWidth: true,
@@ -41,6 +42,7 @@ const ListOfMembers = ({
const [isLoadingMakeAdmin, setIsLoadingMakeAdmin] = useState(false);
const [isLoadingRemoveAdmin, setIsLoadingRemoveAdmin] = useState(false);
const theme = useTheme();
const { t } = useTranslation(['core', 'group']);
const listRef = useRef();
const handlePopoverOpen = (event, index) => {
@@ -57,7 +59,10 @@ const ListOfMembers = ({
try {
const fee = await getFee('GROUP_KICK');
await show({
message: 'Would you like to perform a GROUP_KICK transaction?',
message: t('group:question.perform_transaction', {
action: 'GROUP_KICK',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',
});
@@ -106,7 +111,10 @@ const ListOfMembers = ({
try {
const fee = await getFee('GROUP_BAN'); // TODO translate
await show({
message: 'Would you like to perform a GROUP_BAN transaction?',
message: t('group:question.perform_transaction', {
action: 'GROUP_BAN',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',
});
setIsLoadingBan(true);
@@ -155,7 +163,10 @@ const ListOfMembers = ({
try {
const fee = await getFee('ADD_GROUP_ADMIN');
await show({
message: 'Would you like to perform a ADD_GROUP_ADMIN transaction?',
message: t('group:question.perform_transaction', {
action: 'ADD_GROUP_ADMIN',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',
});
setIsLoadingMakeAdmin(true);
@@ -203,7 +214,10 @@ const ListOfMembers = ({
try {
const fee = await getFee('REMOVE_GROUP_ADMIN');
await show({
message: 'Would you like to perform a REMOVE_GROUP_ADMIN transaction?',
message: t('group:question.perform_transaction', {
action: 'REMOVE_GROUP_ADMIN',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',
});
setIsLoadingRemoveAdmin(true);

View File

@@ -75,7 +75,10 @@ export const ManageMembers = ({
setIsLoadingLeave(true);
const fee = await getFee('LEAVE_GROUP'); // TODO translate
await show({
message: 'Would you like to perform an LEAVE_GROUP transaction?',
message: t('group:question.perform_transaction', {
action: 'LEAVE_GROUP',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',
});

View File

@@ -99,7 +99,8 @@ export const UserListOfInvites = ({
const fee = await getFee('JOIN_GROUP');
await show({
message: t('group:question.join_group', {
message: t('group:question.perform_transaction', {
action: 'JOIN_GROUP',
postProcess: 'capitalize',
}),
publishFee: fee.fee + ' QORT',