diff --git a/README.md b/README.md index 4b405cb..cb3f171 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,5 @@ ```bash git clone https://repos.point-dev.net/Karimaldeen/hijabi-dashboard.git cd hijabi-dashboard -npm install -npm start +pnpm install +pnpm start diff --git a/src/Components/Ui/tables/Actions.tsx b/src/Components/Ui/tables/Actions.tsx index dcf7aa0..f78e1ad 100644 --- a/src/Components/Ui/tables/Actions.tsx +++ b/src/Components/Ui/tables/Actions.tsx @@ -32,6 +32,7 @@ const TableActions = ({ onDelete=()=>{} , objectToEdit,onEdit=()=>{},onView,sh }} className="cursor-pointer m-2" size={20} />} {showView && } + {showDelete && ( { - + console.log(value,"value"); formik.setFieldValue(name, value) }; @@ -31,7 +31,7 @@ const Date = ({ name, label,picker="date" ,isDisabled,props,onChange,placeholder size="large" onChange={onChange || onCalendarChange} disabled={isDisabled} - format={Format ?? ""} + format={Format} /> diff --git a/src/Components/ValidationField/View/SearchField.tsx b/src/Components/ValidationField/View/SearchField.tsx index 498a783..d8ad1c6 100644 --- a/src/Components/ValidationField/View/SearchField.tsx +++ b/src/Components/ValidationField/View/SearchField.tsx @@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react'; import useFormField from '../../../Hooks/useFormField'; import { useLocation, useNavigate } from 'react-router-dom'; -const SearchField = ({ name, label, placeholder, isDisabled, searchBy, option, isMulti, onChange, className, props }: any) => { +const SearchField = ({ name, label, placeholder, isDisabled, searchBy, option, isMulti, onChange, className, loading,props }: any) => { const { errorMsg, isError, t, formik } = useFormField(name, props); const [searchQuery, setSearchQuery] = useState(''); const location = useLocation() @@ -55,6 +55,7 @@ const SearchField = ({ name, label, placeholder, isDisabled, searchBy, option, i showSearch optionFilterProp="label" onSearch={SearchHandleChange} + loading={loading} /> diff --git a/src/Components/ValidationField/View/SelectField.tsx b/src/Components/ValidationField/View/SelectField.tsx index 77a0450..b208b48 100644 --- a/src/Components/ValidationField/View/SelectField.tsx +++ b/src/Components/ValidationField/View/SelectField.tsx @@ -25,7 +25,7 @@ const SelectField = ({ name, label, placeholder, isDisabled,option,isMulti,onCha options={option} size="large" className={`${className} w-100`} - defaultValue={formik.values?.name} + defaultValue={formik.values[name]} allowClear {...(isMulti && { mode: "multiple" })} onChange={onChange || SelecthandleChange} diff --git a/src/Components/ValidationField/types.ts b/src/Components/ValidationField/types.ts index cda23c1..9673f8c 100644 --- a/src/Components/ValidationField/types.ts +++ b/src/Components/ValidationField/types.ts @@ -52,6 +52,7 @@ option: any[]; isMulti?: boolean; searchBy:string; + loading?:boolean; } export interface ValidationFieldPropsDataRange { diff --git a/src/Layout/Dashboard/FormikForm.tsx b/src/Layout/Dashboard/FormikForm.tsx new file mode 100644 index 0000000..9e42628 --- /dev/null +++ b/src/Layout/Dashboard/FormikForm.tsx @@ -0,0 +1,67 @@ +import { Formik, Form } from 'formik'; +import React, { ReactNode } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Button } from "reactstrap"; +import * as Yup from 'yup'; + +interface FormValues { + [key: string]: any; +} + +interface FormikFormProps { + handleSubmit: (values: any) => void + initialValues: FormValues; + validationSchema: any; + title?: string; + children: ReactNode; + ButtonName?:string +} +const FormikForm: React.FC = ({ children, handleSubmit, initialValues, validationSchema, title = "Add New Item" ,ButtonName="إضافة"}) => { + const [t]= useTranslation() + + return ( + <> + + {formik => ( +
+
+ {children} + +
+ +
+ )} +
+ + ); +}; + +export default FormikForm; + + + +{/* { + +}} +initialValues={() => { + return { + id: null, + name: "", + + } +}} +validationSchema={() => { + return Yup.object().shape({ + name: Yup.string().required('required'), + + }); +}} + +> + + */} \ No newline at end of file diff --git a/src/Layout/app/Header.tsx b/src/Layout/app/Header.tsx index d3af37e..fa20079 100644 --- a/src/Layout/app/Header.tsx +++ b/src/Layout/app/Header.tsx @@ -26,9 +26,9 @@ const Header = () => { const [t] = useTranslation(); const navigate = useNavigate() - // const { logout , user} = useAuthState() + const { logout , user} = useAuthState() const handelClick = () => { - // logout() + logout() navigate('/auth', { replace: true }) } diff --git a/src/Pages/Auth/LoginForm.tsx b/src/Pages/Auth/LoginForm.tsx index 6275012..6797687 100644 --- a/src/Pages/Auth/LoginForm.tsx +++ b/src/Pages/Auth/LoginForm.tsx @@ -30,7 +30,7 @@ const OnSuccess = ()=>{ return (
- Logo + Logo