Skip to content

Commit 7b76aac

Browse files
Merge pull request #72 from credebl/291-send-invitation-design
Send invitation design: 291
2 parents 4a4ac78 + 87478b0 commit 7b76aac

File tree

9 files changed

+118
-77
lines changed

9 files changed

+118
-77
lines changed

src/app/NavBarStacked.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { asset, url } from '../lib/data.js';
88
<div class="container py-3 mx-auto">
99
<div class="flex items-center justify-between">
1010
<div class="flex items-center justify-start">
11-
<a class="flex mr-4">
11+
<a class="flex mr-4" href='/'>
1212
<img
1313
src='/images/CREDEBL_ICON.png'
1414
class="h-8 mr-3"
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
import { Alert, Avatar, Spinner } from 'flowbite-react';
1+
import { Alert } from 'flowbite-react';
2+
3+
export const AlertComponent = ({ message, type, viewButton, onAlertClose }: { message: string | null, type: string, viewButton?: boolean, onAlertClose: () => void }) => {
24

3-
export const AlertComponent = ({ message, type, onAlertClose }: { message: string | null, type: string, onAlertClose: () => void }) => {
4-
55

66
return message !== null ? <Alert
77
className='mb-4'
88
color={type}
99
onDismiss={() => onAlertClose()}
1010
>
11-
<span>
11+
<span className='flex flex-wrap justify-between items-center'>
1212
<p>
1313
{message}
1414
</p>
15+
16+
{
17+
viewButton
18+
&& <p className='md:w-32 lg:w-48 text-base text-primary-700 text-right'>
19+
View more...
20+
</p>
21+
}
22+
1523
</span>
24+
1625
</Alert>
17-
: <></>
26+
: <></>
1827
}

src/components/EmptyListComponent/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactElement } from "react";
1+
import type { ReactElement } from "react";
22

