Skip to content

Commit

Permalink
Fix: Redundant new route removal (#450)
Browse files Browse the repository at this point in the history
* modal  (#446)

* modal

* Update index.jsx

* Update index.jsx

* Update index.jsx

* Update index.jsx

* Update index.jsx

* Update index.jsx

* Update index.jsx

* Update index.jsx

* Update index.jsx

* Fix: prettier error resolution for build

---------

Co-authored-by: Diya Therese Shibu <[email protected]>
  • Loading branch information
subru-37 and Diyashibu authored Sep 23, 2024
1 parent a244f00 commit 4fb5439
Show file tree
Hide file tree
Showing 21 changed files with 5,229 additions and 1,998 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ["custom"],
extends: ['custom'],
settings: {
next: {
rootDir: ["apps/*/"],
rootDir: ['apps/*/'],
},
},
};
24 changes: 12 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/apps/core-admin"
- package-ecosystem: 'npm'
directory: '/apps/core-admin'
schedule:
interval: "weekly"
- package-ecosystem: "npm"
directory: "/apps/core-auth0-actions"
interval: 'weekly'
- package-ecosystem: 'npm'
directory: '/apps/core-auth0-actions'
schedule:
interval: "weekly"
- package-ecosystem: "npm"
directory: "/apps/web-admin"
interval: 'weekly'
- package-ecosystem: 'npm'
directory: '/apps/web-admin'
schedule:
interval: "weekly"
- package-ecosystem: "npm"
directory: "/"
interval: 'weekly'
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: |
curl -X GET ${{ secrets.DEV_CORE_ADMIN_DEPLOY_HOOK }}
curl -X GET ${{ secrets.PROD_CORE_ADMIN_DEPLOY_HOOK }}
build-and-push-core-auth0-actions:
runs-on: ubuntu-latest

Expand Down
12 changes: 6 additions & 6 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 100,
tabWidth: 2,
};
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 100,
tabWidth: 2,
};
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<div align="center">
<h1 align="center">Techno Event Management</h1>
<h3>A powerful event management suite.</h3>
Expand Down
2 changes: 1 addition & 1 deletion apps/web-admin/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"components": "@/components",
"utils": "@/lib/utils"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';

import { Button } from '@chakra-ui/react';

import {
Button,
Modal,
ModalOverlay,
ModalContent,
ModalHeader,
ModalBody,
ModalCloseButton,
useDisclosure,
} from '@chakra-ui/react';
import DashboardLayout from '@/layouts/DashboardLayout';

import { useFetch } from '@/hooks/useFetch';
import { useAlert } from '@/hooks/useAlert';

import DataDisplay from '@/components/DataDisplay';
import NewAttributeForm from './new';

