Skip to content

Commit

Permalink
include roles as a sign up property, add the history menu to the land…
Browse files Browse the repository at this point in the history
…ing page
  • Loading branch information
Olasunkanmi Oyinlola authored and Olasunkanmi Oyinlola committed Feb 16, 2024
1 parent 81d3bee commit c20cbc1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions backend/src/infrastructure/filters/exception.filter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ArgumentsHost, Catch, ExceptionFilter, HttpException, HttpStatus, Inject } from '@nestjs/common';
import { ArgumentsHost, Catch, HttpException, HttpStatus, Inject } from '@nestjs/common';
import { BaseExceptionFilter } from '@nestjs/core';
import { Request } from 'express';
import * as fs from 'fs';
import { TYPES } from '../../application/constants';
import { IContextAwareLogger } from '../logger';
import { APIResponseMessage } from './../../application/constants/constants';
import { IExceptionResponse, IRequestException } from './exception-response.interface';
import { BaseExceptionFilter } from '@nestjs/core';

@Catch()
export class ApplicationExceptionsFilter extends BaseExceptionFilter {
Expand Down
5 changes: 5 additions & 0 deletions backend/src/singleclient/dtos/create-singleclient.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ export class CreateSingleClientDTO {
@IsNotEmpty()
@MaxLength(256)
readonly passwordHash: string;

@IsString()
@IsNotEmpty()
@MaxLength(128)
readonly role: string;
}
2 changes: 1 addition & 1 deletion backend/src/singleclient/singleclient.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class SingleClientService extends AuthService implements ISingleClientSer
const { email } = props;
const existingSingleClient: Result<SingleClient> = await this.singleclientRepository.findOne({ email });
if (existingSingleClient.isSuccess && existingSingleClient.getValue().email === email) {
throwApplicationError(HttpStatus.BAD_REQUEST, `User with email ${props.email} already exists`);
throwApplicationError(HttpStatus.BAD_REQUEST, `User already exists, please sign in.`);
}

const audit: Audit = Audit.createInsertContext(context);
Expand Down
17 changes: 13 additions & 4 deletions frontend/src/components/Utilities/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useState } from "react";
import { Button, Nav, Stack } from "react-bootstrap";
import Container from "react-bootstrap/Container";
import Navbar from "react-bootstrap/Navbar";
import { NavLink, Outlet, useNavigate } from "react-router-dom";
import { NavLink, Outlet, useLocation, useNavigate } from "react-router-dom";
import { CONSTANTS } from "../../constants/constant";
import { useShoppingCart } from "../../hooks/UseShoppingCart";
import { calculateQuantity } from "../../utility/utils";
Expand All @@ -16,6 +16,7 @@ export const Navigation = () => {
const handleCloseModal = () => setShowModal(false);
const handleShowModal = () => setShowModal(true);
const navigate = useNavigate();
const location = useLocation();

const displayModal = () => {
handleShowModal();
Expand All @@ -26,16 +27,24 @@ export const Navigation = () => {
resetMenu();
};

const handleNavMenu = () => {
return location.pathname === "/" ? (
<span style={{ color: "#407c54" }}>history</span>
) : (
<span style={{ fontWeight: 600 }} onClick={previousPage}>
<FontAwesomeIcon icon={faArrowLeftLong} size="xl" /> Back
</span>
);
};

return (
<>
<Navbar sticky="top" className="bg-white shadow-sm mb-3">
<Container>
<Nav className="me-auto">
<Nav.Link to="/" as={NavLink}>
<Stack direction="horizontal" gap={4}>
<span style={{ fontWeight: 600 }} onClick={previousPage}>
<FontAwesomeIcon icon={faArrowLeftLong} size="xl" /> Back
</span>
<span>{handleNavMenu()}</span>
</Stack>
</Nav.Link>
</Nav>
Expand Down

0 comments on commit c20cbc1

Please sign in to comment.