mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge latest changes from main and resolved conflicts
This commit is contained in:
commit
e9ad534e5a
@ -6,6 +6,7 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { HttpModule } from '@nestjs/axios';
|
||||
import { MiddlewareConsumer, Module, RequestMethod } from '@nestjs/common';
|
||||
import { InjectDynamicProviders } from 'nestjs-dynamic-providers';
|
||||
|
||||
@ -28,7 +29,7 @@ export interface ChannelModuleOptions {
|
||||
controllers: [WebhookController, ChannelController],
|
||||
providers: [ChannelService],
|
||||
exports: [ChannelService],
|
||||
imports: [NlpModule, ChatModule, AttachmentModule, CmsModule],
|
||||
imports: [NlpModule, ChatModule, AttachmentModule, CmsModule, HttpModule],
|
||||
})
|
||||
export class ChannelModule {
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
|
@ -43,7 +43,7 @@ export class LabelRepository extends BaseRepository<
|
||||
*/
|
||||
async postCreate(created: LabelDocument): Promise<void> {
|
||||
this.eventEmitter.emit(
|
||||
'hook:chatbot:label:create',
|
||||
'hook:label:create',
|
||||
created,
|
||||
async (result: Record<string, any>) => {
|
||||
await this.model.updateOne(
|
||||
@ -82,6 +82,6 @@ export class LabelRepository extends BaseRepository<
|
||||
const labels = await this.find(
|
||||
typeof _criteria === 'string' ? { _id: _criteria } : _criteria,
|
||||
);
|
||||
this.eventEmitter.emit('hook:chatbot:label:delete', labels);
|
||||
this.eventEmitter.emit('hook:label:delete', labels);
|
||||
}
|
||||
}
|
||||
|
@ -45,16 +45,16 @@ export class SubscriberRepository extends BaseRepository<
|
||||
/**
|
||||
* Emits events related to the creation of a new subscriber.
|
||||
*
|
||||
* @param _created - The newly created subscriber document.
|
||||
* @param created - The newly created subscriber document.
|
||||
*/
|
||||
async postCreate(_created: SubscriberDocument): Promise<void> {
|
||||
async postCreate(created: SubscriberDocument): Promise<void> {
|
||||
this.eventEmitter.emit(
|
||||
'hook:stats:entry',
|
||||
'new_users',
|
||||
'New users',
|
||||
_created,
|
||||
created,
|
||||
);
|
||||
this.eventEmitter.emit('hook:chatbot:subscriber:create', _created);
|
||||
this.eventEmitter.emit('hook:subscriber:create', created);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +81,7 @@ export class SubscriberRepository extends BaseRepository<
|
||||
const subscriberUpdates: SubscriberUpdateDto = updates?.['$set'];
|
||||
|
||||
this.eventEmitter.emit(
|
||||
'hook:chatbot:subscriber:update:before',
|
||||
'hook:subscriber:update:before',
|
||||
criteria,
|
||||
subscriberUpdates,
|
||||
);
|
||||
@ -122,7 +122,7 @@ export class SubscriberRepository extends BaseRepository<
|
||||
>,
|
||||
updated: Subscriber,
|
||||
) {
|
||||
this.eventEmitter.emit('hook:chatbot:subscriber:update:after', updated);
|
||||
this.eventEmitter.emit('hook:subscriber:update:after', updated);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,7 +110,7 @@ export class SubscriberStub extends BaseSchema {
|
||||
|
||||
@Prop({
|
||||
type: Object,
|
||||
default: { vars: {} }, //TODO: add this to the migration
|
||||
default: { vars: {} },
|
||||
})
|
||||
context?: SubscriberContext;
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
export interface SubscriberContext {
|
||||
[key: string]: any;
|
||||
vars?: { [key: string]: any };
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ export class BlockService extends BaseService<Block, BlockPopulate, BlockFull> {
|
||||
subscriberContext: SubscriberContext,
|
||||
settings: Settings,
|
||||
): string {
|
||||
const vars = { ...subscriberContext.vars, ...context.vars };
|
||||
const vars = { ...(subscriberContext?.vars || {}), ...context.vars };
|
||||
// Replace context tokens with their values
|
||||
Object.keys(vars).forEach((key) => {
|
||||
if (typeof vars[key] === 'string' && vars[key].indexOf(':') !== -1) {
|
||||
|
@ -287,7 +287,7 @@ export class ChatService {
|
||||
*
|
||||
* @param subscriber - The end user (subscriber)
|
||||
*/
|
||||
@OnEvent('hook:chatbot:subscriber:create')
|
||||
@OnEvent('hook:subscriber:create')
|
||||
onSubscriberCreate(subscriber: Subscriber) {
|
||||
this.websocketGateway.broadcastSubscriberNew(subscriber);
|
||||
}
|
||||
@ -297,7 +297,7 @@ export class ChatService {
|
||||
*
|
||||
* @param subscriber - The end user (subscriber)
|
||||
*/
|
||||
@OnEvent('hook:chatbot:subscriber:update:after')
|
||||
@OnEvent('hook:subscriber:update:after')
|
||||
onSubscriberUpdate(subscriber: Subscriber) {
|
||||
this.websocketGateway.broadcastSubscriberUpdate(subscriber);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { MenuStub, Menu } from '../menu.schema';
|
||||
import { Menu, MenuStub } from '../menu.schema';
|
||||
|
||||
export enum MenuType {
|
||||
web_url = 'web_url',
|
||||
|
@ -4,7 +4,6 @@
|
||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
* 3. SaaS Restriction: This software, or any derivative of it, may not be used to offer a competing product or service (SaaS) without prior written consent from Hexastack. Offering the software as a service or using it in a commercial cloud environment without express permission is strictly prohibited.
|
||||
*/
|
||||
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
|
@ -1,9 +1,14 @@
|
||||
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
||||
try {
|
||||
const url = new URL(relativePath, baseUrl);
|
||||
|
||||
return url.toString();
|
||||
return new URL(relativePath).toString();
|
||||
} catch {
|
||||
throw new Error(`Invalid base URL: ${baseUrl}`);
|
||||
try {
|
||||
return new URL(
|
||||
relativePath.replace(/^\//, ''),
|
||||
baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`,
|
||||
).toString();
|
||||
} catch {
|
||||
throw new Error(`Invalid base URL: ${baseUrl}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -60,6 +60,8 @@ services:
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- ${APP_WIDGET_PORT}:5173
|
||||
|
||||
volumes:
|
||||
mongo-data:
|
||||
|
7044
frontend/package-lock.json
generated
7044
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -9,11 +9,11 @@
|
||||
import { Button, Dialog, DialogActions, DialogContent } from "@mui/material";
|
||||
import { GridEventListener } from "@mui/x-data-grid";
|
||||
import { FC, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
import { MediaLibrary } from "@/components/media-library";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { IAttachment } from "@/types/attachment.types";
|
||||
|
||||
export type AttachmentDialogProps = DialogControlProps<
|
||||
@ -28,7 +28,7 @@ export const AttachmentDialog: FC<AttachmentDialogProps> = ({
|
||||
accept,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [selected, setSelected] = useState<IAttachment | null>(null);
|
||||
const handleSelection: GridEventListener<"rowClick"> = (data) => {
|
||||
setSelected(data.row);
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
import { Box, FormHelperText, FormLabel } from "@mui/material";
|
||||
import { forwardRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useGet } from "@/hooks/crud/useGet";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
@ -47,7 +46,6 @@ const AttachmentInput = forwardRef<HTMLDivElement, AttachmentThumbnailProps>(
|
||||
ref,
|
||||
) => {
|
||||
const hasPermission = useHasPermission();
|
||||
const { t } = useTranslation();
|
||||
const handleChange = (attachment: IAttachment | null) => {
|
||||
onChange && onChange(attachment?.id || null, attachment?.type || null);
|
||||
};
|
||||
@ -84,9 +82,7 @@ const AttachmentInput = forwardRef<HTMLDivElement, AttachmentThumbnailProps>(
|
||||
enableMediaLibrary={enableMediaLibrary}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
) : (
|
||||
t("message.no_attachment")
|
||||
)}
|
||||
) : null}
|
||||
{helperText ? (
|
||||
<FormHelperText error={error}>{helperText}</FormHelperText>
|
||||
) : null}
|
||||
|
@ -20,7 +20,6 @@ import {
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { FC } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useDelete } from "@/hooks/crud/useDelete";
|
||||
import { useGet } from "@/hooks/crud/useGet";
|
||||
@ -28,6 +27,7 @@ import { useDialog } from "@/hooks/useDialog";
|
||||
import useFormattedFileSize from "@/hooks/useFormattedFileSize";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { IAttachment } from "@/types/attachment.types";
|
||||
import { PermissionAction } from "@/types/permission.types";
|
||||
@ -84,7 +84,7 @@ const AttachmentThumbnail: FC<AttachmentThumbnailProps> = ({
|
||||
entity: EntityType.ATTACHMENT,
|
||||
});
|
||||
const { toast } = useToast();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const { mutateAsync: deleteAttachment } = useDelete(EntityType.ATTACHMENT, {
|
||||
onError: () => {
|
||||
|
@ -10,11 +10,11 @@ import CloudUploadIcon from "@mui/icons-material/CloudUpload";
|
||||
import FolderCopyIcon from "@mui/icons-material/FolderCopy";
|
||||
import { Box, Button, Divider, Grid, styled, Typography } from "@mui/material";
|
||||
import { ChangeEvent, DragEvent, FC, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useUpload } from "@/hooks/crud/useUpload";
|
||||
import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { IAttachment } from "@/types/attachment.types";
|
||||
|
||||
@ -76,7 +76,7 @@ const AttachmentUploader: FC<FileUploadProps> = ({
|
||||
const [attachment, setAttachment] = useState<IAttachment | undefined>(
|
||||
undefined,
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [isDragOver, setIsDragOver] = useState<boolean>(false);
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: uploadAttachment } = useUpload(EntityType.ATTACHMENT, {
|
||||
|
@ -14,11 +14,11 @@ import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useConfirmAccount, useLogin } from "@/hooks/entities/auth-hooks";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { useValidationRules } from "@/hooks/useValidationRules";
|
||||
import { ILoginAttributes } from "@/types/auth/login.types";
|
||||
|
||||
@ -33,7 +33,7 @@ const DEFAULT_VALUES: ILoginAttributes = {
|
||||
};
|
||||
|
||||
export const Login = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const router = useRouter();
|
||||
const { authenticate } = useAuth();
|
||||
@ -91,59 +91,57 @@ export const Login = () => {
|
||||
return (
|
||||
<Grid container justifyContent="center">
|
||||
<Paper sx={{ width: { xs: "100%", md: "33%" }, p: 2 }}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer gap={2}>
|
||||
<Typography variant="h1" fontSize="19px" fontWeight={700}>
|
||||
{t("title.login")}
|
||||
</Typography>
|
||||
<Input
|
||||
label={t("placeholder.email")}
|
||||
error={!!errors.identifier}
|
||||
required
|
||||
autoFocus
|
||||
InputProps={{
|
||||
startAdornment: <Adornment Icon={EmailIcon} />,
|
||||
}}
|
||||
helperText={
|
||||
errors.identifier ? errors.identifier.message : null
|
||||
}
|
||||
{...register("identifier", validationRules.email)}
|
||||
/>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer gap={2}>
|
||||
<Typography variant="h1" fontSize="19px" fontWeight={700}>
|
||||
{t("title.login")}
|
||||
</Typography>
|
||||
<Input
|
||||
label={t("placeholder.email")}
|
||||
error={!!errors.identifier}
|
||||
required
|
||||
autoFocus
|
||||
InputProps={{
|
||||
startAdornment: <Adornment Icon={EmailIcon} />,
|
||||
}}
|
||||
helperText={errors.identifier ? errors.identifier.message : null}
|
||||
{...register("identifier", validationRules.email)}
|
||||
/>
|
||||
|
||||
<PasswordInput
|
||||
label={t("placeholder.password")}
|
||||
error={!!errors.password}
|
||||
required
|
||||
InputProps={{
|
||||
startAdornment: <Adornment Icon={KeyIcon} />,
|
||||
}}
|
||||
helperText={errors.password ? errors.password.message : null}
|
||||
{...register("password", validationRules.password)}
|
||||
/>
|
||||
<Grid container gap={2} justifyContent="space-between">
|
||||
<Grid alignContent="center">
|
||||
<Link href="/reset">
|
||||
<Button variant="text" sx={{ textDecoration: "underline" }}>
|
||||
{t("link.reset")}
|
||||
</Button>
|
||||
</Link>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="contained"
|
||||
type="submit"
|
||||
endIcon={<KeyboardArrowRightIcon />}
|
||||
onClick={handleSubmit(onSubmitForm)}
|
||||
disabled={isLoading}
|
||||
>
|
||||
{t("button.login")}
|
||||
<PasswordInput
|
||||
label={t("placeholder.password")}
|
||||
error={!!errors.password}
|
||||
required
|
||||
InputProps={{
|
||||
startAdornment: <Adornment Icon={KeyIcon} />,
|
||||
}}
|
||||
helperText={errors.password ? errors.password.message : null}
|
||||
{...register("password", validationRules.password)}
|
||||
/>
|
||||
<Grid container gap={2} justifyContent="space-between">
|
||||
<Grid alignContent="center">
|
||||
<Link href="/reset">
|
||||
<Button variant="text" sx={{ textDecoration: "underline" }}>
|
||||
{t("link.reset")}
|
||||
</Button>
|
||||
</Grid>
|
||||
</Link>
|
||||
</Grid>
|
||||
</ContentContainer>
|
||||
</form>
|
||||
</Paper>
|
||||
<Grid>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="contained"
|
||||
type="submit"
|
||||
endIcon={<KeyboardArrowRightIcon />}
|
||||
onClick={handleSubmit(onSubmitForm)}
|
||||
disabled={isLoading}
|
||||
>
|
||||
{t("button.login")}
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ContentContainer>
|
||||
</form>
|
||||
</Paper>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
|
@ -22,10 +22,10 @@ import {
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useAcceptInvite } from "@/hooks/entities/auth-hooks";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { useValidationRules } from "@/hooks/useValidationRules";
|
||||
import { IRegisterAttributes } from "@/types/auth/register.types";
|
||||
import { JWT } from "@/utils/Jwt";
|
||||
@ -49,7 +49,7 @@ const DEFAULT_VALUES: IRegisterAttributes = {
|
||||
type TRegisterExtendedPayload = IRegisterAttributes & { password2: string };
|
||||
|
||||
export const Register = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const router = useRouter();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: acceptInvite, isLoading } = useAcceptInvite({
|
||||
|
@ -11,10 +11,10 @@ import { Button, Grid, Paper, Typography } from "@mui/material";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useResetPassword } from "@/hooks/entities/reset-hooks";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { useValidationRules } from "@/hooks/useValidationRules";
|
||||
|
||||
import { ContentContainer } from "../dialogs";
|
||||
@ -22,7 +22,7 @@ import { Adornment } from "../inputs/Adornment";
|
||||
import { PasswordInput } from "../inputs/PasswordInput";
|
||||
|
||||
export const ResetPassword = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const rules = useValidationRules();
|
||||
const validationRules = {
|
||||
|
@ -9,16 +9,16 @@
|
||||
import { Button, Grid, Paper, Typography } from "@mui/material";
|
||||
import Link from "next/link";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useRequestResetPassword } from "@/hooks/entities/reset-hooks";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
|
||||
import { ContentContainer } from "../dialogs";
|
||||
import { Input } from "../inputs/Input";
|
||||
|
||||
export const ResetPasswordRequest = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const {
|
||||
register,
|
||||
|
@ -9,7 +9,8 @@
|
||||
import CheckIcon from "@mui/icons-material/Check";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { Button } from "@mui/material";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
|
||||
interface DialogButtonsProps {
|
||||
closeDialog?: () => void;
|
||||
@ -20,7 +21,7 @@ const DialogButtons: React.FC<DialogButtonsProps> = ({
|
||||
closeDialog,
|
||||
handleSubmit,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -16,10 +16,10 @@ import {
|
||||
Button,
|
||||
} from "@mui/material";
|
||||
import { FC } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
import { DialogControl } from "@/hooks/useDialog";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
|
||||
export type DeleteDialogProps = DialogControl<string>;
|
||||
export const DeleteDialog: FC<DeleteDialogProps> = ({
|
||||
@ -27,7 +27,7 @@ export const DeleteDialog: FC<DeleteDialogProps> = ({
|
||||
callback,
|
||||
closeDialog: closeFunction,
|
||||
}: DeleteDialogProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
|
||||
return (
|
||||
<Dialog open={open} fullWidth onClose={closeFunction}>
|
||||
|
@ -8,13 +8,14 @@
|
||||
|
||||
import SearchIcon from "@mui/icons-material/Search";
|
||||
import { TextFieldProps } from "@mui/material";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
|
||||
import { Adornment } from "./Adornment";
|
||||
import { Input } from "./Input";
|
||||
|
||||
export const FilterTextfield = (props: TextFieldProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
|
||||
//TODO: replace the native delete text button by a styled custom button
|
||||
return (
|
||||
|
@ -24,7 +24,8 @@ import {
|
||||
useEffect,
|
||||
useState,
|
||||
} from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
|
||||
import { Input } from "./Input";
|
||||
|
||||
@ -54,7 +55,7 @@ const MultipleInput = forwardRef<HTMLDivElement, MultipleInputProps>(
|
||||
},
|
||||
ref,
|
||||
) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [inputs, setInputs] = useState<Array<{ id: number; value: string }>>(
|
||||
value
|
||||
? value.length >= minInput
|
||||
|
@ -26,8 +26,9 @@ import {
|
||||
import { OverridableComponent } from "@mui/material/OverridableComponent";
|
||||
import Link from "next/link";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { TTranslationKeys } from "@/i18n/i18n.types";
|
||||
import { theme } from "@/layout/themes/theme";
|
||||
import { SXStyleOptions } from "@/utils/SXStyleOptions";
|
||||
|
||||
@ -160,7 +161,7 @@ const VerticalMenuItem = ({
|
||||
isNested?: boolean;
|
||||
isToggled?: boolean;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const linkProps = {
|
||||
href,
|
||||
onClick,
|
||||
@ -173,7 +174,11 @@ const VerticalMenuItem = ({
|
||||
: theme.palette.text.secondary;
|
||||
|
||||
return (
|
||||
<Tooltip title={t(text)} disableHoverListener={isToggled} {...tooltip}>
|
||||
<Tooltip
|
||||
title={String(t(text as TTranslationKeys))}
|
||||
disableHoverListener={isToggled}
|
||||
{...tooltip}
|
||||
>
|
||||
<StyledListItemButton
|
||||
selected={!!(!(isToggled && !href && isSubmenuOpen) && isSelected)}
|
||||
{...linkProps}
|
||||
@ -196,7 +201,7 @@ const VerticalMenuItem = ({
|
||||
) : null}
|
||||
{isToggled ? (
|
||||
<StyledListItemText
|
||||
primary={t(text)}
|
||||
primary={String(t(text as TTranslationKeys))}
|
||||
isNested={isNested}
|
||||
isSelected={isSelected}
|
||||
/>
|
||||
@ -221,7 +226,7 @@ export const Sidebar = ({
|
||||
isToggled,
|
||||
toggleFunction,
|
||||
}: TSidebarProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [openItems, setOpenItems] = useState<string[]>([]);
|
||||
const toggleCollapse = (menuItem: string) => () => {
|
||||
if (isToggled || !openItems.includes(menuItem))
|
||||
@ -301,7 +306,9 @@ export const Sidebar = ({
|
||||
return (
|
||||
<StyledDivider key={`divider_${text}`}>
|
||||
{isToggled && text ? (
|
||||
<StyledListSubheader>{t(text)}</StyledListSubheader>
|
||||
<StyledListSubheader>
|
||||
{String(t(text as TTranslationKeys))}
|
||||
</StyledListSubheader>
|
||||
) : null}
|
||||
</StyledDivider>
|
||||
);
|
||||
|
@ -7,12 +7,13 @@
|
||||
*/
|
||||
|
||||
import { Grid, Typography } from "@mui/material";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
|
||||
import NoDataIcon from "../svg/NoDataIcon";
|
||||
|
||||
export const NoDataOverlay = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
|
||||
return (
|
||||
<Grid
|
||||
|
@ -23,25 +23,38 @@ import {
|
||||
GridTreeNodeWithRender,
|
||||
GridValidRowModel,
|
||||
} from "@mui/x-data-grid";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { TTranslationKeys } from "@/i18n/i18n.types";
|
||||
import { theme } from "@/layout/themes/theme";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { PermissionAction } from "@/types/permission.types";
|
||||
|
||||
export enum ActionColumnLabel {
|
||||
Edit = "button.edit",
|
||||
Delete = "button.delete",
|
||||
Values = "button.values",
|
||||
Manage_Roles = "button.manage_roles",
|
||||
Permissions = "button.permissions",
|
||||
Content = "button.content",
|
||||
Fields = "button.fields",
|
||||
Manage_Labels = "title.manage_labels",
|
||||
Toggle = "button.toggle",
|
||||
Edit = "Edit",
|
||||
Delete = "Delete",
|
||||
Values = "Values",
|
||||
Manage_Roles = "Manage_Roles",
|
||||
Permissions = "Permissions",
|
||||
Content = "Content",
|
||||
Fields = "Fields",
|
||||
Manage_Labels = "Manage_Labels",
|
||||
Toggle = "Toggle",
|
||||
}
|
||||
|
||||
const ACTION_COLUMN_LABEL_MAP: Record<ActionColumnLabel, TTranslationKeys> = {
|
||||
[ActionColumnLabel.Edit]: "button.edit",
|
||||
[ActionColumnLabel.Delete]: "button.delete",
|
||||
[ActionColumnLabel.Values]: "button.values",
|
||||
[ActionColumnLabel.Manage_Roles]: "button.manage_roles",
|
||||
[ActionColumnLabel.Permissions]: "button.permissions",
|
||||
[ActionColumnLabel.Content]: "button.content",
|
||||
[ActionColumnLabel.Fields]: "button.fields",
|
||||
[ActionColumnLabel.Manage_Labels]: "title.manage_labels",
|
||||
[ActionColumnLabel.Toggle]: "button.toggle",
|
||||
} as const;
|
||||
|
||||
export interface ActionColumn<T extends GridValidRowModel> {
|
||||
label: ActionColumnLabel;
|
||||
action?: (row: T) => void;
|
||||
@ -99,7 +112,7 @@ function StackComponent<T extends GridValidRowModel>({
|
||||
actions: ActionColumn<T>[];
|
||||
params: GridRenderCellParams<T, any, any, GridTreeNodeWithRender>;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
|
||||
return (
|
||||
<Stack height="100%" alignItems="center" direction="row" spacing={0.5}>
|
||||
@ -116,9 +129,13 @@ function StackComponent<T extends GridValidRowModel>({
|
||||
key={label}
|
||||
className="actionButton"
|
||||
icon={
|
||||
<Tooltip title={helperText || t(label)}>{getIcon(label)}</Tooltip>
|
||||
<Tooltip
|
||||
title={helperText || String(t(ACTION_COLUMN_LABEL_MAP[label]))}
|
||||
>
|
||||
{getIcon(label)}
|
||||
</Tooltip>
|
||||
}
|
||||
label={helperText || t(label)}
|
||||
label={helperText || t(ACTION_COLUMN_LABEL_MAP[label])}
|
||||
showInMenu={false}
|
||||
sx={{
|
||||
color:
|
||||
|
@ -25,13 +25,13 @@ import {
|
||||
styled,
|
||||
} from "@mui/material";
|
||||
import React, { FC, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { AnimatedChevron } from "@/app-components/icons/AnimatedChevron";
|
||||
import { UnifiedIcon } from "@/app-components/icons/UnifiedIcon";
|
||||
import { TMenuItem } from "@/app-components/menus/Sidebar";
|
||||
import { useGetFromCache } from "@/hooks/crud/useGet";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { theme } from "@/layout/themes/theme";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { IMenuNode } from "@/types/menu-tree.types";
|
||||
@ -103,7 +103,7 @@ const MenuItem: FC<MenuAccordionProps> = ({
|
||||
onUpdate,
|
||||
onDelete,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const hasPermission = useHasPermission();
|
||||
|
||||
return (
|
||||
|
@ -15,7 +15,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { useEffect, FC } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -23,6 +22,8 @@ import { ContentContainer } from "@/app-components/dialogs/layouts/ContentContai
|
||||
import { ContentItem } from "@/app-components/dialogs/layouts/ContentItem";
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import { ToggleableInput } from "@/app-components/inputs/ToggleableInput";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { TNestedTranslation } from "@/i18n/i18n.types";
|
||||
import { IMenuItem, IMenuItemAttributes, MenuType } from "@/types/menu.types";
|
||||
import { isAbsoluteUrl } from "@/utils/URL";
|
||||
|
||||
@ -45,7 +46,7 @@ export const MenuDialog: FC<MenuDialogProps> = ({
|
||||
parentId,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const {
|
||||
reset,
|
||||
resetField,
|
||||
@ -123,9 +124,11 @@ export const MenuDialog: FC<MenuDialogProps> = ({
|
||||
helperText={errors.type ? errors.type.message : null}
|
||||
{...rest}
|
||||
>
|
||||
{Object.keys(MenuType).map((value, key) => (
|
||||
{(
|
||||
Object.keys(MenuType) as TNestedTranslation<"label">[]
|
||||
).map((value, key) => (
|
||||
<MenuItem value={value} key={key}>
|
||||
{t(`label.${value}`)}
|
||||
{t("label", value)}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Input>
|
||||
|
@ -10,7 +10,6 @@ import { faBars } from "@fortawesome/free-solid-svg-icons";
|
||||
import AddIcon from "@mui/icons-material/Add";
|
||||
import { Grid, Paper, Button, Box, debounce } from "@mui/material";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs/DeleteDialog";
|
||||
import { NoDataOverlay } from "@/app-components/tables/NoDataOverlay";
|
||||
@ -19,6 +18,7 @@ import { useDelete } from "@/hooks/crud/useDelete";
|
||||
import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { IMenuItem } from "@/types/menu.types";
|
||||
@ -28,7 +28,7 @@ import MenuAccordion from "./MenuAccordion";
|
||||
import { MenuDialog } from "./MenuDialog";
|
||||
|
||||
export const Menu = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [addDialogOpened, setAddDialogOpened] = useState(false);
|
||||
const [editDialogOpened, setEditDialogOpened] = useState(false);
|
||||
const [selectedMenuId, setSelectedMenuId] = useState<string | undefined>(
|
||||
|
@ -9,7 +9,6 @@
|
||||
import { Dialog, DialogActions, DialogContent } from "@mui/material";
|
||||
import { FC, useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -20,6 +19,7 @@ import { useCreate } from "@/hooks/crud/useCreate";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { ICategory, ICategoryAttributes } from "@/types/category.types";
|
||||
|
||||
@ -31,7 +31,7 @@ export const CategoryDialog: FC<CategoryDialogProps> = ({
|
||||
closeDialog,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: createCategory } = useCreate(EntityType.CATEGORY, {
|
||||
onError: (error) => {
|
||||
|
@ -10,7 +10,6 @@ import AddIcon from "@mui/icons-material/Add";
|
||||
import FolderIcon from "@mui/icons-material/Folder";
|
||||
import { Button, Grid, Paper } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs/DeleteDialog";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -26,6 +25,7 @@ import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { PermissionAction } from "@/types/permission.types";
|
||||
@ -35,7 +35,7 @@ import { CategoryDialog } from "./CategoryDialog";
|
||||
import { ICategory } from "../../types/category.types";
|
||||
|
||||
export const Categories = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<ICategory>(false);
|
||||
const editDialogCtl = useDialog<ICategory>(false);
|
||||
|
@ -9,7 +9,6 @@
|
||||
import { Dialog, DialogActions, DialogContent } from "@mui/material";
|
||||
import { FC, useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -20,6 +19,7 @@ import { useCreate } from "@/hooks/crud/useCreate";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import {
|
||||
IContentType,
|
||||
@ -33,7 +33,7 @@ export const ContentTypeDialog: FC<ContentTypeDialogProps> = ({
|
||||
closeDialog,
|
||||
}) => {
|
||||
const { toast } = useToast();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const {
|
||||
handleSubmit,
|
||||
register,
|
||||
|
@ -17,7 +17,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { useEffect } from "react";
|
||||
import { useFieldArray, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import {
|
||||
@ -30,6 +29,7 @@ import { useGet } from "@/hooks/crud/useGet";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { ContentFieldType, IContentType } from "@/types/content-type.types";
|
||||
|
||||
@ -43,7 +43,7 @@ export const EditContentTypeFieldsDialog = ({
|
||||
closeDialog,
|
||||
open,
|
||||
}: EditContentTypeDialogFieldsProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { isLoading, data, refetch } = useGet(contentType?.id || "", {
|
||||
entity: EntityType.CONTENT_TYPE,
|
||||
});
|
||||
|
@ -16,10 +16,10 @@ import {
|
||||
UseFormSetValue,
|
||||
useWatch,
|
||||
} from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { IconButton } from "@/app-components/buttons/IconButton";
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { ContentFieldType, IContentType } from "@/types/content-type.types";
|
||||
import { slugify } from "@/utils/string";
|
||||
|
||||
@ -34,7 +34,7 @@ export const FieldInput = ({
|
||||
control: Control<Partial<IContentType>>;
|
||||
setValue: UseFormSetValue<Partial<IContentType>>;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const label = useWatch({
|
||||
control: props.control,
|
||||
name: `fields.${index}.label`,
|
||||
|
@ -10,7 +10,6 @@ import { faAlignLeft } from "@fortawesome/free-solid-svg-icons";
|
||||
import AddIcon from "@mui/icons-material/Add";
|
||||
import { Button, Grid, Paper } from "@mui/material";
|
||||
import { useRouter } from "next/router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -26,6 +25,7 @@ import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { IContentType } from "@/types/content-type.types";
|
||||
@ -36,7 +36,7 @@ import { ContentTypeDialog } from "./ContentTypeDialog";
|
||||
import { EditContentTypeFieldsDialog } from "./EditContentTypeFieldsDialog";
|
||||
|
||||
export const ContentTypes = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const router = useRouter();
|
||||
// Dialog Controls
|
||||
|
@ -23,7 +23,6 @@ import {
|
||||
FieldErrors,
|
||||
useForm,
|
||||
} from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import AttachmentInput from "@/app-components/attachment/AttachmentInput";
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
@ -36,6 +35,8 @@ import { useCreate } from "@/hooks/crud/useCreate";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { TNestedTranslation } from "@/i18n/i18n.types";
|
||||
import { EntityType } from "@/services/types";
|
||||
import {
|
||||
ContentField,
|
||||
@ -60,7 +61,7 @@ const ContentFieldInput: React.FC<ContentFieldInput> = ({
|
||||
field,
|
||||
errors,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
|
||||
switch (contentField.type) {
|
||||
case ContentFieldType.TEXT:
|
||||
@ -70,7 +71,7 @@ const ContentFieldInput: React.FC<ContentFieldInput> = ({
|
||||
<Input
|
||||
multiline={contentField.type === ContentFieldType.TEXTAREA}
|
||||
rows={contentField.type === ContentFieldType.TEXTAREA ? 5 : 1}
|
||||
label={t(`label.${contentField.name}`, {
|
||||
label={t("label", contentField.name as TNestedTranslation<"label">, {
|
||||
defaultValue: contentField.label,
|
||||
})}
|
||||
InputProps={
|
||||
@ -92,7 +93,7 @@ const ContentFieldInput: React.FC<ContentFieldInput> = ({
|
||||
case ContentFieldType.CHECKBOX:
|
||||
return (
|
||||
<FormControlLabel
|
||||
label={t(`label.${contentField.name}`, {
|
||||
label={t("label", contentField.name as TNestedTranslation<"label">, {
|
||||
defaultValue: contentField.label,
|
||||
})}
|
||||
{...field}
|
||||
@ -102,7 +103,7 @@ const ContentFieldInput: React.FC<ContentFieldInput> = ({
|
||||
case ContentFieldType.FILE:
|
||||
return (
|
||||
<AttachmentInput
|
||||
label={t(`label.${contentField.name}`, {
|
||||
label={t("label", contentField.name as TNestedTranslation<"label">, {
|
||||
defaultValue: contentField.label,
|
||||
})}
|
||||
{...field}
|
||||
@ -133,7 +134,7 @@ export const ContentDialog: FC<ContentDialogProps> = ({
|
||||
content: undefined,
|
||||
contentType: undefined,
|
||||
};
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const {
|
||||
reset,
|
||||
|
@ -12,7 +12,6 @@ import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
||||
import { Button, Chip, Grid, Paper, Switch, Typography } from "@mui/material";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -30,6 +29,7 @@ import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { IContentType } from "@/types/content-type.types";
|
||||
@ -40,7 +40,7 @@ import { getDateTimeFormatter } from "@/utils/date";
|
||||
import { ContentDialog } from "./ContentDialog";
|
||||
|
||||
export const Contents = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { query } = useRouter();
|
||||
// Dialog Controls
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { FC, useEffect } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -27,6 +26,7 @@ import { useCreate } from "@/hooks/crud/useCreate";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { IContextVar, IContextVarAttributes } from "@/types/context-var.types";
|
||||
import { slugify } from "@/utils/string";
|
||||
@ -38,7 +38,7 @@ export const ContextVarDialog: FC<ContextVarDialogProps> = ({
|
||||
closeDialog,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: createContextVar } = useCreate(EntityType.CONTEXT_VAR, {
|
||||
onError: (error) => {
|
||||
|
@ -11,7 +11,6 @@ import AddIcon from "@mui/icons-material/Add";
|
||||
import { Button, Grid, Paper, Switch } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs/DeleteDialog";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -28,6 +27,7 @@ import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { IContextVar } from "@/types/context-var.types";
|
||||
@ -37,7 +37,7 @@ import { getDateTimeFormatter } from "@/utils/date";
|
||||
import { ContextVarDialog } from "./ContextVarDialog";
|
||||
|
||||
export const ContextVars = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<IContextVar>(false);
|
||||
const editDialogCtl = useDialog<IContextVar>(false);
|
||||
|
@ -8,17 +8,17 @@
|
||||
|
||||
import { Card, CardContent, Divider } from "@mui/material";
|
||||
import { MultiLineChart, ResponsiveChartContainer } from "eazychart-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { StyledCardHeader } from "@/app-components/card/StyledCardHeader";
|
||||
import { useFindStats } from "@/hooks/entities/bot-stat-hooks";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { LineChartStats } from "@/types/bot-stat.types";
|
||||
import { buildMultiLineChartConfig, transformToLine } from "@/utils/chart";
|
||||
|
||||
import { NoDataChart } from "./NoDataChart";
|
||||
|
||||
const AudienceChart = () => {
|
||||
const { t, i18n } = useTranslation();
|
||||
const { t, i18n } = useTranslate();
|
||||
const { data: stats } = useFindStats<LineChartStats>("audiance");
|
||||
const { data, domainKeys } = transformToLine(stats);
|
||||
|
||||
|
@ -8,17 +8,17 @@
|
||||
|
||||
import { Card, CardContent, Divider } from "@mui/material";
|
||||
import { MultiLineChart, ResponsiveChartContainer } from "eazychart-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { StyledCardHeader } from "@/app-components/card/StyledCardHeader";
|
||||
import { useFindStats } from "@/hooks/entities/bot-stat-hooks";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { LineChartStats } from "@/types/bot-stat.types";
|
||||
import { buildMultiLineChartConfig, transformToLine } from "@/utils/chart";
|
||||
|
||||
import { NoDataChart } from "./NoDataChart";
|
||||
|
||||
const ConversationChart = () => {
|
||||
const { t, i18n } = useTranslation();
|
||||
const { t, i18n } = useTranslate();
|
||||
const { data: conversations } = useFindStats<LineChartStats>("conversation");
|
||||
const { data: conversationData, domainKeys: conversationDomains } =
|
||||
transformToLine(conversations);
|
||||
|
@ -8,17 +8,17 @@
|
||||
|
||||
import { Card, CardContent, Divider } from "@mui/material";
|
||||
import { MultiLineChart, ResponsiveChartContainer } from "eazychart-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { StyledCardHeader } from "@/app-components/card/StyledCardHeader";
|
||||
import { useFindStats } from "@/hooks/entities/bot-stat-hooks";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { LineChartStats } from "@/types/bot-stat.types";
|
||||
import { buildMultiLineChartConfig, transformToLine } from "@/utils/chart";
|
||||
|
||||
import { NoDataChart } from "./NoDataChart";
|
||||
|
||||
const MessageChart = () => {
|
||||
const { t, i18n } = useTranslation();
|
||||
const { t, i18n } = useTranslate();
|
||||
const { data: stats } = useFindStats<LineChartStats>("messages");
|
||||
const { data, domainKeys: domains } = transformToLine(stats);
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
import { faChartLine } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { styled, Typography } from "@mui/material";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { SXStyleOptions } from "@/utils/SXStyleOptions";
|
||||
|
||||
export const StyledMessage = styled(Typography)(
|
||||
@ -24,7 +24,7 @@ export const StyledMessage = styled(Typography)(
|
||||
);
|
||||
|
||||
export const NoDataChart = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
|
||||
return (
|
||||
<StyledMessage>
|
||||
|
@ -8,17 +8,17 @@
|
||||
|
||||
import { Card, CardContent, Divider } from "@mui/material";
|
||||
import { ColumnChart, ResponsiveChartContainer } from "eazychart-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { StyledCardHeader } from "@/app-components/card/StyledCardHeader";
|
||||
import { useFindStats } from "@/hooks/entities/bot-stat-hooks";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { ColumnChartStats } from "@/types/bot-stat.types";
|
||||
import { buildColumnChartConfig } from "@/utils/chart";
|
||||
|
||||
import { NoDataChart } from "./NoDataChart";
|
||||
|
||||
const PopularChart = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { data } = useFindStats<ColumnChartStats>("popularBlocks");
|
||||
|
||||
return (
|
||||
|
@ -9,8 +9,8 @@
|
||||
import Home from "@mui/icons-material/Home";
|
||||
import { Grid, GridProps } from "@mui/material";
|
||||
import { PropsWithChildren } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
|
||||
import AudienceChart from "./AudienceChart";
|
||||
@ -23,7 +23,7 @@ const DashboardContent = (props: PropsWithChildren<GridProps>) => (
|
||||
);
|
||||
|
||||
export const Dashboard = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
|
||||
return (
|
||||
<Grid container gap={3} flexDirection="column">
|
||||
|
@ -9,10 +9,10 @@
|
||||
import DownloadIcon from "@mui/icons-material/Download";
|
||||
import { Button, Dialog, DialogContent } from "@mui/material";
|
||||
import { FC } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DialogTitle } from "@/app-components/dialogs";
|
||||
import { useDialog } from "@/hooks/useDialog";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import {
|
||||
AttachmentAttrs,
|
||||
FileType,
|
||||
@ -68,7 +68,7 @@ const componentMap: { [key in FileType]: FC<AttachmentInterface> } = {
|
||||
return <audio controls src={props.url} />;
|
||||
},
|
||||
[FileType.file]: (props: AttachmentInterface) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
@ -16,11 +16,11 @@ import {
|
||||
} from "@chatscope/chat-ui-kit-react";
|
||||
import QuestionAnswerTwoToneIcon from "@mui/icons-material/QuestionAnswerTwoTone";
|
||||
import { debounce, Grid } from "@mui/material";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useCreate } from "@/hooks/crud/useCreate";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useConfig } from "@/hooks/useConfig";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
|
||||
import { ChatActions } from "./ChatActions";
|
||||
@ -35,7 +35,7 @@ import { useInfinitedLiveMessages } from "../hooks/useInfiniteLiveMessages";
|
||||
|
||||
export function Chat() {
|
||||
const { apiUrl } = useConfig();
|
||||
const { t, i18n } = useTranslation();
|
||||
const { t, i18n } = useTranslate();
|
||||
const { subscriber } = useChat();
|
||||
const { user } = useAuth();
|
||||
const { mutateAsync: createMessage } = useCreate(EntityType.MESSAGE);
|
||||
|
@ -10,7 +10,6 @@ import { Avatar } from "@chatscope/chat-ui-kit-react";
|
||||
import { faHandPointRight } from "@fortawesome/free-solid-svg-icons";
|
||||
import { Button, Grid, IconButton, MenuItem, Typography } from "@mui/material";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { UnifiedIcon } from "@/app-components/icons/UnifiedIcon";
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
@ -18,6 +17,7 @@ import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useConfig } from "@/hooks/useConfig";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
|
||||
import { getAvatarSrc } from "../helpers/mapMessages";
|
||||
@ -25,7 +25,7 @@ import { useChat } from "../hooks/ChatContext";
|
||||
|
||||
export const ChatActions = () => {
|
||||
const { apiUrl } = useConfig();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { subscriber: activeChat } = useChat();
|
||||
const [takeoverBy, setTakeoverBy] = useState<string>(
|
||||
activeChat?.assignedTo ?? "",
|
||||
|
@ -13,9 +13,9 @@ import {
|
||||
} from "@chatscope/chat-ui-kit-react";
|
||||
import InboxIcon from "@mui/icons-material/MoveToInbox";
|
||||
import { Chip, debounce, Grid } from "@mui/material";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useConfig } from "@/hooks/useConfig";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { Title } from "@/layout/content/Title";
|
||||
import { EntityType } from "@/services/types";
|
||||
|
||||
@ -30,7 +30,7 @@ export const SubscribersList = (props: {
|
||||
assignedTo: AssignedTo;
|
||||
}) => {
|
||||
const { apiUrl } = useConfig();
|
||||
const { t, i18n } = useTranslation();
|
||||
const { t, i18n } = useTranslate();
|
||||
const chat = useChat();
|
||||
const { fetchNextPage, isFetching, subscribers, hasNextPage } =
|
||||
useInfiniteLiveSubscribers(props);
|
||||
|
@ -10,11 +10,11 @@ import { MainContainer, Search, Sidebar } from "@chatscope/chat-ui-kit-react";
|
||||
import "@chatscope/chat-ui-kit-styles/dist/default/styles.min.css";
|
||||
import { Grid, MenuItem } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import AutoCompleteEntitySelect from "@/app-components/inputs/AutoCompleteEntitySelect";
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { IChannel } from "@/types/channel.types";
|
||||
import { ISubscriber } from "@/types/subscriber.types";
|
||||
@ -25,7 +25,7 @@ import { ChatProvider } from "./hooks/ChatContext";
|
||||
import { AssignedTo } from "./types";
|
||||
|
||||
export const Inbox = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { onSearch, searchPayload } = useSearch<ISubscriber>({
|
||||
$or: ["first_name", "last_name"],
|
||||
});
|
||||
|
@ -9,7 +9,6 @@
|
||||
import { Dialog, DialogActions, DialogContent } from "@mui/material";
|
||||
import { FC, useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -20,6 +19,7 @@ import { useCreate } from "@/hooks/crud/useCreate";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { ILabel, ILabelAttributes } from "@/types/label.types";
|
||||
import { slugify } from "@/utils/string";
|
||||
@ -31,7 +31,7 @@ export const LabelDialog: FC<LabelDialogProps> = ({
|
||||
closeDialog,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: createLabel } = useCreate(EntityType.LABEL, {
|
||||
onError: () => {
|
||||
|
@ -11,7 +11,6 @@ import AddIcon from "@mui/icons-material/Add";
|
||||
import { Button, Grid, Paper } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs/DeleteDialog";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -27,6 +26,7 @@ import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { ILabel } from "@/types/label.types";
|
||||
@ -36,7 +36,7 @@ import { getDateTimeFormatter } from "@/utils/date";
|
||||
import { LabelDialog } from "./LabelDialog";
|
||||
|
||||
export const Labels = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<ILabel>(false);
|
||||
const editDialogCtl = useDialog<ILabel>(false);
|
||||
|
@ -15,7 +15,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { FC, useEffect } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -26,6 +25,7 @@ import { useCreate } from "@/hooks/crud/useCreate";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { ILanguage, ILanguageAttributes } from "@/types/language.types";
|
||||
|
||||
@ -36,7 +36,7 @@ export const LanguageDialog: FC<LanguageDialogProps> = ({
|
||||
closeDialog,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: createLanguage } = useCreate(EntityType.LANGUAGE, {
|
||||
onError: () => {
|
||||
|
@ -10,7 +10,6 @@ import { Flag } from "@mui/icons-material";
|
||||
import AddIcon from "@mui/icons-material/Add";
|
||||
import { Button, Grid, Paper, Switch } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useQueryClient } from "react-query";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs/DeleteDialog";
|
||||
@ -29,6 +28,7 @@ import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { ILanguage } from "@/types/language.types";
|
||||
@ -38,7 +38,7 @@ import { getDateTimeFormatter } from "@/utils/date";
|
||||
import { LanguageDialog } from "./LanguageDialog";
|
||||
|
||||
export const Languages = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<ILanguage>(false);
|
||||
const editDialogCtl = useDialog<ILanguage>(false);
|
||||
|
@ -9,7 +9,6 @@
|
||||
import DriveFolderUploadIcon from "@mui/icons-material/DriveFolderUpload";
|
||||
import { Box, Grid, Paper } from "@mui/material";
|
||||
import { GridColDef, GridEventListener } from "@mui/x-data-grid";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import AttachmentThumbnail from "@/app-components/attachment/AttachmentThumbnail";
|
||||
import { DeleteDialog } from "@/app-components/dialogs/DeleteDialog";
|
||||
@ -26,6 +25,7 @@ import { useDialog } from "@/hooks/useDialog";
|
||||
import useFormattedFileSize from "@/hooks/useFormattedFileSize";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { PermissionAction } from "@/types/permission.types";
|
||||
@ -41,7 +41,7 @@ type MediaLibraryProps = {
|
||||
};
|
||||
|
||||
export const MediaLibrary = ({ onSelect, accept }: MediaLibraryProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const formatFileSize = useFormattedFileSize();
|
||||
|
@ -18,7 +18,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { FC, useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -29,6 +28,7 @@ import { useCreate } from "@/hooks/crud/useCreate";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import {
|
||||
INlpEntity,
|
||||
@ -43,7 +43,7 @@ export const NlpEntityDialog: FC<NlpEntityDialogProps> = ({
|
||||
data,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: createNlpEntity } = useCreate(EntityType.NLP_ENTITY, {
|
||||
onError: () => {
|
||||
|
@ -9,7 +9,6 @@
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { Button, Dialog, DialogActions, DialogContent } from "@mui/material";
|
||||
import { FC, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
|
||||
import AttachmentInput from "@/app-components/attachment/AttachmentInput";
|
||||
@ -20,6 +19,7 @@ import { isSameEntity } from "@/hooks/crud/helpers";
|
||||
import { useApiClient } from "@/hooks/useApiClient";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, QueryType } from "@/services/types";
|
||||
|
||||
export type NlpImportDialogProps = DialogControlProps<never>;
|
||||
@ -30,7 +30,7 @@ export const NlpImportDialog: FC<NlpImportDialogProps> = ({
|
||||
...rest
|
||||
}) => {
|
||||
const [attachmentId, setAttachementId] = useState<string | null>(null);
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const queryClient = useQueryClient();
|
||||
const { toast } = useToast();
|
||||
const { apiClient } = useApiClient();
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
import { Dialog, DialogContent } from "@mui/material";
|
||||
import { FC } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import {
|
||||
INlpDatasetSample,
|
||||
@ -30,7 +30,7 @@ export const NlpSampleDialog: FC<NlpSampleDialogProps> = ({
|
||||
closeDialog,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: updateSample } = useUpdate<
|
||||
EntityType.NLP_SAMPLE,
|
||||
|
@ -10,7 +10,6 @@ import { Dialog, DialogActions, DialogContent } from "@mui/material";
|
||||
import { useRouter } from "next/router";
|
||||
import { FC, useEffect } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -23,6 +22,7 @@ import { useGet } from "@/hooks/crud/useGet";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { INlpValue, INlpValueAttributes } from "@/types/nlp-value.types";
|
||||
|
||||
@ -41,7 +41,7 @@ export const NlpValueDialog: FC<NlpValueDialogProps> = ({
|
||||
canHaveSynonyms,
|
||||
callback,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { query } = useRouter();
|
||||
const { refetch: refetchEntity } = useGet(data?.entity || String(query.id), {
|
||||
|
@ -8,15 +8,15 @@
|
||||
|
||||
import { Box } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { StyledCardHeader } from "@/app-components/card/StyledCardHeader";
|
||||
import { useCount } from "@/hooks/crud/useCount";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { NlpSampleType } from "@/types/nlp-sample.types";
|
||||
|
||||
const NlpDatasetCounter: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const train = useCount(EntityType.NLP_SAMPLE, { type: NlpSampleType.train });
|
||||
const test = useCount(EntityType.NLP_SAMPLE, { type: NlpSampleType.test });
|
||||
const entity = useCount(EntityType.NLP_ENTITY, {});
|
||||
|
@ -10,7 +10,6 @@ import AddIcon from "@mui/icons-material/Add";
|
||||
import { Button, Chip, Grid } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import { useRouter } from "next/router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -26,6 +25,7 @@ import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { INlpEntity } from "@/types/nlp-entity.types";
|
||||
import { PermissionAction } from "@/types/permission.types";
|
||||
@ -48,7 +48,7 @@ const NlpEntity = () => {
|
||||
},
|
||||
});
|
||||
const addDialogCtl = useDialog<INlpEntity>(false);
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { onSearch, searchPayload } = useSearch<INlpEntity>({
|
||||
$or: ["name", "doc"],
|
||||
|
@ -22,7 +22,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs";
|
||||
import { ChipEntity } from "@/app-components/displays/ChipEntity";
|
||||
@ -43,6 +42,8 @@ import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { TNestedTranslation } from "@/i18n/i18n.types";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { ILanguage } from "@/types/language.types";
|
||||
import {
|
||||
@ -67,7 +68,7 @@ const NLP_SAMPLE_TYPE_COLORS = {
|
||||
export default function NlpSample() {
|
||||
const { apiUrl } = useConfig();
|
||||
const { toast } = useToast();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [type, setType] = useState<NlpSampleType | undefined>(undefined);
|
||||
const [language, setLanguage] = useState<string | undefined>(undefined);
|
||||
const hasPermission = useHasPermission();
|
||||
@ -296,7 +297,9 @@ export default function NlpSample() {
|
||||
</IconButton>
|
||||
),
|
||||
}),
|
||||
renderValue: (value) => <Box>{t(`label.${value}`)}</Box>,
|
||||
renderValue: (value) => (
|
||||
<Box>{t("label", value as TNestedTranslation<"label">)}</Box>
|
||||
),
|
||||
}}
|
||||
>
|
||||
{Object.values(NlpSampleType).map((nlpSampleType, index) => (
|
||||
|
@ -24,7 +24,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { FC, useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Controller, useFieldArray, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useQuery } from "react-query";
|
||||
|
||||
import { ContentContainer, ContentItem } from "@/app-components/dialogs";
|
||||
@ -34,6 +33,7 @@ import Selectable from "@/app-components/inputs/Selectable";
|
||||
import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useGetFromCache } from "@/hooks/crud/useGet";
|
||||
import { useApiClient } from "@/hooks/useApiClient";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { ILanguage } from "@/types/language.types";
|
||||
import { INlpEntity } from "@/types/nlp-entity.types";
|
||||
@ -55,7 +55,7 @@ const NlpDatasetSample: FC<NlpDatasetSampleProps> = ({
|
||||
sample,
|
||||
submitForm,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { data: entities, refetch: refetchEntities } = useFind(
|
||||
{
|
||||
entity: EntityType.NLP_ENTITY,
|
||||
@ -435,7 +435,7 @@ const NlpDatasetSample: FC<NlpDatasetSampleProps> = ({
|
||||
>
|
||||
{!selection?.value
|
||||
? t("button.select_some_text")
|
||||
: t("button.add_nlp_entity", { 0: selection.value })}
|
||||
: t("button.add_nlp_entity", { defaultValue: selection.value })}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
|
@ -13,7 +13,6 @@ import { Box, Button, Chip, Grid, Slide } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -30,6 +29,7 @@ import { useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { NlpLookups } from "@/types/nlp-entity.types";
|
||||
@ -46,7 +46,7 @@ export const NlpValues = ({ entityId }: { entityId: string }) => {
|
||||
const addNlpValueDialogCtl = useDialog<INlpValue>(false);
|
||||
const hasPermission = useHasPermission();
|
||||
const router = useRouter();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { data: nlpEntity, refetch: refetchEntity } = useGet(entityId, {
|
||||
entity: EntityType.NLP_ENTITY,
|
||||
|
@ -11,12 +11,12 @@ import { Grid, Paper, Tab, Tabs } from "@mui/material";
|
||||
import dynamic from "next/dynamic";
|
||||
import { useRouter } from "next/router";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { TabPanel } from "@/app-components/tabs/TabPanel";
|
||||
import { useCreate } from "@/hooks/crud/useCreate";
|
||||
import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import {
|
||||
@ -60,7 +60,7 @@ export const Nlp = ({
|
||||
},
|
||||
);
|
||||
};
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: createSample } = useCreate<
|
||||
EntityType.NLP_SAMPLE,
|
||||
|
@ -9,15 +9,15 @@
|
||||
import { faUser } from "@fortawesome/free-solid-svg-icons";
|
||||
import { Grid, Paper } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
|
||||
import { ProfileForm } from "./profile";
|
||||
|
||||
export const Profile = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { user } = useAuth();
|
||||
|
||||
return (
|
||||
|
@ -14,7 +14,6 @@ import LanguageIcon from "@mui/icons-material/Language";
|
||||
import { Box, Button, Grid, MenuItem, Typography } from "@mui/material";
|
||||
import { FC } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useQueryClient } from "react-query";
|
||||
|
||||
import AttachmentInput from "@/app-components/attachment/AttachmentInput";
|
||||
@ -26,6 +25,7 @@ import { PasswordInput } from "@/app-components/inputs/PasswordInput";
|
||||
import { useUpdateProfile } from "@/hooks/entities/auth-hooks";
|
||||
import { CURRENT_USER_KEY } from "@/hooks/useAuth";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { useValidationRules } from "@/hooks/useValidationRules";
|
||||
import { IUser, IUserAttributes } from "@/types/user.types";
|
||||
import { MIME_TYPES } from "@/utils/attachment";
|
||||
@ -35,7 +35,7 @@ type TUserProfileExtendedPayload = IUserAttributes & { password2: string };
|
||||
type ProfileFormProps = { user: IUser };
|
||||
|
||||
export const ProfileForm: FC<ProfileFormProps> = ({ user }) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const queryClient = useQueryClient();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: updateProfile, isLoading } = useUpdateProfile({
|
||||
|
@ -24,7 +24,6 @@ import {
|
||||
Divider,
|
||||
} from "@mui/material";
|
||||
import { useState, FC, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { IconButton } from "@/app-components/buttons/IconButton";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -35,6 +34,7 @@ import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useGetFromCache } from "@/hooks/crud/useGet";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { IPermission, IPermissionAttributes } from "@/types/permission.types";
|
||||
import { IRole } from "@/types/role.types";
|
||||
@ -70,7 +70,7 @@ export const PermissionsDialog: FC<PermissionsDialogProps> = ({
|
||||
data,
|
||||
closeDialog: closeFunction,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { data: models, refetch: modelRefetch } = useFind(
|
||||
{ entity: EntityType.MODEL, format: Format.FULL },
|
||||
|
@ -9,7 +9,6 @@
|
||||
import { Dialog, DialogActions, DialogContent } from "@mui/material";
|
||||
import { FC, useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -20,6 +19,7 @@ import { useCreate } from "@/hooks/crud/useCreate";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { IRole, IRoleAttributes } from "@/types/role.types";
|
||||
|
||||
@ -30,7 +30,7 @@ export const RoleDialog: FC<RoleDialogProps> = ({
|
||||
closeDialog,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: createRole } = useCreate(EntityType.ROLE, {
|
||||
onError: (error) => {
|
||||
|
@ -12,7 +12,6 @@ import AddIcon from "@mui/icons-material/Add";
|
||||
import { Button, Grid, Paper } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs/DeleteDialog";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -28,6 +27,7 @@ import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { PermissionAction } from "@/types/permission.types";
|
||||
@ -38,7 +38,7 @@ import { PermissionsDialog } from "./PermissionsDialog";
|
||||
import { RoleDialog } from "./RoleDialog";
|
||||
|
||||
export const Roles = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<IRole>(false);
|
||||
const editDialogCtl = useDialog<IRole>(false);
|
||||
|
@ -9,7 +9,6 @@
|
||||
import KeyIcon from "@mui/icons-material/Key";
|
||||
import { FormControlLabel, MenuItem, Switch } from "@mui/material";
|
||||
import { ControllerRenderProps } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import AttachmentInput from "@/app-components/attachment/AttachmentInput";
|
||||
import { Adornment } from "@/app-components/inputs/Adornment";
|
||||
@ -17,6 +16,8 @@ import AutoCompleteEntitySelect from "@/app-components/inputs/AutoCompleteEntity
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import MultipleInput from "@/app-components/inputs/MultipleInput";
|
||||
import { PasswordInput } from "@/app-components/inputs/PasswordInput";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { TNestedTranslation } from "@/i18n/i18n.types";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { IBlock } from "@/types/block.types";
|
||||
import { ISetting } from "@/types/setting.types";
|
||||
@ -33,13 +34,11 @@ const SettingInput: React.FC<RenderSettingInputProps> = ({
|
||||
field,
|
||||
isDisabled = () => false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const label = t(`label.${setting.label}`, {
|
||||
defaultValue: setting.title || setting.label,
|
||||
});
|
||||
const helperText = t(`help.${setting.label}`, {
|
||||
defaultValue: "",
|
||||
});
|
||||
const { t } = useTranslate();
|
||||
const nestedLabel = setting.label as TNestedTranslation<"label">;
|
||||
const nestedHelp = setting.label as TNestedTranslation<"help">;
|
||||
const label = t("label", nestedLabel);
|
||||
const helperText = t("help", nestedHelp);
|
||||
|
||||
switch (setting.type) {
|
||||
case "text":
|
||||
|
@ -18,12 +18,13 @@ import {
|
||||
} from "@mui/material";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { a11yProps, TabPanel } from "@/app-components/tabs/TabPanel";
|
||||
import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { TNestedTranslation } from "@/i18n/i18n.types";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { ISetting } from "@/types/setting.types";
|
||||
@ -67,7 +68,7 @@ function groupBy(array: ISetting[]) {
|
||||
}
|
||||
|
||||
export const Settings = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const [selectedTab, setSelectedTab] = useState("live-chat-tester");
|
||||
const { control, watch } = useForm();
|
||||
@ -156,14 +157,16 @@ export const Settings = () => {
|
||||
},
|
||||
}}
|
||||
>
|
||||
{Object.keys(groups).map((group, index) => (
|
||||
<StyledTab
|
||||
value={group}
|
||||
key={group}
|
||||
label={t(`title.${group}`)}
|
||||
{...a11yProps(index)}
|
||||
/>
|
||||
))}
|
||||
{(Object.keys(groups) as TNestedTranslation<"title">[]).map(
|
||||
(group, index) => (
|
||||
<StyledTab
|
||||
value={group}
|
||||
key={group}
|
||||
label={t("title", group)}
|
||||
{...a11yProps(index)}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
</Tabs>
|
||||
<StyledForm sx={{ width: "100%", px: 3, paddingY: 2 }}>
|
||||
{Object.entries(groups).map(([group, settings]) => (
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
import Link from "next/link";
|
||||
import { useEffect, FC, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -27,6 +26,7 @@ import { Input } from "@/app-components/inputs/Input";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { ILabel } from "@/types/label.types";
|
||||
import { ISubscriber, ISubscriberAttributes } from "@/types/subscriber.types";
|
||||
@ -43,7 +43,7 @@ export const EditSubscriberDialog: FC<EditSubscriberDialogProps> = ({
|
||||
closeDialog,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const [fullName, setFullName] = useState<string>("");
|
||||
const { mutateAsync: updateSubscriber } = useUpdate(EntityType.SUBSCRIBER, {
|
||||
|
@ -11,7 +11,6 @@ import DeleteIcon from "@mui/icons-material/Close";
|
||||
import { Grid, IconButton, MenuItem, Paper } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ChipEntity } from "@/app-components/displays/ChipEntity";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -26,6 +25,7 @@ import { DataGrid } from "@/app-components/tables/DataGrid";
|
||||
import { useFind } from "@/hooks/crud/useFind";
|
||||
import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { ILabel } from "@/types/label.types";
|
||||
@ -35,7 +35,7 @@ import { getDateTimeFormatter } from "@/utils/date";
|
||||
import { EditSubscriberDialog } from "./EditSubscriberDialog";
|
||||
|
||||
export const Subscribers = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const editDialogCtl = useDialog<{
|
||||
labels: ILabel[];
|
||||
subscriber: ISubscriber;
|
||||
|
@ -15,7 +15,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { FC, useEffect } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -25,6 +24,7 @@ import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import {
|
||||
ITranslation,
|
||||
@ -47,7 +47,7 @@ export const EditTranslationDialog: FC<EditTranslationDialogProps> = ({
|
||||
hasCount: false,
|
||||
},
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: updateTranslation } = useUpdate(EntityType.TRANSLATION, {
|
||||
onError: () => {
|
||||
|
@ -10,7 +10,6 @@ import { faLanguage } from "@fortawesome/free-solid-svg-icons";
|
||||
import AutorenewIcon from "@mui/icons-material/Autorenew";
|
||||
import { Button, Chip, Grid, Paper, Stack } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DeleteDialog } from "@/app-components/dialogs";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -25,6 +24,7 @@ import { useRefreshTranslations } from "@/hooks/entities/translation-hooks";
|
||||
import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { ILanguage } from "@/types/language.types";
|
||||
@ -35,7 +35,7 @@ import { getDateTimeFormatter } from "@/utils/date";
|
||||
import { EditTranslationDialog } from "./EditTranslationDialog";
|
||||
|
||||
export const Translations = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { data: languages } = useFind(
|
||||
{ entity: EntityType.LANGUAGE },
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
import Link from "next/link";
|
||||
import { FC, useEffect, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -27,6 +26,7 @@ import { Input } from "@/app-components/inputs/Input";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { IRole } from "@/types/role.types";
|
||||
import { IUser, IUserAttributes } from "@/types/user.types";
|
||||
@ -44,7 +44,7 @@ export const EditUserDialog: FC<EditUserDialogProps> = ({
|
||||
closeDialog,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const [fullName, setFullName] = useState<string>("");
|
||||
const { mutateAsync: updateUser } = useUpdate(EntityType.USER, {
|
||||
|
@ -11,7 +11,6 @@ import SendIcon from "@mui/icons-material/Send";
|
||||
import { Button, Dialog, DialogActions, DialogContent } from "@mui/material";
|
||||
import { FC, useEffect } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
import { ContentContainer } from "@/app-components/dialogs/layouts/ContentContainer";
|
||||
@ -21,6 +20,7 @@ import { Input } from "@/app-components/inputs/Input";
|
||||
import { useSendInvitation } from "@/hooks/entities/invitation-hooks";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { useValidationRules } from "@/hooks/useValidationRules";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { IInvitationAttributes } from "@/types/invitation.types";
|
||||
@ -34,7 +34,7 @@ export const InvitationDialog: FC<InvitationDialogProps> = ({
|
||||
closeDialog,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { mutateAsync: sendInvitation } = useSendInvitation({
|
||||
onSuccess: () => {
|
||||
|
@ -10,7 +10,6 @@ import { faUsers } from "@fortawesome/free-solid-svg-icons";
|
||||
import PersonAddAlt1Icon from "@mui/icons-material/PersonAddAlt1";
|
||||
import { Button, Grid, Paper, Switch } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ChipEntity } from "@/app-components/displays/ChipEntity";
|
||||
import { FilterTextfield } from "@/app-components/inputs/FilterTextfield";
|
||||
@ -29,6 +28,7 @@ import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { PageHeader } from "@/layout/content/PageHeader";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { PermissionAction } from "@/types/permission.types";
|
||||
@ -41,7 +41,7 @@ import { InvitationDialog } from "./InvitationDialog";
|
||||
|
||||
export const Users = () => {
|
||||
const { ssoEnabled } = useConfig();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const { user } = useAuth();
|
||||
const { mutateAsync: updateUser } = useUpdate(EntityType.USER, {
|
||||
|
@ -8,13 +8,13 @@
|
||||
|
||||
import { Grid, IconButton, Paper, Typography, styled } from "@mui/material";
|
||||
import { FC, SVGProps } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import AttachmentIcon from "@/app-components/svg/toolbar/AttachmentIcon";
|
||||
import ButtonsIcon from "@/app-components/svg/toolbar/ButtonsIcon";
|
||||
import ListIcon from "@/app-components/svg/toolbar/ListIcon";
|
||||
import QuickRepliesIcon from "@/app-components/svg/toolbar/QuickRepliesIcon";
|
||||
import SimpleTextIcon from "@/app-components/svg/toolbar/SimpleTextIcon";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { IBlockAttributes } from "@/types/block.types";
|
||||
import { SXStyleOptions } from "@/utils/SXStyleOptions";
|
||||
|
||||
@ -116,7 +116,7 @@ export const Block = ({
|
||||
};
|
||||
|
||||
const Aside = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
|
||||
return (
|
||||
<Grid
|
||||
|
@ -20,7 +20,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { FC, useEffect, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import DialogButtons from "@/app-components/buttons/DialogButtons";
|
||||
import { DialogTitle } from "@/app-components/dialogs/DialogTitle";
|
||||
@ -32,6 +31,7 @@ import { TabPanel } from "@/app-components/tabs/TabPanel";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { DialogControlProps } from "@/hooks/useDialog";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
import { OutgoingMessageFormat } from "@/types/message.types";
|
||||
|
||||
@ -49,7 +49,7 @@ const BlockDialog: FC<BlockDialogProps> = ({
|
||||
closeDialog,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [selectedTab, setSelectedTab] = useState("triggers");
|
||||
const handleChange = (_event: React.SyntheticEvent, newValue: string) => {
|
||||
setSelectedTab(newValue);
|
||||
|
@ -7,16 +7,16 @@
|
||||
*/
|
||||
|
||||
import { Grid } from "@mui/material";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import PluginIcon from "@/app-components/svg/toolbar/PluginIcon";
|
||||
import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType } from "@/services/types";
|
||||
|
||||
import { Block, StyledTitle } from "./Aside";
|
||||
|
||||
export const CustomBlocks = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { data: customBlocks } = useFind(
|
||||
{ entity: EntityType.CUSTOM_BLOCK },
|
||||
{ hasCount: false },
|
||||
|
@ -7,11 +7,11 @@
|
||||
*/
|
||||
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import AttachmentInput from "@/app-components/attachment/AttachmentInput";
|
||||
import { ContentItem } from "@/app-components/dialogs";
|
||||
import AttachmentIcon from "@/app-components/svg/toolbar/AttachmentIcon";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { IBlockAttributes } from "@/types/block.types";
|
||||
import { FileType } from "@/types/message.types";
|
||||
import { MIME_TYPES, getFileType } from "@/utils/attachment";
|
||||
@ -21,7 +21,7 @@ import { FormSectionTitle } from "./FormSectionTitle";
|
||||
|
||||
const AttachmentMessageForm = () => {
|
||||
const block = useBlock();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const {
|
||||
control,
|
||||
formState: { errors },
|
||||
|
@ -7,12 +7,12 @@
|
||||
*/
|
||||
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ContentItem } from "@/app-components/dialogs";
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import ButtonsIcon from "@/app-components/svg/toolbar/ButtonsIcon";
|
||||
import SimpleTextIcon from "@/app-components/svg/toolbar/SimpleTextIcon";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { IBlockAttributes } from "@/types/block.types";
|
||||
|
||||
import { useBlock } from "./BlockFormProvider";
|
||||
@ -21,7 +21,7 @@ import ButtonsInput from "./inputs/message/ButtonsInput";
|
||||
|
||||
const ButtonsMessageForm = () => {
|
||||
const block = useBlock();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const {
|
||||
control,
|
||||
formState: { errors },
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
RadioGroup,
|
||||
} from "@mui/material";
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ContentItem } from "@/app-components/dialogs";
|
||||
import AutoCompleteEntitySelect from "@/app-components/inputs/AutoCompleteEntitySelect";
|
||||
@ -25,6 +24,8 @@ import { Input } from "@/app-components/inputs/Input";
|
||||
import ButtonsIcon from "@/app-components/svg/toolbar/ButtonsIcon";
|
||||
import ListIcon from "@/app-components/svg/toolbar/ListIcon";
|
||||
import { useGet } from "@/hooks/crud/useGet";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { TNestedTranslation } from "@/i18n/i18n.types";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import {
|
||||
ContentField,
|
||||
@ -39,7 +40,7 @@ import ButtonsInput from "./inputs/message/ButtonsInput";
|
||||
|
||||
const ListMessageForm = () => {
|
||||
const block = useBlock();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
@ -67,10 +68,12 @@ const ListMessageForm = () => {
|
||||
name="options.content.display_mode"
|
||||
render={({ field }) => (
|
||||
<RadioGroup row {...field}>
|
||||
{[
|
||||
OutgoingMessageFormat.list,
|
||||
OutgoingMessageFormat.carousel,
|
||||
].map((display) => (
|
||||
{(
|
||||
[
|
||||
OutgoingMessageFormat.list,
|
||||
OutgoingMessageFormat.carousel,
|
||||
] as TNestedTranslation<"label">[]
|
||||
).map((display) => (
|
||||
<FormControlLabel
|
||||
key={display}
|
||||
value={display}
|
||||
@ -80,7 +83,7 @@ const ListMessageForm = () => {
|
||||
{...register("options.content.display")}
|
||||
/>
|
||||
}
|
||||
label={t(`label.${display}`)}
|
||||
label={t("label", display)}
|
||||
/>
|
||||
))}
|
||||
</RadioGroup>
|
||||
@ -98,12 +101,12 @@ const ListMessageForm = () => {
|
||||
name="options.content.top_element_style"
|
||||
render={({ field }) => (
|
||||
<RadioGroup row {...field}>
|
||||
{["large", "compact"].map((style) => (
|
||||
{(["large", "compact"] as const).map((style) => (
|
||||
<FormControlLabel
|
||||
key={style}
|
||||
value={style}
|
||||
control={<Radio />}
|
||||
label={t(`label.${style}`)}
|
||||
label={t("label", style)}
|
||||
/>
|
||||
))}
|
||||
</RadioGroup>
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
import { Typography } from "@mui/material";
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ContentContainer } from "@/app-components/dialogs/layouts/ContentContainer";
|
||||
import { ContentItem } from "@/app-components/dialogs/layouts/ContentItem";
|
||||
import AutoCompleteEntitySelect from "@/app-components/inputs/AutoCompleteEntitySelect";
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { IBlockAttributes, ICustomBlockTemplate } from "@/types/block.types";
|
||||
import { ILabelFull } from "@/types/label.types";
|
||||
@ -24,7 +24,7 @@ import ContextVarsInput from "./inputs/options/ContextVarsInput";
|
||||
import LocalFallbackInput from "./inputs/options/LocalFallbackInput";
|
||||
|
||||
export const OptionsForm = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const block = useBlock();
|
||||
const { control, register, watch } = useFormContext<IBlockAttributes>();
|
||||
const computed = watch("options.typing");
|
||||
|
@ -7,12 +7,12 @@
|
||||
*/
|
||||
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ContentItem } from "@/app-components/dialogs";
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import QuickRepliesIcon from "@/app-components/svg/toolbar/QuickRepliesIcon";
|
||||
import SimpleTextIcon from "@/app-components/svg/toolbar/SimpleTextIcon";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { IBlockAttributes } from "@/types/block.types";
|
||||
|
||||
import { useBlock } from "./BlockFormProvider";
|
||||
@ -21,7 +21,7 @@ import QuickRepliesInput from "./inputs/message/QuickRepliesInput";
|
||||
|
||||
const QuickRepliesMessageForm = () => {
|
||||
const block = useBlock();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
|
@ -7,11 +7,11 @@
|
||||
*/
|
||||
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ContentItem } from "@/app-components/dialogs";
|
||||
import MultipleInput from "@/app-components/inputs/MultipleInput";
|
||||
import SimpleTextIcon from "@/app-components/svg/toolbar/SimpleTextIcon";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { IBlockAttributes } from "@/types/block.types";
|
||||
|
||||
import { useBlock } from "./BlockFormProvider";
|
||||
@ -20,7 +20,7 @@ import ReplacementTokens from "./inputs/ReplacementTokens";
|
||||
|
||||
const TextMessageForm = () => {
|
||||
const block = useBlock();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
|
@ -8,11 +8,11 @@
|
||||
|
||||
import { Divider } from "@mui/material";
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ContentContainer } from "@/app-components/dialogs/layouts/ContentContainer";
|
||||
import { ContentItem } from "@/app-components/dialogs/layouts/ContentItem";
|
||||
import AutoCompleteEntitySelect from "@/app-components/inputs/AutoCompleteEntitySelect";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { IBlockAttributes } from "@/types/block.types";
|
||||
import { IChannel } from "@/types/channel.types";
|
||||
@ -23,7 +23,7 @@ import PatternsInput from "./inputs/triggers/PatternsInput";
|
||||
|
||||
export const TriggersForm = () => {
|
||||
const block = useBlock();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const { control } = useFormContext<IBlockAttributes>();
|
||||
|
||||
return (
|
||||
|
@ -16,13 +16,14 @@ import {
|
||||
ListItemText,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { TNestedTranslation } from "@/i18n/i18n.types";
|
||||
import { EntityType } from "@/services/types";
|
||||
|
||||
function ReplacementTokens() {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const userInfos = [
|
||||
{ name: "first_name", label: t("label.user_first_name") },
|
||||
{ name: "last_name", label: t("label.user_last_name") },
|
||||
@ -99,7 +100,7 @@ function ReplacementTokens() {
|
||||
<ListItem key={index}>
|
||||
<ListItemText
|
||||
primary={`{contact.${v.label}}`}
|
||||
secondary={t("label." + v.label)}
|
||||
secondary={t("label", v.label as TNestedTranslation<"label">)}
|
||||
/>
|
||||
</ListItem>
|
||||
))}
|
||||
|
@ -9,10 +9,10 @@
|
||||
import { Grid, MenuItem } from "@mui/material";
|
||||
import { FC } from "react";
|
||||
import { FieldPath, useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import { ToggleableInput } from "@/app-components/inputs/ToggleableInput";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { useValidationRules } from "@/hooks/useValidationRules";
|
||||
import { IBlockAttributes } from "@/types/block.types";
|
||||
import {
|
||||
@ -44,7 +44,7 @@ const ButtonInput: FC<ButtonInputProps> = ({
|
||||
disablePayload = false,
|
||||
fieldPath,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const types: { value: ButtonType; label: string }[] = [
|
||||
{ value: ButtonType.postback, label: t("label.postback") },
|
||||
{ value: ButtonType.web_url, label: t("label.web_url") },
|
||||
|
@ -11,8 +11,8 @@ import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import { Box, Button, Grid, IconButton } from "@mui/material";
|
||||
import { FC, Fragment, useEffect, useState } from "react";
|
||||
import { FieldPath } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { IBlockAttributes } from "@/types/block.types";
|
||||
import { AnyButton, ButtonType } from "@/types/message.types";
|
||||
import { ValueWithId, createValueWithId } from "@/utils/valueWithId";
|
||||
@ -36,7 +36,7 @@ const ButtonsInput: FC<ButtonsInput> = ({
|
||||
disablePayload = false,
|
||||
fieldPath,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [buttons, setButtons] = useState<ValueWithId<AnyButton>[]>(
|
||||
value.map((button) => createValueWithId(button)),
|
||||
);
|
||||
|
@ -10,8 +10,8 @@ import AddIcon from "@mui/icons-material/Add";
|
||||
import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import { Box, Button, Grid, IconButton } from "@mui/material";
|
||||
import { FC, Fragment, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { QuickReplyType, StdQuickReply } from "@/types/message.types";
|
||||
import { ValueWithId, createValueWithId } from "@/utils/valueWithId";
|
||||
|
||||
@ -28,7 +28,7 @@ const QuickRepliesInput: FC<QuickRepliesInput> = ({
|
||||
onChange,
|
||||
minInput = 1,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [quickReplies, setQuickReplies] = useState<
|
||||
ValueWithId<StdQuickReply>[]
|
||||
>(value.map((quickReplie) => createValueWithId(quickReplie)));
|
||||
|
@ -9,10 +9,10 @@
|
||||
import { Grid, MenuItem } from "@mui/material";
|
||||
import { FC, useState } from "react";
|
||||
import { useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import { ToggleableInput } from "@/app-components/inputs/ToggleableInput";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { IBlockAttributes } from "@/types/block.types";
|
||||
import { QuickReplyType, StdQuickReply } from "@/types/message.types";
|
||||
|
||||
@ -27,7 +27,7 @@ const QuickReplyInput: FC<QuickReplyInputProps> = ({
|
||||
onChange,
|
||||
idx,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [quickReplyType, setQuickReplyType] = useState(value.content_type);
|
||||
const {
|
||||
register,
|
||||
|
@ -10,11 +10,11 @@ import ArrowLeftOutlinedIcon from "@mui/icons-material/ArrowLeftOutlined";
|
||||
import { Grid } from "@mui/material";
|
||||
import { FC } from "react";
|
||||
import { useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import AutoCompleteEntitySelect from "@/app-components/inputs/AutoCompleteEntitySelect";
|
||||
import AutoCompleteSelect from "@/app-components/inputs/AutoCompleteSelect";
|
||||
import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { CaptureVar, IBlockAttributes, IBlockFull } from "@/types/block.types";
|
||||
import { IContextVar } from "@/types/context-var.types";
|
||||
@ -37,7 +37,7 @@ const ContextVarInput: FC<ContextVarInputProps> = ({
|
||||
value,
|
||||
onChange,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const {
|
||||
register,
|
||||
formState: { errors },
|
||||
|
@ -19,8 +19,8 @@ import {
|
||||
IconButton,
|
||||
} from "@mui/material";
|
||||
import { FC, Fragment, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { CaptureVar } from "@/types/block.types";
|
||||
import { ValueWithId, createValueWithId } from "@/utils/valueWithId";
|
||||
|
||||
@ -32,7 +32,7 @@ type ContextVarsInputProps = {
|
||||
};
|
||||
|
||||
const ContextVarsInput: FC<ContextVarsInputProps> = ({ value, onChange }) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const [vars, setVars] = useState<ValueWithId<CaptureVar>[]>(
|
||||
value.map((v) => createValueWithId(v)),
|
||||
);
|
||||
|
@ -11,11 +11,11 @@ import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||
import { Accordion, AccordionDetails, AccordionSummary } from "@mui/material";
|
||||
import { FC, useEffect, useState } from "react";
|
||||
import { useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ContentContainer, ContentItem } from "@/app-components/dialogs";
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import MultipleInput from "@/app-components/inputs/MultipleInput";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { BlockFallbackOptions, IBlockAttributes } from "@/types/block.types";
|
||||
|
||||
type LocalFallbackProps = {
|
||||
@ -31,7 +31,7 @@ const LocalFallbackInput: FC<LocalFallbackProps> = ({ value, onChange }) => {
|
||||
message: [""],
|
||||
},
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const {
|
||||
register,
|
||||
formState: { errors },
|
||||
|
@ -8,11 +8,11 @@
|
||||
|
||||
import { Box, Typography } from "@mui/material";
|
||||
import { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import AutoCompleteSelect from "@/app-components/inputs/AutoCompleteSelect";
|
||||
import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useGetFromCache } from "@/hooks/crud/useGet";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import { IBlock, PayloadPattern } from "@/types/block.types";
|
||||
|
||||
@ -32,7 +32,7 @@ export const ContentPostbackInput = ({
|
||||
value,
|
||||
onChange,
|
||||
}: ContentPostbackInputProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslate();
|
||||
const block = useBlock();
|
||||
const { data: contents } = useFind(
|
||||
{ entity: EntityType.CONTENT, format: Format.FULL },
|
||||
|
@ -6,15 +6,15 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { Box, Grid, MenuItem, Typography } from "@mui/material";
|
||||
import { Box, Grid, MenuItem, TextFieldProps, Typography } from "@mui/material";
|
||||
import { FC, useEffect, useState } from "react";
|
||||
import { RegisterOptions, useFormContext } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import AutoCompleteEntitySelect from "@/app-components/inputs/AutoCompleteEntitySelect";
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import { RegexInput } from "@/app-components/inputs/RegexInput";
|
||||
import { useGetFromCache } from "@/hooks/crud/useGet";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { EntityType, Format } from "@/services/types";
|
||||
import {
|
||||
IBlockAttributes,
|
||||
@ -57,10 +57,16 @@ type PatternInputProps = {
|
||||
onChange: (pattern: Pattern) => void;
|
||||
block?: IBlockFull;
|
||||
idx: number;
|
||||
getInputProps?: (index: number) => TextFieldProps;
|
||||
};
|
||||
|
||||
const PatternInput: FC<PatternInputProps> = ({ value, onChange, idx }) => {
|
||||
const { t } = useTranslation();
|
||||
const PatternInput: FC<PatternInputProps> = ({
|
||||
value,
|
||||
onChange,
|
||||
idx,
|
||||
getInputProps,
|
||||
}) => {
|
||||
const { t } = useTranslate();
|
||||
const {
|
||||
register,
|
||||
formState: { errors },
|
||||
@ -272,6 +278,7 @@ const PatternInput: FC<PatternInputProps> = ({ value, onChange, idx }) => {
|
||||
) : null}
|
||||
{typeof value === "string" && patternType === "text" ? (
|
||||
<Input
|
||||
{...(getInputProps ? getInputProps(idx) : null)}
|
||||
label={t("label.text")}
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user