Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiya1155 committed Sep 12, 2023
1 parent 620527a commit dbcc0a3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
9 changes: 3 additions & 6 deletions client/src/components/StatusBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const StatusBar = () => {

const { setBugReportModalOpen } = useContext(UIContext.BugReport);
const { openLink, release } = useContext(DeviceContext);
const { requestsLeft, isSubscribed, hasCheckedQuota } = useContext(
const { quota, isSubscribed, hasCheckedQuota } = useContext(
PersonalQuotaContext.Values,
);
const { refetchQuota } = useContext(PersonalQuotaContext.Handlers);
Expand Down Expand Up @@ -107,11 +107,8 @@ const StatusBar = () => {
<div className="flex gap-1 items-center caption text-label-base">
<Info raw sizeClassName="w-3.5 h-3.5" />
<p className="pt-0.5">
{requestsLeft.allowed - requestsLeft.used}/
{requestsLeft.allowed}{' '}
<Trans count={requestsLeft.allowed - requestsLeft.used}>
uses left
</Trans>
{quota.allowed - quota.used}/{quota.allowed}{' '}
<Trans count={quota.allowed - quota.used}>uses left</Trans>
</p>
</div>
</Tooltip>
Expand Down
6 changes: 4 additions & 2 deletions client/src/context/personalQuotaContext.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createContext } from 'react';

type ContextType = {
requestsLeft: {
requestsLeft: number;
quota: {
used: number;
allowed: number;
};
Expand All @@ -11,7 +12,8 @@ type ContextType = {

export const PersonalQuotaContext = {
Values: createContext<ContextType>({
requestsLeft: {
requestsLeft: 10,
quota: {
used: 0,
allowed: 10,
},
Expand Down
9 changes: 6 additions & 3 deletions client/src/context/providers/PersonalQuotaContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ type Props = {};

export const PersonalQuotaContextProvider = memo(
({ children }: PropsWithChildren<Props>) => {
const [requestsLeft, setRequestsLeft] = useState({ used: 0, allowed: 10 });
const [quota, setQuota] = useState({ used: 0, allowed: 10 });
const [requestsLeft, setRequestsLeft] = useState(10);
const [isSubscribed, setIsSubscribed] = useState(false);
const [hasCheckedQuota, setHasCheckedQuota] = useState(false);

const refetchQuota = useCallback(() => {
getQuota().then((resp) => {
setIsSubscribed(resp.upgraded);
setRequestsLeft({ used: resp.used, allowed: resp.allowed });
setQuota({ used: resp.used, allowed: resp.allowed });
setRequestsLeft(Math.max(resp.allowed - resp.used, 0));
setHasCheckedQuota(true);
});
}, []);
Expand All @@ -32,10 +34,11 @@ export const PersonalQuotaContextProvider = memo(
const contextValue = useMemo(
() => ({
requestsLeft,
quota,
isSubscribed,
hasCheckedQuota,
}),
[requestsLeft, isSubscribed, hasCheckedQuota],
[requestsLeft, isSubscribed, hasCheckedQuota, quota],
);

const handlersContextValue = useMemo(
Expand Down
6 changes: 3 additions & 3 deletions client/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@
"Unavailable": "Indisponible",
"Token limit exceeded. Reduce the number of context files or messages to enable the ability to generate.": "Límite de token excedido. Reduzca la cantidad de archivos o mensajes de contexto para habilitar la capacidad de generar.",
"Invert": "Invertir",
"uses left_one": "Usos restantes",
"uses left_other": "uso restante",
"uses left_one": "usos restantes",
"uses left_other": "usos restante",
"Upgrade": "Actualizar",
"Your quota resets every 24 hours, upgrade for unlimited uses": "Tu cuota se restablece cada 24 horas, actualiza para solicitudes ilimitadas",
"Manage subscription": "Administrar suscripción"
}
}
4 changes: 2 additions & 2 deletions client/src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@
"Unavailable": "利用できません",
"Token limit exceeded. Reduce the number of context files or messages to enable the ability to generate.": "トークンの制限が超えました。 コンテキストファイルまたはメッセージの数を減らして、生成する機能を有効にします。",
"Invert": "反転",
"# requests left_one": "回数",
"# requests left_other": "回数",
"uses left_one": "回数",
"uses left_other": "回数",
"Upgrade": "アップグレード",
"Your quota resets every 24 hours, upgrade for unlimited uses": "あなたのクオータは24時間ごとにリセットされます、無制限のリクエストにアップグレードしてください",
"Manage subscription": "サブスクリプションを管理します"
Expand Down
7 changes: 4 additions & 3 deletions client/src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,10 @@
"Unavailable": "不可用",
"Token limit exceeded. Reduce the number of context files or messages to enable the ability to generate.": "令牌限制超过了。 减少上下文文件的数量或消息,以实现生成能力。",
"Invert": "倒置",
"# requests left_one": "次数",
"# requests left_other": "次数",
"uses left": "使用左侧",
"uses left_one": "使用左侧",
"uses left_other": "使用左侧",
"Upgrade": "升级",
"Your quota resets every 24 hours, upgrade for unlimited uses": "您的配额每24小时重置一次,升级以获得无限请求",
"Manage subscription": "管理订阅"
}
}

0 comments on commit dbcc0a3

Please sign in to comment.