diff --git a/apps/backend/src/user/user.service.ts b/apps/backend/src/user/user.service.ts index 263b874b..d44937a8 100644 --- a/apps/backend/src/user/user.service.ts +++ b/apps/backend/src/user/user.service.ts @@ -4,7 +4,6 @@ import { DynamoDbService } from '../dynamodb'; import { UserInputModel, UserStatus, Role } from './user.model'; import { NewUserInput } from '../dtos/newUserDTO'; - @Injectable() export class UserService { private readonly tableName = 'gibostonUsers'; @@ -53,7 +52,6 @@ export class UserService { } } - public async getUserTables(userId: number): Promise> { try { const key = { userId: { N: userId.toString() } }; diff --git a/apps/frontend/.env.example b/apps/frontend/.env.example index 98c420f4..5986055e 100644 --- a/apps/frontend/.env.example +++ b/apps/frontend/.env.example @@ -1,2 +1 @@ VITE_GOOGLE_MAPS_API_KEY=INSERT_API_KEY_HERE - diff --git a/apps/frontend/src/pages/registerPage/formPage.tsx b/apps/frontend/src/pages/registerPage/formPage.tsx index 7be37eb3..18efae7c 100644 --- a/apps/frontend/src/pages/registerPage/formPage.tsx +++ b/apps/frontend/src/pages/registerPage/formPage.tsx @@ -38,6 +38,14 @@ const FormPage: React.FC = ({ setIsSubmitted }) => { }); const [showPassword, setShowPassword] = useState(false); const [showRePassword, setShowRePassword] = useState(false); + const [userId, setUserId] = useState(''); + const [error, setError] = useState(''); + + const UserStatus = { + APPROVED: 'Approved', + PENDING: 'Pending', + DENIED: 'Denied', + }; const handleTogglePassword = () => { setShowPassword((prev) => !prev); @@ -47,7 +55,29 @@ const FormPage: React.FC = ({ setIsSubmitted }) => { setShowRePassword((prev) => !prev); }; - // Define the validation schema using Yup + const handleSubmit = async () => { + if (!userId.trim()) { + setError('User ID required'); + return; + } + //console.log('UserID: ', userId); + + try { + const response = await axios.put( + `${import.meta.env.VITE_API_BASE_URL}/users/editUser/${userId}`, + { status: UserStatus.APPROVED }, + ); + + setIsSubmitted(true); + + //console.log('Response:', response.data); + } catch (e) { + setError('Failed to approve user. Please try again.'); + console.error('Error: ', e); + } + }; + + // Validation schema using Yup const validationSchema = Yup.object({ userId: Yup.string().required('User ID is required'), email: Yup.string() @@ -313,6 +343,7 @@ const FormPage: React.FC = ({ setIsSubmitted }) => { }} sx={{ '& .MuiFilledInput-root': { fontFamily: 'Montserrat' } }} /> + {formik.touched.rePassword && formik.errors.rePassword && (