Skip to content

Commit

Permalink
Update - Localization
Browse files Browse the repository at this point in the history
- added DE to lang selector
- updated Prisma schema added DE to enum
  • Loading branch information
pdovhomilja committed Nov 25, 2023
1 parent 440e015 commit 48c45b0
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 29 deletions.
45 changes: 34 additions & 11 deletions components/SetLanguage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ import {
PopoverTrigger,
} from "@/components/ui/popover";
import { toast } from "@/components/ui/use-toast";
import { on } from "events";

import axios from "axios";
import { useRouter } from "next/navigation";
import { useState } from "react";
import LoadingModal from "./modals/loading-modal";

const languages = [
{ label: "English", value: "en" },
{ label: "Czech", value: "cz" },
{ label: "German", value: "de" },
] as const;

const FormSchema = z.object({
Expand All @@ -55,16 +58,36 @@ export function SetLanguage({ userId }: Props) {
resolver: zodResolver(FormSchema),
});

const [isLoading, setIsLoading] = useState(false);

async function onSubmit(data: z.infer<typeof FormSchema>) {
await axios.put(`/api/user/${userId}/set-language`, data);
toast({
title: "Success",
description:
"You change user language to:" +
data.language +
" but it's not working yet.",
});
router.refresh();
setIsLoading(true);
try {
await axios.put(`/api/user/${userId}/set-language`, data);
toast({
title: "Success",
description: "You change user language to: " + data.language,
});
} catch (e) {
console.log(e, "error");
toast({
title: "Error",
description: "Something went wrong.",
variant: "destructive",
});
} finally {
router.refresh();
setIsLoading(false);
}
}

if (isLoading) {
return (
<LoadingModal
isOpen={isLoading}
description="Changing NextCRM language"
/>
);
}

return (
Expand Down Expand Up @@ -100,7 +123,7 @@ export function SetLanguage({ userId }: Props) {
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0">
<Command>
<CommandInput placeholder="Search framework..." />
<CommandInput placeholder="Search language ..." />
<CommandEmpty>No framework found.</CommandEmpty>
<CommandGroup>
{languages.map((language) => (
Expand Down
4 changes: 2 additions & 2 deletions components/modals/loading-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { type } from "os";

type LoadingModalProps = {
isOpen: boolean;
title: string;
description: string;
title?: string;
description?: string;
};

const LoadingModal = ({ isOpen, title, description }: LoadingModalProps) => {
Expand Down
2 changes: 1 addition & 1 deletion locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Willkommen bei NextCRM CRM mit Prisma und Next.js 13"
},
"ModuleMenu": {
"dashboard": "Přehled",
"dashboard": "Dashboard",
"crm": {
"title": "Handel",
"accounts": "Firmen",
Expand Down
12 changes: 6 additions & 6 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "NextCRM is an open source CRM build on top of NextJS."
},
"ModuleMenu": {
"dashboard": "Přehled",
"dashboard": "Dashboard",
"crm": {
"title": "Sales",
"accounts": "Companies",
Expand All @@ -13,12 +13,12 @@
"leads": "Leads"
},
"projects": "Projects",
"tasks": "Úkoly",
"invoices": "Faktury",
"tasks": "Tasks",
"invoices": "Invoices",
"reports": "Reports",
"documents": "Dokumenty",
"storage": "Úložiště",
"settings": "Nastavení"
"documents": "Documents",
"storage": "Storage",
"settings": "Administration"
},
"DashboardPage": {
"containerTitle": "Dashboard",
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@types/nodemailer": "^6.4.8",
"@types/react-beautiful-dnd": "^13.1.4",
"cypress": "^13.1.0",
"prisma": "^5.5.2",
"prisma": "^5.6.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
}
Expand Down
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ model Users {
enum Language {
cz
en
de
}

model system_Modules_Enabled {
Expand Down

6 comments on commit 48c45b0

@vercel
Copy link

@vercel vercel bot commented on 48c45b0 Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 48c45b0 Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextcrm-demo – ./

nextcrm-demo-e-osvc.vercel.app
nextcrm-demo-git-main-e-osvc.vercel.app
demo.nextcrm.io

@vercel
Copy link

@vercel vercel bot commented on 48c45b0 Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 48c45b0 Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 48c45b0 Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextcrm-others – ./

nextcrm-others-e-osvc.vercel.app
nextcrm-others-git-main-e-osvc.vercel.app
others.nextcrm.io

@vercel
Copy link

@vercel vercel bot commented on 48c45b0 Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextcrm-test – ./

nextcrm-test-git-main-e-osvc.vercel.app
nextcrm-test-e-osvc.vercel.app
test.nextcrm.io

Please sign in to comment.