diff --git a/src/app/(main)/invoice/new/page.tsx b/src/app/(main)/invoice/new/page.tsx
new file mode 100644
index 0000000..6ac8255
--- /dev/null
+++ b/src/app/(main)/invoice/new/page.tsx
@@ -0,0 +1,25 @@
+import { Metadata } from "next";
+import { getServerI18n } from "@/i18n";
+import Add from "@mui/icons-material/Add";
+import Button from "@mui/material/Button";
+import Stack from "@mui/material/Stack";
+import Typography from "@mui/material/Typography";
+import Link from "next/link";
+
+export const metadata: Metadata = {
+ title: "Create Invoice",
+};
+
+const Invoice: React.FC = async () => {
+ const { t } = await getServerI18n("Create Invoice");
+
+ return (
+ <>
+
+ {t("Create Invoice")}
+
+ >
+ )
+};
+
+export default Invoice;
\ No newline at end of file
diff --git a/src/app/(main)/invoice/page.tsx b/src/app/(main)/invoice/page.tsx
index ae9fc37..1806d2e 100644
--- a/src/app/(main)/invoice/page.tsx
+++ b/src/app/(main)/invoice/page.tsx
@@ -1,11 +1,40 @@
import { Metadata } from "next";
+import { getServerI18n } from "@/i18n";
+import Add from "@mui/icons-material/Add";
+import Button from "@mui/material/Button";
+import Stack from "@mui/material/Stack";
+import Typography from "@mui/material/Typography";
+import Link from "next/link";
export const metadata: Metadata = {
title: "Invoice",
};
const Invoice: React.FC = async () => {
- return "Invoice";
+ const { t } = await getServerI18n("Invoice");
+
+ return (
+ <>
+
+
+ {t("Invoice")}
+
+ }
+ LinkComponent={Link}
+ href="/invoice/new"
+ >
+ {t("Create Invoice")}
+
+
+ >
+ )
};
export default Invoice;
diff --git a/src/app/(main)/settings/company/create/page.tsx b/src/app/(main)/settings/company/create/page.tsx
index 1702f2d..e26aaf8 100644
--- a/src/app/(main)/settings/company/create/page.tsx
+++ b/src/app/(main)/settings/company/create/page.tsx
@@ -1,20 +1,22 @@
-import { fetchProjectCategories } from "@/app/api/projects";
-import { preloadStaff } from "@/app/api/staff";
-import { fetchAllTasks, fetchTaskTemplates } from "@/app/api/tasks";
-import CreateProject from "@/components/CreateProject";
+import CreateCompany from "@/components/CreateCompany";
import { I18nProvider, getServerI18n } from "@/i18n";
import Typography from "@mui/material/Typography";
import { Metadata } from "next";
export const metadata: Metadata = {
- title: "Create Project",
+ title: "Create Comapny",
};
const Companys: React.FC = async () => {
- const { t } = await getServerI18n("projects");
+ const { t } = await getServerI18n("companys");
return(
- <>AAAA>
+ <>
+ {t("Create Company")}
+
+
+
+ >
)
}
diff --git a/src/app/api/companys/actions.ts b/src/app/api/companys/actions.ts
index d78f9b6..b0e6db0 100644
--- a/src/app/api/companys/actions.ts
+++ b/src/app/api/companys/actions.ts
@@ -1,4 +1,5 @@
"use server";
+
import { serverFetchJson } from "@/app/utils/fetchUtil";
import { BASE_API_URL } from "@/config/api";
import { cache } from "react";
@@ -12,6 +13,30 @@ export interface combo {
records: comboProp[];
}
+export interface CreateCompanyInputs {
+ companyCode: String;
+ companyName: String;
+ brNo: String;
+ contactName: String;
+ phone: String;
+ otHourTo: String;
+ otHourFrom: String;
+ normalHourTo: String;
+ normalHourFrom: String;
+ currency: String;
+ address: String;
+ distract: String;
+ email: String;
+}
+
+export const saveCompany = async (data: CreateCompanyInputs) => {
+ return serverFetchJson(`${BASE_API_URL}/companys/new`, {
+ method: "POST",
+ body: JSON.stringify(data),
+ headers: { "Content-Type": "application/json" },
+ });
+};
+
export const fetchCompanyCombo = cache(async () => {
return serverFetchJson(`${BASE_API_URL}/companys/combo`, {
next: { tags: ["company"] },
diff --git a/src/components/CreateCompany/CompanyDetails.tsx b/src/components/CreateCompany/CompanyDetails.tsx
new file mode 100644
index 0000000..f3268c8
--- /dev/null
+++ b/src/components/CreateCompany/CompanyDetails.tsx
@@ -0,0 +1,110 @@
+"use client";
+
+import Stack from "@mui/material/Stack";
+import Box from "@mui/material/Box";
+import Card from "@mui/material/Card";
+import CardContent from "@mui/material/CardContent";
+import FormControl from "@mui/material/FormControl";
+import Grid from "@mui/material/Grid";
+import InputLabel from "@mui/material/InputLabel";
+import MenuItem from "@mui/material/MenuItem";
+import Select from "@mui/material/Select";
+import TextField from "@mui/material/TextField";
+import Typography from "@mui/material/Typography";
+import { useTranslation } from "react-i18next";
+import CardActions from "@mui/material/CardActions";
+import RestartAlt from "@mui/icons-material/RestartAlt";
+import Button from "@mui/material/Button";
+import { Controller, useFormContext } from "react-hook-form";
+import { CreateCompanyInputs } from "@/app/api/companys/actions";
+
+const CompanyDetails: React.FC = ({
+}) => {
+ const { t } = useTranslation();
+ const {
+ register,
+ formState: { errors },
+ control,
+ } = useFormContext();
+
+ return (
+
+
+
+
+ {t("Company Details")}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/*
+ }>
+ {t("Reset")}
+
+ */}
+
+
+ );
+};
+
+export default CompanyDetails;
\ No newline at end of file
diff --git a/src/components/CreateCompany/CreateCompany.tsx b/src/components/CreateCompany/CreateCompany.tsx
new file mode 100644
index 0000000..4394f51
--- /dev/null
+++ b/src/components/CreateCompany/CreateCompany.tsx
@@ -0,0 +1,101 @@
+"use client";
+
+import Check from "@mui/icons-material/Check";
+import Close from "@mui/icons-material/Close";
+import Button from "@mui/material/Button";
+import Stack from "@mui/material/Stack";
+import { CreateCompanyInputs, saveCompany } from "@/app/api/companys/actions";
+import { useRouter } from "next/navigation";
+import React, { useCallback, useState } from "react";
+import { useTranslation } from "react-i18next";
+import {
+ FieldErrors,
+ FormProvider,
+ SubmitErrorHandler,
+ SubmitHandler,
+ useForm,
+ } from "react-hook-form";
+import CompanyDetails from "./CompanyDetails";
+
+const CreateCompany: React.FC = ({
+
+}) => {
+ const [serverError, setServerError] = useState("");
+ const { t } = useTranslation();
+ const router = useRouter();
+
+ const handleCancel = () => {
+ router.back();
+ };
+
+ const onSubmit = useCallback>(
+ async (data) => {
+ try {
+ console.log(data);
+ setServerError("");
+ // console.log(JSON.stringify(data));
+ await saveCompany(data)
+ router.replace("/settings/companys");
+ } catch (e) {
+ setServerError(t("An error has occurred. Please try again later."));
+ }
+ },
+ [router, t],
+ );
+
+ const onSubmitError = useCallback>(
+ (errors) => {
+ console.log(errors)
+ },
+ [],
+ );
+
+ const formProps = useForm({
+ defaultValues: {
+ companyCode: "",
+ companyName: "",
+ brNo: "",
+ contactName: "",
+ phone: "",
+ otHourTo: "",
+ otHourFrom: "",
+ normalHourTo: "",
+ normalHourFrom: "",
+ currency: "",
+ address: "",
+ distract: "",
+ email: "",
+ },
+ });
+
+ const errors = formProps.formState.errors;
+
+ return(
+
+
+ {
+
+ }
+
+
+ }
+ onClick={handleCancel}
+ >
+ {t("Cancel")}
+
+ } type="submit">
+ {t("Confirm")}
+
+
+
+
+ )
+}
+
+export default CreateCompany;
\ No newline at end of file
diff --git a/src/components/CreateCompany/CreateCompanyWrapper.tsx b/src/components/CreateCompany/CreateCompanyWrapper.tsx
new file mode 100644
index 0000000..1becfc6
--- /dev/null
+++ b/src/components/CreateCompany/CreateCompanyWrapper.tsx
@@ -0,0 +1,10 @@
+import CreateCompany from "./CreateCompany";
+
+const CreateCompanyWrapper: React.FC = async () => {
+ return (
+
+ )
+}
+
+export default CreateCompanyWrapper;
\ No newline at end of file
diff --git a/src/components/CreateCompany/index.ts b/src/components/CreateCompany/index.ts
new file mode 100644
index 0000000..222e8c7
--- /dev/null
+++ b/src/components/CreateCompany/index.ts
@@ -0,0 +1 @@
+export { default } from "./CreateCompanyWrapper"
\ No newline at end of file