diff --git a/cypress/e2e/users_spec/user_crud.cy.ts b/cypress/e2e/users_spec/user_crud.cy.ts index e24998295b9..ace5cfe5c2e 100644 --- a/cypress/e2e/users_spec/user_crud.cy.ts +++ b/cypress/e2e/users_spec/user_crud.cy.ts @@ -11,7 +11,7 @@ const makeid = (length: number) => { }; const makePhoneNumber = () => - "9199" + Math.floor(Math.random() * 99999999).toString(); + "98" + Math.floor(Math.random() * 99999999).toString(); const username = makeid(25); const phone_number = makePhoneNumber(); @@ -41,29 +41,28 @@ describe("User management", () => { cy.intercept(/\/api\/v1\/facility/).as("facility"); cy.get("[name='facilities']").type("Mysore").wait("@facility"); cy.get("[name='facilities']").type("{downarrow}{enter}"); + cy.get("input[type='checkbox']").click(); + cy.get("[placeholder='Phone Number']").type(phone_number); + cy.get("[placeholder='WhatsApp Phone Number']").type(alt_phone_number, { + force: true, + }); cy.intercept(/users/).as("check_availability"); cy.get("[name='username']").type(username, { force: true }); + cy.get("[id='date_of_birth']").click(); + cy.get("div").contains("20").click(); + cy.get("[id='year-0']").click(); + cy.get("[id='date-1']").click(); cy.wait("@check_availability").its("response.statusCode").should("eq", 200); cy.get("[name='password']").type("#@Cypress_test123"); cy.get("[name='c_password']").type("#@Cypress_test123"); cy.get("[name='first_name']").type("Cypress Test"); cy.get("[name='last_name']").type("Tester"); + cy.get("[name='email']").type("cypress@tester.com"); cy.get("[id='gender'] > div > button").click(); cy.get("div").contains("Male").click(); - cy.get("[id='date_of_birth']").click(); - cy.get("div").contains("20").click(); - cy.get("body").click(700, 450); - cy.get("body").click(720, 470); - cy.get("input[type='checkbox']").click(); - cy.wait(1000); - cy.get("[placeholder='Phone Number']").type(phone_number); - cy.wait(1000); - cy.get("[placeholder='WhatsApp Phone Number']").type(alt_phone_number, { + cy.get("button[id='submit']").contains("Save User").click({ force: true, }); - cy.wait(1000); - cy.get("[name='email']").type("cypress@tester.com"); - cy.get("button[id='submit']").contains("Save User").click(); cy.verifyNotification("User added successfully"); }); @@ -72,10 +71,10 @@ describe("User management", () => { cy.get("[name='first_name']").type("Cypress Test"); cy.get("[name='last_name']").type("Tester"); cy.get("[placeholder='Phone Number']").type(phone_number); + cy.get("input[name='district']").type("Ernakulam"); cy.get("[placeholder='WhatsApp Phone Number']").type(alt_phone_number); cy.contains("Apply").click(); cy.get("[name='username']").type(username, { force: true }); - // TODO: some verify task }); it("link facility for user", () => { diff --git a/src/Components/Common/DateInputV2.tsx b/src/Components/Common/DateInputV2.tsx index a2c1e1ec091..aa4e2150e6b 100644 --- a/src/Components/Common/DateInputV2.tsx +++ b/src/Components/Common/DateInputV2.tsx @@ -252,8 +252,12 @@ const DateInputV2: React.FC = ({ {type === "date" && ( <>
- {DAYS.map((day) => ( -
+ {DAYS.map((day, i) => ( +
{day}
@@ -268,7 +272,11 @@ const DateInputV2: React.FC = ({ /> ))} {dayCount.map((d, i) => ( -
+
= ({ .map((_, i) => (
= ({ return (
= (option: T) => R; @@ -12,6 +13,7 @@ type SelectMenuProps = { disabled?: boolean | undefined; value: V | undefined; placeholder?: React.ReactNode; + position?: "above" | "below"; optionLabel: OptionCallback; optionSelectedLabel?: OptionCallback; optionDescription?: OptionCallback; @@ -99,40 +101,47 @@ const SelectMenuV2 = (props: SelectMenuProps) => { )}
- - - {options.map((option, index) => ( - - {({ active, selected }) => ( -
-
- {option.label} - {props.optionIcon - ? option.icon - : selected && ( - - )} +
+ + + {options.map((option, index) => ( + + {({ active, selected }) => ( +
+
+ {option.label} + {props.optionIcon + ? option.icon + : selected && ( + + )} +
+ {option.description && ( +

+ {option.description} +

+ )}
- {option.description && ( -

- {option.description} -

- )} -
- )} - - ))} - - + )} + + ))} + + +
)} diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index 41b5f67f269..27e906158f6 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -544,7 +544,7 @@ export const UserAdd = (props: UserProps) => { email: state.form.email, state: state.form.state, district: state.form.district, - local_body: state.form.local_body, + local_body: showLocalbody ? state.form.local_body : null, phone_number: parsePhoneNumberFromString( state.form.phone_number )?.format("E.164"), @@ -616,7 +616,6 @@ export const UserAdd = (props: UserProps) => { showAll={false} />
-
-
- {isStateLoading ? ( - - ) : ( - <> - o.name} - optionValue={(o) => o.id} - value={state.form.state} - onChange={(e) => { - if (e) { - return [ - handleValueChange(e, "state"), - fetchDistricts(e), - ]; - } - }} - /> - - - )} + + handleValueChange(value, "phone_number") + } + errors={state.errors.phone_number} + onlyIndia={true} + /> + { + setPhoneIsWhatsApp(checked); + !checked && handleValueChange("+91", "alt_phone_number"); + }} + label="Is the phone number a WhatsApp number?" + />
-
- - {isDistrictLoading ? ( - - ) : ( - <> - o.name} - optionValue={(o) => o.id} - value={state.form.district} - onChange={(e) => { - if (e) { - return [ - handleValueChange(e, "district"), - fetchLocalBody(e), - ]; - } - }} - /> - - - )} + + + handleValueChange(value, "alt_phone_number") + } + disabled={phoneIsWhatsApp} + errors={state.errors.alt_phone_number} + onlyIndia={true} + />
- - {showLocalbody && ( -
- - {isLocalbodyLoading ? ( - - ) : ( - <> - o.name} - optionValue={(o) => o.id} - value={state.form.local_body} - onChange={(e) => handleValueChange(e, "local_body")} - /> - - - )} -
- )} -
)}
+
+ + +
)}
-
-
-
- +
+ + +
- -
- - -
- - handleValueChange(value, "phone_number") - } - errors={state.errors.phone_number} - onlyIndia={true} - /> - { - setPhoneIsWhatsApp(checked); - !checked && handleValueChange("+91", "alt_phone_number"); - }} - label="Is the phone number a WhatsApp number?" - /> -
- -
- - - handleValueChange(value, "alt_phone_number") - } - disabled={phoneIsWhatsApp} - errors={state.errors.alt_phone_number} - onlyIndia={true} - /> + {isStateLoading ? ( + + ) : ( + <> + o.name} + optionValue={(o) => o.id} + value={state.form.state} + onChange={(e) => { + if (e) { + return [ + handleValueChange(e, "state"), + fetchDistricts(e), + ]; + } + }} + /> + + + )}
- + {isDistrictLoading ? ( + + ) : ( + <> + o.name} + optionValue={(o) => o.id} + value={state.form.district} + onChange={(e) => { + if (e) { + return [ + handleValueChange(e, "district"), + fetchLocalBody(e), + ]; + } + }} + /> + + + )}
+ {showLocalbody && ( +
+ + {isLocalbodyLoading ? ( + + ) : ( + <> + o.name} + optionValue={(o) => o.id} + value={state.form.local_body} + onChange={(e) => handleValueChange(e, "local_body")} + /> + + + )} +
+ )}
goBack()} /> diff --git a/src/Components/Users/UserFilter.tsx b/src/Components/Users/UserFilter.tsx index 8e311552527..a645b707182 100644 --- a/src/Components/Users/UserFilter.tsx +++ b/src/Components/Users/UserFilter.tsx @@ -123,6 +123,7 @@ export default function UserFilter(props: any) {
Role o.role + ((o.readOnly && " (Read Only)") || "")}