const columns = [
{ field: 'name', headerName: 'Name', width: 200 },
Expand All @@ -23,10 +29,9 @@ export default function Attributes() {
const router = useRouter();
const { orgId, eventId } = router.query;
const showAlert = useAlert();

const { isOpen, onOpen, onClose } = useDisclosure();
const { loading, get } = useFetch();

const [event, setEvent] = useState([]);
const [attributes, setAttributes] = useState([]);

useEffect(() => {
Expand All @@ -53,12 +58,7 @@ export default function Attributes() {
previousPage={`/organizations/${orgId}/events/${eventId}`}
headerButton={
<>
<Button
onClick={() => {
router.push(`/${orgId}/events/${eventId}/attributes/new`);
}}
isLoading={loading}
>
<Button onClick={onOpen} isLoading={loading}>
Add Attribute
</Button>
</>
Expand All @@ -73,6 +73,17 @@ export default function Attributes() {
router.push(`/${orgId}/events/${eventId}/attributes/${row.id}`);
}}
/>

<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalHeader>Add Attribute</ModalHeader>
<ModalCloseButton />
<ModalBody>
<NewAttributeForm onClose={onClose} />
</ModalBody>
</ModalContent>
</Modal>
</DashboardLayout>
);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { useState } from 'react';
import { useRouter } from 'next/router';

import { Button, FormControl, FormLabel, Input } from '@chakra-ui/react';

import DashboardLayout from '@/layouts/DashboardLayout';

import { useAlert } from '@/hooks/useAlert';
import { useFetch } from '@/hooks/useFetch';

export default function NewAttribute() {
export default function NewAttributeForm({ onClose }) {
const { loading, post } = useFetch();
const showAlert = useAlert();

const router = useRouter();
const { orgId, eventId } = router.query;

Expand All @@ -22,16 +17,15 @@ export default function NewAttribute() {
const { data, status } = await post(
`/core/organizations/${orgId}/events/${eventId}/attributes`,
{},
{
name,
},
{ name },
);
if (status === 200) {
showAlert({
title: 'Success',
description: 'Attribute has been added successfully.',
status: 'success',
});
onClose();
router.push(`/${orgId}/events/${eventId}/attributes`);
} else {
showAlert({
Expand All @@ -43,26 +37,22 @@ export default function NewAttribute() {
};

return (
<DashboardLayout
pageTitle="Add Attribute"
previousPage={`/organizations/${orgId}/events/${eventId}/attributes`}
>
<form onSubmit={handleSubmit}>
<FormControl isRequired my={4}>
<FormLabel>Name</FormLabel>
<Input
type="text"
name="name"
value={name}
onChange={(e) => {
setName(e.target.value);
}}
/>
</FormControl>
<Button type="submit" width="100%" my="4" isLoading={loading} loadingText="Please Wait">
Add
</Button>
</form>
</DashboardLayout>
<form onSubmit={handleSubmit}>
<FormControl isRequired my={4}>
<FormLabel>Name</FormLabel>
<Input type="text" name="name" value={name} onChange={(e) => setName(e.target.value)} />
</FormControl>

<Button
type="submit"
width="100%"
my="4"
isLoading={loading}
loadingText="Please Wait"
colorScheme="teal"
>
Add
</Button>
</form>
);
}
38 changes: 26 additions & 12 deletions apps/web-admin/src/pages/[orgId]/events/[eventId]/extras/index.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';

import { Button } from '@chakra-ui/react';

import {
Button,
Modal,
ModalOverlay,
ModalContent,
ModalHeader,
ModalBody,
ModalCloseButton,
useDisclosure,
} from '@chakra-ui/react';
import DashboardLayout from '@/layouts/DashboardLayout';

import { useFetch } from '@/hooks/useFetch';
import { useAlert } from '@/hooks/useAlert';

import DataDisplay from '@/components/DataDisplay';
import NewExtraForm from './new'; // Import the form component

const columns = [
{ field: 'name', headerName: 'Name', width: 200 },
Expand All @@ -28,7 +34,7 @@ export default function Extras() {
const router = useRouter();
const { orgId, eventId } = router.query;
const showAlert = useAlert();

const { isOpen, onOpen, onClose } = useDisclosure(); // Chakra UI hook for modal control
const { loading, get } = useFetch();

const [extras, setExtras] = useState([]);
Expand All @@ -55,12 +61,7 @@ export default function Extras() {
previousPage={`/organizations/${orgId}/events/${eventId}`}
headerButton={
<>
<Button
onClick={() => {
router.push(`/${orgId}/events/${eventId}/extras/new`);
}}
isLoading={loading}
>
<Button onClick={onOpen} isLoading={loading}>
Add Extra
</Button>
</>
Expand All @@ -75,6 +76,19 @@ export default function Extras() {
router.push(`/${orgId}/events/${eventId}/extras/${row.id}`);
}}
/>

{/* Modal for creating a new extra */}
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalHeader>Add Extra</ModalHeader>
<ModalCloseButton />
<ModalBody>
{/* Render the form from new/index.js */}
<NewExtraForm onClose={onClose} />
</ModalBody>
</ModalContent>
</Modal>
</DashboardLayout>
);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { useState } from 'react';
import { useRouter } from 'next/router';

import { Button, FormControl, FormLabel, Input } from '@chakra-ui/react';

import DashboardLayout from '@/layouts/DashboardLayout';

import { useAlert } from '@/hooks/useAlert';
import { useFetch } from '@/hooks/useFetch';

export default function NewExtra() {
export default function NewExtraForm({ onClose }) {
// Accept onClose to close the modal
const { loading, post } = useFetch();
const showAlert = useAlert();

const router = useRouter();
const { orgId, eventId } = router.query;

Expand All @@ -22,17 +18,16 @@ export default function NewExtra() {
const { data, status } = await post(
`/core/organizations/${orgId}/events/${eventId}/extras`,
{},
{
name,
},
{ name },
);
if (status === 200) {
showAlert({
title: 'Success',
description: 'Extra has been added successfully.',
status: 'success',
});
router.push(`/${orgId}/events/${eventId}/extras`);
onClose(); // Close the modal after success
router.push(`/${orgId}/events/${eventId}/extras`); // Redirect to extras list
} else {
showAlert({
title: 'Error',
Expand All @@ -43,26 +38,21 @@ export default function NewExtra() {
};

return (
<DashboardLayout
pageTitle="Add Extra"
previousPage={`/organizations/${orgId}/events/${eventId}/extras`}
>
<form onSubmit={handleSubmit}>
<FormControl isRequired my={4}>
<FormLabel>Name</FormLabel>
<Input
type="text"
name="name"
value={name}
onChange={(e) => {
setName(e.target.value);
}}
/>
</FormControl>
<Button type="submit" width="100%" my="4" isLoading={loading} loadingText="Please Wait">
Add
</Button>
</form>
</DashboardLayout>
<form onSubmit={handleSubmit}>
<FormControl isRequired my={4}>
<FormLabel>Name</FormLabel>
<Input type="text" name="name" value={name} onChange={(e) => setName(e.target.value)} />
</FormControl>
<Button
type="submit"
width="100%"
my="4"
isLoading={loading}
loadingText="Please Wait"
colorScheme="teal"
>
Add
</Button>
</form>
);
}
Loading

0 comments on commit 4fb5439

Please sign in to comment.