diff --git a/src/App/Container/Views/Private/VendorProfile/Component/General/Component/General.tsx b/src/App/Container/Views/Private/VendorProfile/Component/General/Component/General.tsx
index 3b5f13a..515f966 100644
--- a/src/App/Container/Views/Private/VendorProfile/Component/General/Component/General.tsx
+++ b/src/App/Container/Views/Private/VendorProfile/Component/General/Component/General.tsx
@@ -1,21 +1,92 @@
-import React from "react";
+import React, { useContext } from "react";
import Table from "./Table";
+import { Modal } from "../../../../../../Components";
+import { GeneralContext } from "../Controller";
+import { MainApp } from "../../../../../../Components";
+import ModalComponent from "./Modal";
const GeneralComponent = () => {
- return (
-
-
-
-
- Nama Perusahaan
-
- PINDAD JAYA
-
+ const { open, setOpen, _handleSubmit } = useContext(GeneralContext);
+
+ const ButtonMainApp = () => {
+ return (
+
+ {/*
+
+
+
+ Set Primary Data
+ */}
+
+ Selesai
+
+
setOpen(true)}
+ className="bg-greenpindad-100 hover:bg-green-700 text-white px-4 py-1 inline-flex items-center border border-gray-600"
+ >
+
+
+
+ Buat Entri Baru
+
+
+ );
+ };
+
+ return (
+
}>
+
+
+
+
+ Nama Perusahaan
+
+ PINDAD JAYA
+
+
+
{
+ setOpen(false);
+ }}
+ onActionOne={() => {
+ setOpen(false);
+ }}
+ onActionTwo={async () => _handleSubmit()}
+ textOne="Batal"
+ textTwo="Simpan"
+ >
+
+
-
+
);
};
diff --git a/src/App/Container/Views/Private/VendorProfile/Component/General/Component/Modal.tsx b/src/App/Container/Views/Private/VendorProfile/Component/General/Component/Modal.tsx
new file mode 100644
index 0000000..edb6faf
--- /dev/null
+++ b/src/App/Container/Views/Private/VendorProfile/Component/General/Component/Modal.tsx
@@ -0,0 +1,526 @@
+import React, { useContext } from "react";
+import { useFormContext } from "react-hook-form";
+import Select from "react-select";
+import { GeneralContext } from "../Controller";
+
+const ModalComponent = () => {
+ const {
+ customStyles,
+ setBranchName,
+ setAddress,
+ country,
+ setCountry,
+ province,
+ setProvince,
+ city,
+ setCity,
+ setDistrict,
+ setPostalCode,
+ setPhoneNumber,
+ setPhoneNumberExt,
+ setFaxNumber,
+ setFaxNumberExt,
+ setWebsite,
+ setCompanyEmail,
+ optionsCompanyType,
+ Indonesia,
+ Yogya,
+ Sleman,
+ register,
+ } = useContext(GeneralContext);
+ const { errors } = useFormContext();
+
+ return (
+
+
+
+ Use as Branch Office
+
+
+
+
+ );
+};
+
+export default ModalComponent;
diff --git a/src/App/Container/Views/Private/VendorProfile/Component/General/Component/Table.tsx b/src/App/Container/Views/Private/VendorProfile/Component/General/Component/Table.tsx
index fa1398c..74d0c84 100644
--- a/src/App/Container/Views/Private/VendorProfile/Component/General/Component/Table.tsx
+++ b/src/App/Container/Views/Private/VendorProfile/Component/General/Component/Table.tsx
@@ -1,7 +1,11 @@
-import React from "react";
+import React, { useContext } from "react";
import "../../../../../../Assets/Css/App.css";
+import { HomeContext } from "../../../Controller";
const Table = () => {
+ const { generalList } = useContext(HomeContext);
+ console.log("CEK", generalList);
+
return (
@@ -28,17 +32,22 @@ const Table = () => {
+ {/* {generalList &&
+ generalList.map((e: any, i: any) => (
+ */}
- 1.
+ {/* {i + 1} */}1
Nama Perusahaan
-
+
+ {/* {e.companyName} */}
+
Dipersiapkan
{
Kategori Lokasi
-
+
+ {/* {e.address} */}
+
Negara
-
+
+ {/* {e.county} */}
+
Provinsi
-
+
+ {/* {e.province} */}
+
Kota
-
+
+ {/* {e.city} */}
+
Kecamatan
-
+
+ {/* {e.district} */}
+
Kode Pos
-
+
+ {/* {e.postalCode} */}
+
alamat
-
+
+ {/* {e.address} */}
+
Nomor Telepon
-
+
+ {/* {e.phoneNumber} */}
+
@@ -116,13 +141,17 @@ const Table = () => {
Nomor Faksimile
-
+
+ {/* {e.faxNumber} */}
+
Situs
-
+
+ {/* {e.website} */}
+
@@ -130,7 +159,9 @@ const Table = () => {
E-mail Perusahaan
-
+
+ {/* {e.eMail} */}
+
diff --git a/src/App/Container/Views/Private/VendorProfile/Component/General/Controller.tsx b/src/App/Container/Views/Private/VendorProfile/Component/General/Controller.tsx
new file mode 100644
index 0000000..9e515a6
--- /dev/null
+++ b/src/App/Container/Views/Private/VendorProfile/Component/General/Controller.tsx
@@ -0,0 +1,319 @@
+import React, { createContext, useState, useEffect } from "react";
+import { useForm, FormContext } from "react-hook-form";
+import { getToken } from "../../../../../../Misc/Cookies";
+import { INSERT_VENDOR_CONTACT } from "./Query";
+import { useMutation } from "react-apollo";
+
+interface InitialState {
+ customStyles: object;
+ _isLogin: string | null;
+ open: boolean;
+ setOpen: Function;
+ optionsCompanyType: Array;
+ Indonesia: Array;
+ Yogya: Array;
+ Sleman: Array;
+ branchName: string;
+ address: string;
+ country: string;
+ province: string;
+ city: string;
+ district: string;
+ postalCode: string;
+ phoneNumber: string;
+ phoneNumberExt: string;
+ faxNumber: string;
+ faxNumberExt: string;
+ website: string;
+ companyEmail: string;
+ setBranchName: Function;
+ setAddress: Function;
+ setCountry: Function;
+ setProvince: Function;
+ setCity: Function;
+ setDistrict: Function;
+ setPostalCode: Function;
+ setPhoneNumber: Function;
+ setPhoneNumberExt: Function;
+ setFaxNumber: Function;
+ setFaxNumberExt: Function;
+ setCompanyEmail: Function;
+ setWebsite: Function;
+ _handleCountry: Function;
+ _handleProvince: Function;
+ _handleCity: Function;
+ _handleDistrict: Function;
+ _handleSubmit: Function;
+ register: Function;
+}
+
+const initialState = {
+ customStyles: {},
+ _isLogin: null,
+ open: false,
+ setOpen: () => {},
+ register: () => {},
+ optionsCompanyType: [{}],
+ Indonesia: [{}],
+ Yogya: [{}],
+ Sleman: [{}],
+ branchName: "",
+ setBranchName: () => {},
+ address: "",
+ setAddress: () => {},
+ country: "",
+ setCountry: () => {},
+ province: "",
+ setProvince: () => {},
+ city: "",
+ setCity: () => {},
+ district: "",
+ setDistrict: () => {},
+ postalCode: "",
+ setPostalCode: () => {},
+ phoneNumber: "",
+ setPhoneNumber: () => {},
+ phoneNumberExt: "",
+ setPhoneNumberExt: () => {},
+ faxNumber: "",
+ setFaxNumber: () => {},
+ faxNumberExt: "",
+ setFaxNumberExt: () => {},
+ companyEmail: "",
+ setCompanyEmail: () => {},
+ website: "",
+ setWebsite: () => {},
+ _handleCountry: () => {},
+ _handleProvince: () => {},
+ _handleCity: () => {},
+ _handleDistrict: () => {},
+ _handleSubmit: () => {},
+};
+
+export const GeneralContext = createContext(initialState);
+
+export const {
+ Provider: GeneralProvider,
+ Consumer: GeneralConsumer,
+} = GeneralContext;
+
+export const GeneralController = ({ children }) => {
+ const _isLogin = getToken();
+ const [open, setOpen] = useState(false);
+ const [branchName, setBranchName] = useState("");
+ const [address, setAddress] = useState("");
+ const [country, setCountry] = useState("");
+ const [province, setProvince] = useState("");
+ const [city, setCity] = useState("");
+ const [district, setDistrict] = useState("");
+ const [postalCode, setPostalCode] = useState("");
+ const [phoneNumber, setPhoneNumber] = useState("");
+ const [phoneNumberExt, setPhoneNumberExt] = useState("");
+ const [faxNumber, setFaxNumber] = useState("");
+ const [faxNumberExt, setFaxNumberExt] = useState("");
+ const [website, setWebsite] = useState("");
+ const [companyEmail, setCompanyEmail] = useState("");
+
+ const optionsCompanyType = [
+ {
+ label: "10 dari 255 (harap ketik untuk memfilter)",
+ isDisabled: true,
+ },
+ { value: "Indonesia", label: "Indonesia" },
+ ];
+ const Indonesia = [{ value: "Yogyakarta", label: "Yogyakarta" }];
+ const Yogya = [{ value: "Sleman", label: "Sleman" }];
+ const Sleman = [{ value: "Ngaglik", label: "Ngaglik" }];
+ const customStyles = {
+ control: (base) => ({
+ ...base,
+ height: 32,
+ minHeight: 32,
+ }),
+ };
+
+ // FormContext
+ const methods = useForm({
+ mode: "onChange",
+ });
+ const { register, setValue, triggerValidation } = methods;
+
+ useEffect(() => {
+ register(
+ { name: "business_type" },
+ {
+ required: true,
+ validate: (value) => {
+ return Array.isArray(value) ? value.length > 0 : !!value;
+ },
+ }
+ );
+ }, [register]);
+
+ useEffect(() => {
+ register(
+ { name: "country" },
+ {
+ required: true,
+ validate: (value) => {
+ return Array.isArray(value) ? value.length > 0 : !!value;
+ },
+ }
+ );
+ }, [register]);
+
+ useEffect(() => {
+ register(
+ { name: "province" },
+ {
+ required: true,
+ validate: (value) => {
+ return Array.isArray(value) ? value.length > 0 : !!value;
+ },
+ }
+ );
+ }, [register]);
+
+ useEffect(() => {
+ register(
+ { name: "city" },
+ {
+ required: true,
+ validate: (value) => {
+ return Array.isArray(value) ? value.length > 0 : !!value;
+ },
+ }
+ );
+ }, [register]);
+
+ useEffect(() => {
+ register(
+ { name: "district" },
+ {
+ required: true,
+ validate: (value) => {
+ return Array.isArray(value) ? value.length > 0 : !!value;
+ },
+ }
+ );
+ }, [register]);
+
+ const _handleCountry = (e: any) => {
+ setCountry(e && e.value);
+ setValue("country", e && e.value);
+ triggerValidation("country");
+ };
+
+ const _handleProvince = (e: any) => {
+ setProvince(e && e.value);
+ setValue("province", e && e.value);
+ triggerValidation("province");
+ };
+
+ const _handleCity = (e: any) => {
+ setCity(e && e.value);
+ setValue("city", e && e.value);
+ triggerValidation("city");
+ };
+
+ const _handleDistrict = (e: any) => {
+ setDistrict(e && e.value);
+ setValue("district", e && e.value);
+ triggerValidation("district");
+ };
+
+ const val = [
+ "branchName",
+ "address",
+ "country",
+ "province",
+ "city",
+ "district",
+ "postalCode",
+ "phoneNumber",
+ "phoneNumberExt",
+ "faxNumber",
+ "faxNumberExt",
+ "website",
+ "companyEmail",
+ ];
+
+ // Add
+ const [submitAdd] = useMutation(INSERT_VENDOR_CONTACT, {
+ errorPolicy: "all",
+ });
+
+ const _handleSubmit = async () => {
+ if (await triggerValidation(val)) {
+ try {
+ await submitAdd({
+ variables: {
+ company_name: branchName,
+ address,
+ country,
+ province,
+ city,
+ district,
+ postal_code: postalCode,
+ phone_number: phoneNumber,
+ website,
+ e_mail: companyEmail,
+ },
+ });
+ } catch (error) {}
+ } else {
+ console.log("Gagal");
+ }
+ };
+
+ return (
+
+
+ {children}
+
+
+ );
+};
diff --git a/src/App/Container/Views/Private/VendorProfile/Component/General/Query.ts b/src/App/Container/Views/Private/VendorProfile/Component/General/Query.ts
new file mode 100644
index 0000000..e563fb6
--- /dev/null
+++ b/src/App/Container/Views/Private/VendorProfile/Component/General/Query.ts
@@ -0,0 +1,49 @@
+import gql from "graphql-tag";
+
+export const GENERAL_LIST = gql`
+ {
+ GetVendorContacts {
+ id
+ companyName
+ address
+ county
+ province
+ city
+ district
+ phoneNumber
+ faxNumber
+ website
+ eMail
+ }
+ }
+`;
+
+export const INSERT_VENDOR_CONTACT = gql`
+ mutation(
+ $company_name: String
+ $address: String
+ $country: String
+ $province: String
+ $city: String
+ $district: String
+ $postal_code: Int
+ $phone_number: String
+ $website: String
+ $e_mail: String
+ ) {
+ InsertVendorContact(
+ data: {
+ company_name: $company_name
+ address: $address
+ country: $country
+ province: $province
+ city: $city
+ district: $district
+ postal_code: $postal_code
+ phone_number: $phone_number
+ website: $website
+ e_mail: $e_mail
+ }
+ )
+ }
+`;
diff --git a/src/App/Container/Views/Private/VendorProfile/Component/General/View.tsx b/src/App/Container/Views/Private/VendorProfile/Component/General/View.tsx
index 47a1713..c7c1e5b 100644
--- a/src/App/Container/Views/Private/VendorProfile/Component/General/View.tsx
+++ b/src/App/Container/Views/Private/VendorProfile/Component/General/View.tsx
@@ -1,12 +1,12 @@
import React from "react";
-import { MainApp } from "../../../../../Components";
import GeneralComponent from "./Component/General";
+import { GeneralController } from "./Controller";
const General = () => {
return (
-
+
-
+
);
};
diff --git a/src/App/Container/Views/Private/VendorProfile/Controller.tsx b/src/App/Container/Views/Private/VendorProfile/Controller.tsx
index 60bdce9..f809a34 100644
--- a/src/App/Container/Views/Private/VendorProfile/Controller.tsx
+++ b/src/App/Container/Views/Private/VendorProfile/Controller.tsx
@@ -1,9 +1,21 @@
-import React from 'react'
-
-export const HomeController = () => {
- return (
-
- Home Controller
-
- )
+import React, { createContext } from "react";
+import { useQuery } from "react-apollo";
+import { GENERAL_LIST } from "../VendorProfile/Component/General/Query";
+
+interface InitialState {
+ generalList: object;
}
+
+const initialState = {
+ generalList: {},
+};
+
+export const HomeContext = createContext(initialState);
+
+export const { Provider: HomeProvider, Consumer: HomeConsumer } = HomeContext;
+
+export const HomeController = ({ children }) => {
+ const { data: generalList } = useQuery(GENERAL_LIST);
+
+ return {children} ;
+};
diff --git a/src/App/Container/Views/Public/Registration/Component/Registration.tsx b/src/App/Container/Views/Public/Registration/Component/Registration.tsx
index d8675f7..97a98a6 100644
--- a/src/App/Container/Views/Public/Registration/Component/Registration.tsx
+++ b/src/App/Container/Views/Public/Registration/Component/Registration.tsx
@@ -553,12 +553,12 @@ const RegistrationComponent = () => {
ref={register({
required: "This is required",
minLength: {
- value: 4,
- message: "This input is less than 4 characters",
+ value: 5,
+ message: "This input is less than 5 characters",
},
maxLength: {
- value: 30,
- message: "This input is more than 30 characters",
+ value: 5,
+ message: "This input is more than 5 characters",
},
pattern: {
value: /^\d+$/,
diff --git a/src/Routes.tsx b/src/Routes.tsx
index 34c568a..325fbac 100644
--- a/src/Routes.tsx
+++ b/src/Routes.tsx
@@ -15,7 +15,7 @@ import {
TermCondition,
UserManual,
} from "./App/Container/Views/Public/index";
-import { VendorProfile,ChangePassword,Beranda } from "./App/Container/Views/Private/index";
+import { ChangePassword, Beranda } from "./App/Container/Views/Private/index";
import { PublicHeader, PublicSidebar } from "./App/Layout/Public/index";
import { PrivateSidebar } from "./App/Layout/Private/index";
import history from "./App/Misc/BrowserHistory";
@@ -103,12 +103,8 @@ const Routes = () => {
path="/registration"
component={Registration}
/>
+
-