mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-07-23 04:36:52 +00:00
Add translations to appRating
This commit is contained in:
@@ -7,6 +7,7 @@ import { StarFilledIcon } from '../../assets/Icons/StarFilled';
|
||||
import { StarEmptyIcon } from '../../assets/Icons/StarEmpty';
|
||||
import { AppInfoUserName } from './Apps-styles';
|
||||
import { Spacer } from '../../common/Spacer';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const AppRating = ({ app, myName, ratingCountPosition = 'right' }) => {
|
||||
const [value, setValue] = useState(0);
|
||||
@@ -19,6 +20,7 @@ export const AppRating = ({ app, myName, ratingCountPosition = 'right' }) => {
|
||||
const [openSnack, setOpenSnack] = useState(false);
|
||||
const [infoSnack, setInfoSnack] = useState(null);
|
||||
const hasCalledRef = useRef(false);
|
||||
const { t } = useTranslation(['core', 'group']);
|
||||
|
||||
const getRating = useCallback(async (name, service) => {
|
||||
try {
|
||||
@@ -101,26 +103,39 @@ export const AppRating = ({ app, myName, ratingCountPosition = 'right' }) => {
|
||||
const rateFunc = async (event, chosenValue, currentValue) => {
|
||||
try {
|
||||
const newValue = chosenValue || currentValue;
|
||||
if (!myName) throw new Error('You need a name to rate.');
|
||||
if (!myName)
|
||||
throw new Error(
|
||||
t('core:message.generic.name_rate', {
|
||||
postProcess: 'capitalize',
|
||||
})
|
||||
);
|
||||
if (!app?.name) return;
|
||||
const fee = await getFee('CREATE_POLL');
|
||||
|
||||
await show({
|
||||
// TODO translate
|
||||
message: `Would you like to rate this app a rating of ${newValue}?. It will create a POLL tx.`,
|
||||
message: t('core:message.error.generic', {
|
||||
rate: newValue,
|
||||
postProcess: 'capitalize',
|
||||
}),
|
||||
publishFee: fee.fee + ' QORT',
|
||||
});
|
||||
|
||||
if (hasPublishedRating === false) {
|
||||
const pollName = `app-library-${app.service}-rating-${app.name}`;
|
||||
const pollOptions = [`1, 2, 3, 4, 5, initialValue-${newValue}`];
|
||||
const pollDescription = t('core:message.error.generic', {
|
||||
name: app.name,
|
||||
service: app.service,
|
||||
postProcess: 'capitalize',
|
||||
});
|
||||
|
||||
await new Promise((res, rej) => {
|
||||
window
|
||||
.sendMessage(
|
||||
'createPoll',
|
||||
{
|
||||
pollName: pollName,
|
||||
pollDescription: `Rating for ${app.service} ${app.name}`,
|
||||
pollDescription: pollDescription,
|
||||
pollOptions: pollOptions,
|
||||
pollOwnerAddress: myName,
|
||||
},
|
||||
@@ -137,7 +152,7 @@ export const AppRating = ({ app, myName, ratingCountPosition = 'right' }) => {
|
||||
message:
|
||||
'Successfully rated. Please wait a couple minutes for the network to propogate the changes.',
|
||||
});
|
||||
setOpenSnack(true);
|
||||
setOpenSnack(true); // TODO translate
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import React, { useContext, useState } from 'react';
|
||||
import { useContext, useState } from 'react';
|
||||
import { executeEvent } from '../../utils/events';
|
||||
import { getBaseApiReact, MyContext } from '../../App';
|
||||
import { createEndpoint } from '../../background';
|
||||
@@ -7,10 +7,9 @@ import {
|
||||
sortablePinnedAppsAtom,
|
||||
} from '../../atoms/global';
|
||||
import { saveToLocalStorage } from './AppsNavBarDesktop';
|
||||
import { base64ToBlobUrl } from '../../utils/fileReading';
|
||||
import { base64ToUint8Array } from '../../qdn/encryption/group-encryption';
|
||||
import { uint8ArrayToObject } from '../../backgroundFunctions/encryption';
|
||||
import { useAtom, useSetAtom } from 'jotai';
|
||||
import { useSetAtom } from 'jotai';
|
||||
|
||||
export const useHandlePrivateApps = () => {
|
||||
const [status, setStatus] = useState('');
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { useCallback, useContext, useEffect, useState } from 'react';
|
||||
import { executeEvent } from '../../utils/events';
|
||||
import { navigationControllerAtom } from '../../atoms/global';
|
||||
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { saveFile } from '../../qortalRequests/get';
|
||||
import { mimeToExtensionMap } from '../../utils/memeTypes';
|
||||
import { MyContext } from '../../App';
|
||||
|
@@ -111,7 +111,7 @@ export const GeneralNotifications = ({ address }) => {
|
||||
userSelect: 'none',
|
||||
}}
|
||||
>
|
||||
No new notifications
|
||||
{t('core:message.generic.no_notifications')}
|
||||
</Typography>
|
||||
)}
|
||||
{hasNewPayment && (
|
||||
|
@@ -233,7 +233,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
|
||||
{isDesktop ? (
|
||||
<IconWrapper
|
||||
disableWidth={disableWidth}
|
||||
label={t('core:save_options.save', {
|
||||
label={t('core:action.save', {
|
||||
postProcess: 'capitalize',
|
||||
})}
|
||||
selected={false}
|
||||
@@ -409,7 +409,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => {
|
||||
onClick={saveToQdn}
|
||||
variant="contained"
|
||||
>
|
||||
{t('core:save_options.save_qdn', {
|
||||
{t('core:action.save_qdn', {
|
||||
postProcess: 'capitalize',
|
||||
})}
|
||||
</LoadingButton>
|
||||
|
Reference in New Issue
Block a user