Skip to content

Commit

Permalink
Added add and delete page
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-tco committed Jul 31, 2023
1 parent a56cb1c commit 525154f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ import getConfig from 'next/config';
import InferProps from '../../../../../types/InferProps';
import { getUserTokenFromCookies } from '../../../../../utils/session';
import { deleteDepartmentInformation } from '../../../../../services/SuperAdminService';
import { Department } from '../../../types';

export function getServerSideProps(context: GetServerSidePropsContext) {
const fetchPageData = async () => {
return { id: context.params?.id as string };
};

const handleRequest = async (id: any, jwt: string) => {
console.log('id', id);
deleteDepartmentInformation({ id }, jwt);
};
const handleRequest = async (
body: Omit<Department, 'name' | 'ggisID'>,
jwt: string
) => deleteDepartmentInformation(body.id, jwt);

return QuestionPageGetServerSideProps({
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ const ManageDepartmentsPage = ({
hasWiderKeyColumn
rows={departments.map((dept, idx) => getDepartmentRow(idx, dept))}
/>
<CustomLink
href={`/manage-departments/create`}
isButton
isSecondaryButton
>
<CustomLink href={`/manage-departments/add`} isButton isSecondaryButton>
Add new department
</CustomLink>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/services/SuperAdminService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const updateDepartmentInformation = async (
);

export const deleteDepartmentInformation = async (
id: Record<string, string>,
id: string,
userToken: string
) =>
axios.delete(
Expand Down

0 comments on commit 525154f

Please sign in to comment.