diff --git a/package.json b/package.json index b8266c65..1a4b6ec2 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "random-words": "^2.0.0", "react": "18.2.0", "react-chartjs-2": "^5.2.0", + "react-csv": "^2.2.2", "react-currency-input-field": "^3.6.12", "react-datepicker": "^4.18.0", "react-dom": "18.2.0", @@ -78,6 +79,7 @@ "@types/lodash": "^4.14.191", "@types/nodemailer": "^6.4.11", "@types/nodemailer-express-handlebars": "^4.0.3", + "@types/react-csv": "^1.1.10", "@types/react-datepicker": "^4.15.1", "@types/uuid": "^9.0.1", "@types/wavesurfer.js": "^6.0.6", diff --git a/src/components/Low/Checkbox.tsx b/src/components/Low/Checkbox.tsx index e5e9656d..d5a7298d 100644 --- a/src/components/Low/Checkbox.tsx +++ b/src/components/Low/Checkbox.tsx @@ -6,11 +6,15 @@ interface Props { isChecked: boolean; onChange: (isChecked: boolean) => void; children: ReactNode; + disabled?: boolean; } -export default function Checkbox({isChecked, onChange, children}: Props) { +export default function Checkbox({isChecked, onChange, children, disabled}: Props) { return ( -
onChange(!isChecked)}> +
{ + if(disabled) return; + onChange(!isChecked); + }}>
void; onViewTeachers?: () => void; onViewCorporate?: () => void; + disabled?: boolean; } -const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, onViewCorporate}: Props) => { +const USER_STATUS_OPTIONS = [ + { + value: 'active', + label: 'Active', + }, { + value: 'disabled', + label: 'Disabled', + }, { + value: 'paymentDue', + label: 'Payment Due', + } +]; + +const USER_TYPE_OPTIONS = Object.keys(USER_TYPE_LABELS).map((type) => ({ + value: type, + label: USER_TYPE_LABELS[type as keyof typeof USER_TYPE_LABELS] +})); + +const CURRENCIES_OPTIONS = CURRENCIES.map(({ label, currency}) => ({ value: currency, label })); + +const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, onViewCorporate, disabled = false}: Props) => { const [expiryDate, setExpiryDate] = useState(user.subscriptionExpirationDate); const [type, setType] = useState(user.type); const [status, setStatus] = useState(user.status); @@ -154,6 +175,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, placeholder="Enter corporate name" defaultValue={companyName} required + disabled={disabled} />
@@ -178,6 +201,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, onChange={setCompanyName} placeholder="Enter corporate name" defaultValue={companyName} + disabled={disabled} /> setUserAmount(e ? parseInt(e) : undefined)} placeholder="Enter number of users" defaultValue={userAmount} + disabled={disabled} /> setMonthlyDuration(e ? parseInt(e) : undefined)} placeholder="Enter monthly duration" defaultValue={monthlyDuration} + disabled={disabled} />
@@ -204,17 +230,31 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, type="number" defaultValue={paymentValue || 0} className="col-span-3" + disabled={disabled} + /> + setPaymentCurrency(e.target.value)} - className="p-6 col-span-2 w-full min-h-[70px] flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer bg-white"> - {CURRENCIES.map(({label, currency}) => ( - - ))} -
@@ -249,6 +289,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, color: state.isFocused ? "black" : styles.color, }), }} + isDisabled={disabled} /> )} @@ -262,6 +303,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, type="number" defaultValue={commissionValue || 0} className="col-span-3" + disabled={disabled} /> ) : ( @@ -316,7 +358,8 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, + className="grid grid-cols-2 items-center gap-4 place-items-center" + disabled={disabled}> {EMPLOYMENT_STATUS.map(({status, label}) => ( {({checked}) => ( @@ -351,7 +394,11 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers,
- + {({checked}) => ( Expiry Date setExpiryDate(checked ? user.subscriptionExpirationDate || new Date() : null)}> + onChange={(checked) => setExpiryDate(checked ? user.subscriptionExpirationDate || new Date() : null)} + disabled={disabled} + > Enabled
@@ -434,6 +483,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, dateFormat="dd/MM/yyyy" selected={moment(expiryDate).toDate()} onChange={(date) => setExpiryDate(date)} + disabled={disabled} /> )}
@@ -445,27 +495,55 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers,
- + setType(e.target.value as typeof user.type)} - className="p-6 w-full min-h-[70px] flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer bg-white"> - {Object.keys(USER_TYPE_LABELS).map((type) => ( - - ))} - + + (profilePictureInput.current as any)?.click()} + className="cursor-pointer text-mti-purple-light text-sm"> + Change picture + +
{USER_TYPE_LABELS[user.type]}
- - (profilePictureInput.current as any)?.click()} - className="cursor-pointer text-mti-purple-light text-sm"> - Change picture - -
{USER_TYPE_LABELS[user.type]}
+ {user.type === 'agent' && ( +
+ {user.demographicInformation?.country.toLowerCase() +
+ )}
diff --git a/yarn.lock b/yarn.lock index 6b4aa13c..24bb6199 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1287,6 +1287,13 @@ resolved "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz" integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== +"@types/react-csv@^1.1.10": + version "1.1.10" + resolved "https://registry.yarnpkg.com/@types/react-csv/-/react-csv-1.1.10.tgz#b4e292d7330d2fa12062c579c752f254f559bf56" + integrity sha512-PESAyASL7Nfi/IyBR3ufd8qZkyoS+7jOylKmJxRZUZLFASLo4NZaRsJ8rNP8pCcbIziADyWBbLPD1nPddhsL4g== + dependencies: + "@types/react" "*" + "@types/react-datepicker@^4.15.1": version "4.15.1" resolved "https://registry.yarnpkg.com/@types/react-datepicker/-/react-datepicker-4.15.1.tgz#a66fee520f2a31f83b45f4ed7f28af7296e11d0c" @@ -4519,6 +4526,11 @@ react-chartjs-2@^5.2.0: resolved "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz" integrity sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA== +react-csv@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/react-csv/-/react-csv-2.2.2.tgz#5bbf0d72a846412221a14880f294da9d6def9bfb" + integrity sha512-RG5hOcZKZFigIGE8LxIEV/OgS1vigFQT4EkaHeKgyuCbUAu9Nbd/1RYq++bJcJJ9VOqO/n9TZRADsXNDR4VEpw== + react-currency-input-field@^3.6.12: version "3.6.12" resolved "https://registry.yarnpkg.com/react-currency-input-field/-/react-currency-input-field-3.6.12.tgz#6c59bec50b9a769459c971f94f9a67b7bf9046f7"