33
export const EmptyListMessage = ({ message, description, buttonContent, svgComponent, onClick }
44
: {
@@ -11,12 +11,12 @@ export const EmptyListMessage = ({ message, description, buttonContent, svgCompo
1111
}) => {
1212
return (
1313
<div className='flex mt-20 justify-start items-center flex-col'>
14-
<p className='text-2xl font-bold mb-4'>{message}</p>
15-
<p className='text-lg mb-4'>{description}</p>
14+
<p className='text-2xl font-bold mb-4 text-gray-900 dark:text-white'>{message}</p>
15+
<p className='text-lg mb-4 text-gray-900 dark:text-white'>{description}</p>
1616
{
1717
buttonContent
1818
&& <button
19-
className='group flex h-min p-3 mt-10 items-center justify-center p-0.5 font-medium focus:z-10 border border-transparent enabled:hover:bg-cyan-800 dark:enabled:hover:bg-cyan-700 text-base font- text-center text-white bg-primary-700 rounded-lg hover:bg-accent-00 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800&quot;'
19+
className='group flex h-min p-3 mt-5 items-center justify-center p-0.5 font-medium focus:z-10 border border-transparent enabled:hover:bg-cyan-800 dark:enabled:hover:bg-cyan-700 text-base font- text-center text-white bg-primary-700 rounded-lg hover:bg-accent-00 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800&quot;'
2020
onClick={onClick}>
2121
{svgComponent}
2222
<span className="ml-2">{buttonContent}</span>

src/components/UserDashBoard.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import type { AxiosResponse } from "axios";
21
import { useEffect, useState } from "react";
3-
import { getUserInvitations } from "../api/invitations";
4-
import { getOrganizations } from "../api/organization";
5-
import { apiStatusCodes } from "../config/CommonConstant";
6-
import { pathRoutes } from "../config/pathRoutes";
2+
73
import { AlertComponent } from "./AlertComponent";
8-
import type { Organisation } from "./organization/interfaces";
4+
import type { AxiosResponse } from "axios";
95
import CustomAvatar from '../components/Avatar'
6+
import type { Organisation } from "./organization/interfaces";
7+
import { apiStatusCodes } from "../config/CommonConstant";
8+
import { getOrganizations } from "../api/organization";
9+
import { getUserInvitations } from "../api/invitations";
10+
import { pathRoutes } from "../config/pathRoutes";
1011

1112
const initialPageState = {
1213
pageNumber: 1,
@@ -17,6 +18,7 @@ const initialPageState = {
1718
const UserDashBoard = () => {
1819

1920
const [message, setMessage] = useState<string | null>(null)
21+
const [viewButton, setViewButton] = useState<boolean>(false)
2022
const [error, setError] = useState<string | null>(null)
2123
const [currentPage, setCurrentPage] = useState(initialPageState);
2224
const [loading, setLoading] = useState<boolean>(false)
@@ -37,6 +39,7 @@ const UserDashBoard = () => {
3739

3840
if (invitationList.length > 0) {
3941
setMessage('You have some pending received invitations')
42+
setViewButton(true)
4043
}
4144

4245
setCurrentPage({
@@ -91,6 +94,7 @@ const UserDashBoard = () => {
9194
<AlertComponent
9295
message={message ? message : error}
9396
type={message ? 'warning' : 'failure'}
97+
viewButton={viewButton}
9498
onAlertClose={() => {
9599
setMessage(null)
96100
setError(null)

src/components/organization/OrgDropDown.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import { pathRoutes } from '../../config/pathRoutes';
1212
const OrgDropDown = () => {
1313
const [orgList, setOrgList] = useState<Organisation[]>([]);
1414
const [activeOrg, setactiveOrg] = useState<Organisation | null>(null)
15-
16-
1715

1816
useEffect(() => {
1917
getAllorgs()
@@ -36,31 +34,34 @@ const OrgDropDown = () => {
3634
};
3735

3836
const setActiveOrg = async (organizations: Organisation[]) => {
39-
37+
4038
let activeOrg: Organisation | null = null
4139

4240
const orgId = await getFromLocalStorage(storageKeys.ORG_ID)
4341
if (orgId) {
4442
activeOrg = organizations?.find(org => org.id === Number(orgId)) as Organisation
4543
setactiveOrg(activeOrg || null)
46-
await setToLocalStorage(storageKeys.ORG_ID, orgId.toString());
4744
} else {
4845
activeOrg = organizations && organizations[0]
4946
setactiveOrg(activeOrg || null)
50-
await setToLocalStorage(storageKeys.ORG_ID, activeOrg.id.toString());
5147

5248
}
5349

54-
const roles: string[] = activeOrg?.userOrgRoles.map(role => role.orgRole.name)
55-
activeOrg.roles = roles
50+
if (activeOrg) {
51+
52+
await setToLocalStorage(storageKeys.ORG_ID, activeOrg.id.toString());
53+
const roles: string[] = activeOrg?.userOrgRoles.map(role => role.orgRole.name)
54+
activeOrg.roles = roles
55+
56+
await setToLocalStorage(storageKeys.ORG_ROLES, roles.toString());
57+
}
5658

57-
await setToLocalStorage(storageKeys.ORG_ROLES, roles.toString());
5859

5960
}
6061

6162
const redirectToCreateOrgModal = () => {
6263
window.location.href = '/organizations?orgModal=true';
63-
64+
6465
}
6566

6667
return (
@@ -75,8 +76,8 @@ const OrgDropDown = () => {
7576

7677
<>
7778
{
78-
activeOrg ?
79-
<>
79+
activeOrg
80+
? <>
8081
{activeOrg.logoUrl ? (
8182
<CustomAvatar size="20" src={activeOrg?.logoUrl} round />
8283
) : (
@@ -136,8 +137,8 @@ const OrgDropDown = () => {
136137
onClick={redirectToCreateOrgModal}
137138
>
138139
<svg xmlns="http://www.w3.org/2000/svg" className='pr-2 dark:text-white' width="24" height="24" fill="none" viewBox="0 0 24 24">
139-
<path fill="currentColor" d="M21.89 9.89h-7.78V2.11a2.11 2.11 0 1 0-4.22 0v7.78H2.11a2.11 2.11 0 1 0 0 4.22h7.78v7.78a2.11 2.11 0 1 0 4.22 0v-7.78h7.78a2.11 2.11 0 1 0 0-4.22Z"/>
140-
</svg>
140+
<path fill="currentColor" d="M21.89 9.89h-7.78V2.11a2.11 2.11 0 1 0-4.22 0v7.78H2.11a2.11 2.11 0 1 0 0 4.22h7.78v7.78a2.11 2.11 0 1 0 4.22 0v-7.78h7.78a2.11 2.11 0 1 0 0-4.22Z" />
141+
</svg>
141142

142143

143144
Create Organization

src/components/organization/OrganizationsList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const OrganizationsList = () => {
193193
return (
194194
<span
195195
key={index}
196-
className="m-1 bg-primary-50 text-blue-800 text-sm font-medium mr-2 px-2.5 py-0.5 rounded dark:bg-blue-900 dark:text-primary-700"
196+
className="m-1 bg-primary-50 text-blue-800 text-sm font-medium mr-2 px-2.5 py-0.5 rounded dark:bg-blue-900 dark:text-blue-300"
197197
>
198198
{role.charAt(0).toUpperCase() + role.slice(1)}
199199
</span>

src/components/organization/invitations/SendInvitationModal.tsx

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ interface Invitations {
2222

2323

2424
interface RoleI {
25-
id: number
26-
name: string
25+
id: number
26+
name: string
2727
}
2828

2929

30-
const SendInvitationModal = (props: { openModal: boolean; setMessage: (message: string)=> void ; setOpenModal: (flag: boolean)=> void }) => {
30+
const SendInvitationModal = (props: { openModal: boolean; setMessage: (message: string) => void; setOpenModal: (flag: boolean) => void }) => {
3131

3232
const [loading, setLoading] = useState<boolean>(false)
3333

@@ -47,7 +47,7 @@ const SendInvitationModal = (props: { openModal: boolean; setMessage: (message:
4747
const { data } = resRoles as AxiosResponse
4848

4949
if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
50-
50+
5151
const roles: Array<RoleI> = data?.data.response
5252

5353
const memberRole = roles.find(role => role.name === 'member')
@@ -89,7 +89,7 @@ const SendInvitationModal = (props: { openModal: boolean; setMessage: (message:
8989

9090
const sendInvitations = async () => {
9191

92-
setLoading(true)
92+
setLoading(true)
9393

9494
const invitationPayload = invitations.map(invitation => {
9595
return {
@@ -124,13 +124,13 @@ const SendInvitationModal = (props: { openModal: boolean; setMessage: (message:
124124
}>
125125
<Modal.Header>Send Invitations</Modal.Header>
126126
<Modal.Body>
127-
<AlertComponent
127+
<AlertComponent
128128
message={erroMsg}
129129
type={'error'}
130-
onAlertClose = {() => {
130+
onAlertClose={() => {
131131
setErrMsg(null)
132132
}}
133-
/>
133+
/>
134134
<Formik
135135
initialValues={initialInvitationData}
136136
validationSchema={
@@ -180,12 +180,11 @@ const SendInvitationModal = (props: { openModal: boolean; setMessage: (message:
180180

181181
<div className="w-1/3">
182182
<Button type="submit"
183-
color="gray"
184-
className='mt-6 float-right text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-700 dark:hover:bg-primary-700 dark:focus:ring-primary-800'
185-
><svg className="pr-2" xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" viewBox="0 0 24 24">
186-
<path fill="#fff" d="M21.89 9.89h-7.78V2.11a2.11 2.11 0 1 0-4.22 0v7.78H2.11a2.11 2.11 0 1 0 0 4.22h7.78v7.78a2.11 2.11 0 1 0 4.22 0v-7.78h7.78a2.11 2.11 0 1 0 0-4.22Z"/>
187-
</svg>
188-
183+
className='mt-6 text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800'
184+
><svg className="pr-2" xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" viewBox="0 0 24 24">
185+
<path fill="#fff" d="M21.89 9.89h-7.78V2.11a2.11 2.11 0 1 0-4.22 0v7.78H2.11a2.11 2.11 0 1 0 0 4.22h7.78v7.78a2.11 2.11 0 1 0 4.22 0v-7.78h7.78a2.11 2.11 0 1 0 0-4.22Z" />
186+
</svg>
187+
189188
ADD
190189
</Button>
191190
</div>
@@ -197,10 +196,10 @@ const SendInvitationModal = (props: { openModal: boolean; setMessage: (message:
197196
)}
198197

199198
</Formik>
200-
{
201-
invitations.length > 0 &&
202-
<div>
203-
<div
199+
200+
<div>
201+
{
202+
invitations.length > 0 && <div
204203
className="p-2 my-2 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-2 dark:bg-gray-800"
205204
>
206205
<ul className="divide-y divide-gray-200 dark:divide-gray-700">
@@ -248,19 +247,19 @@ const SendInvitationModal = (props: { openModal: boolean; setMessage: (message:
248247
}
249248
</ul>
250249
</div>
251-
<div className="mt-4 flex justify-end">
252-
<Button
253-
onClick={sendInvitations}
254-
isProcessing={loading}
255-
className='text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800"'
256-
>
257-
Send
258-
</Button>
259-
</div>
250+
}
251+
252+
<div className="mt-4 flex justify-end">
253+
<Button
254+
onClick={sendInvitations}
255+
disabled={invitations.length === 0}
256+
isProcessing={loading}
257+
className='text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800"'
258+
>
259+
Send
260+
</Button>
260261
</div>
261-
262-
}
263-
262+
</div>
264263

265264
</Modal.Body>
266265

0 commit comments

Comments
 (0)