Skip to content

Commit

Permalink
Merge pull request #13 from chaitanyakole/bug_fixes
Browse files Browse the repository at this point in the history
Search and sorting hide, remove roles and credeantials removed
  • Loading branch information
gouravmore authored Dec 25, 2024
2 parents f5e429a + 57f06b0 commit e7221f4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 52 deletions.
18 changes: 11 additions & 7 deletions src/components/HeaderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const HeaderComponent = ({
tenantDefaultValue,
isTenantShow,
isCohortShow,
showSearch = true,
}: any) => {
const { t } = useTranslation();
const queryClient = useQueryClient();
Expand Down Expand Up @@ -664,15 +665,18 @@ const HeaderComponent = ({
display: "flex",
flexDirection: isMobile || isMediumScreen ? "column" : "row",
gap: isMobile || isMediumScreen ? "8px" : "5%",
marginTop: "20px",
marginTop: showSearch ? "20px" : "10px",
p: showSearch ? "1%" : "1%",
}}
>
<Box sx={{ flex: 1, paddingLeft: "16px", paddingRight: "16px" }}>
<SearchBar
onSearch={handleSearch}
placeholder={searchPlaceHolder}
/>
</Box>
{showSearch && (
<Box sx={{ flex: 1, paddingLeft: "16px", paddingRight: "16px" }}>
<SearchBar
onSearch={handleSearch}
placeholder={searchPlaceHolder}
/>
</Box>
)}
{showAddNew && (
<Box
display={"flex"}
Expand Down
27 changes: 1 addition & 26 deletions src/pages/cohortSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@
"validation": [],
"description": "Enter the cohort name."
},
"username": {
"title": "Username",
"fieldId": null,
"type": "string",
"validation": []
},
"password": {
"title": "Password",
"fieldId": null,
"type": "string",
"validation": []
},
"type": {
"title": "Type",
"type": "string",
Expand All @@ -42,19 +30,6 @@
"readOnly": true,
"validation": [],
"description": "The current status of the cohort, this field is read-only."
},

"role": {
"title": "Role",
"type": "string",
"oneOf": [
{
"title": "Learner",
"const": "learner"
}
],
"validation": []
}
},
"dependencies": {}
}
}
2 changes: 0 additions & 2 deletions src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ const LoginPage = () => {

const userInfo = response?.userData;
setAdminInfo(userInfo);
const tenantId = userInfo?.tenantData?.[0]?.tenantId;
localStorage.setItem("tenantId", tenantId);
//set user info in zustand store
if (typeof window !== "undefined" && window.localStorage) {
localStorage.setItem("adminInfo", JSON.stringify(userInfo));
Expand Down
16 changes: 8 additions & 8 deletions src/pages/tenant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ const Tenant: React.FC = () => {
"ui:help":
"Password must be at least 8 characters long, with at least one letter and one number.",
},
role: {
"ui:widget": "select",
"ui:placeholder": "Select a role",
// "ui:help": "Select a role.",
},
// role: {
// "ui:widget": "select",
// "ui:placeholder": "Select a role",
// // "ui:help": "Select a role.",
// },
status: {
"ui:widget": "CustomRadioWidget",
"ui:options": {
Expand Down Expand Up @@ -403,7 +403,7 @@ const Tenant: React.FC = () => {

useEffect(() => {
fetchTenantList();
}, [openAddNewCohort]);
}, [openAddNewCohort, filters]);

// const getFormData = async () => {
// try {
Expand Down Expand Up @@ -761,7 +761,6 @@ const Tenant: React.FC = () => {
newValue: any
) => {
setStatusValue(newValue);

setSelectedFilter(newValue);
setPageSize(Numbers.TEN);
setPageLimit(Numbers.TEN);
Expand Down Expand Up @@ -1261,11 +1260,12 @@ const Tenant: React.FC = () => {
handleSearch: handleSearch,
showAddNew: adminRole == true ? true : false,
// showAddNew: true,
showSearch: false,
statusArchived: true,
handleAddUserClick: handleAddUserClick,
statusValue: statusValue,
setStatusValue: setStatusValue,
showSort: true,
showSort: false,
selectedBlockCode: selectedBlockCode,
setSelectedBlockCode: setSelectedBlockCode,
selectedDistrictCode: selectedDistrictCode,
Expand Down
28 changes: 19 additions & 9 deletions src/services/CohortService/cohortService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { CohortMemberList } from "@/utils/Interfaces";
import { deleteApi, get, patch, post, put } from "../RestClient";
import config from "@/utils/urlConstants.json";
import axios from 'axios';

export interface cohortListFilter {
type: string;
status: string[];
Expand Down Expand Up @@ -251,26 +253,34 @@ data:any
let apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/${config.URLS.ROLES_LIST}`;

try {
const response = await post(apiUrl, data);
console.log({response});

const response = await post(apiUrl, data);
return response?.data;
} catch (error) {
console.error("Error in Getting cohort List Details", error);
return error;
}
};
export const userCreate = async (data: cohortListData,userTenantId:string): Promise<any> => {
let apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/${config.URLS.USER_CREATE}`;

export const userCreate = async (data: cohortListData, userTenantId: string): Promise<any> => {
const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/${config.URLS.USER_CREATE}`;

try {
const response = await post(apiUrl, data);
return response?.data;
const token=localStorage.getItem('token')
const headers = {
'Authorization': `Bearer ${token}`,
'Content-Type':'application/json',
'tenantid': userTenantId ,
};

const response = await axios.post(apiUrl, data, { headers });
console.log({response});
return response?.data;
} catch (error) {
console.error("Error in Getting cohort List Details", error);
return error;
console.error('Error in Creating User:', error);
return error ;
}
};


export const deleteUser = async (
userId: string
Expand Down

0 comments on commit e7221f4

Please sign in to comment.