Skip to content

Commit

Permalink
added eventsattended in user portal
Browse files Browse the repository at this point in the history
  • Loading branch information
duplixx committed Oct 11, 2024
1 parent 5738fd6 commit 3263112
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 116 deletions.
Binary file modified dump.rdb
Binary file not shown.
2 changes: 2 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@
"article": "Article"
},
"settings": {
"eventAttended":"Events Attended",
"noEventsAttended":"No Events Attended",
"profileSettings": "Profile Settings",
"gender": "Gender",
"phoneNumber": "Phone Number",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@
"article": "Article"
},
"settings": {
"eventAttended":"Événements Assistés",
"noEventsAttended":"Aucun événement assisté",
"profileSettings": "Paramètres de profil",
"gender": "Genre",
"phoneNumber": "Numéro de téléphone",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/hi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@
"article": "लेख"
},
"settings": {
"noEventsAttended": "कोई कार्यक्रम में उपस्थित नहीं",
"eventAttended": "भाग लिए गए कार्यक्रम",
"profileSettings": "पार्श्वचित्र समायोजन",
"gender": "लिंग",
"phoneNumber": "फ़ोन नंबर",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/sp/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,8 @@
},
"settings": {
"settings": "Ajustes",
"eventAttended":"Événements Assistés",
"noEventsAttended":"Ningún evento asistido",
"profileSettings": "Configuración de perfil",
"firstName": "Nombre de pila",
"lastName": "Apellido",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@
"article": "文章"
},
"settings": {
"noEventsAttended": "未参加任何活动",
"eventAttended":"参加的活动",
"profileSettings": "配置文件设置",
"gender": "性别",
"phoneNumber": "电话号码",
Expand Down
3 changes: 3 additions & 0 deletions src/GraphQl/Queries/Queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export const CHECK_AUTH = gql`
state
countryCode
}
eventsAttended {
_id
}
}
}
`;
Expand Down
36 changes: 24 additions & 12 deletions src/components/DynamicDropDown/DynamicDropDown.tsx
Original file line number Diff line number Diff line change
@@ -1,48 +1,60 @@
import React from 'react';
import { Dropdown } from 'react-bootstrap';
import styles from './DynamicDropDown.module.css';
import type { InterfaceMember } from 'components/EventManagement/EventAttendance/InterfaceEvents';

interface InterfaceChangeDropDownProps {
parentContainerStyle?: string;
btnStyle?: string;
btnTextStyle?: string;
setFormState: React.Dispatch<React.SetStateAction<any>>;
setFormState: React.Dispatch<React.SetStateAction<InterfaceMember>>;
formState: any;
fieldOptions: { value: string; label: string }[]; // Field options for dropdown
fieldName: string; // Field name for labeling
fieldOptions: { value: string; label: string }[];
fieldName: string;
handleChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
}

const DynamicDropDown = (props: InterfaceChangeDropDownProps): JSX.Element => {
const handleFieldChange = (value: string): void => {
props.setFormState({ ...props.formState, [props.fieldName]: value });
if (props?.handleChange) {
const event = {
target: {
name: props?.fieldName,
value: value,
},
} as React.ChangeEvent<HTMLSelectElement>;
props?.handleChange(event);
} else {
props?.setFormState({ ...props?.formState, [props?.fieldName]: value });
}
};

const getLabel = (value: string): string => {
const selectedOption = props.fieldOptions.find(
const selectedOption = props?.fieldOptions.find(
(option) => option.value === value,
);
return selectedOption ? selectedOption.label : `None`;
};

return (
<Dropdown
title={`Select ${props.fieldName}`}
title={`Select ${props?.fieldName}`}
className={`${props?.parentContainerStyle ?? ''} m-2`}
data-testid={`${props.fieldName.toLowerCase()}-dropdown-container`}
data-testid={`${props?.fieldName.toLowerCase()}-dropdown-container`}
>
<Dropdown.Toggle
className={`${props?.btnStyle ?? 'w-100'} ${styles.dropwdownToggle}`}
data-testid={`${props.fieldName.toLowerCase()}-dropdown-btn`}
data-testid={`${props?.fieldName.toLowerCase()}-dropdown-btn`}
>
{getLabel(props.formState[props.fieldName])}
{getLabel(props?.formState[props?.fieldName])}
</Dropdown.Toggle>
<Dropdown.Menu>
{props.fieldOptions.map((option, index: number) => (
{props?.fieldOptions.map((option, index: number) => (
<Dropdown.Item
key={`${props.fieldName.toLowerCase()}-dropdown-item-${index}`}
key={`${props?.fieldName.toLowerCase()}-dropdown-item-${index}`}
className={`dropdown-item`}
onClick={() => handleFieldChange(option.value)}
data-testid={`change-${props.fieldName.toLowerCase()}-btn-${option.value}`}
data-testid={`change-${props?.fieldName.toLowerCase()}-btn-${option.value}`}
>
{option.label}
</Dropdown.Item>
Expand Down
17 changes: 17 additions & 0 deletions src/screens/MemberDetail/MemberDetail.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@
left: 20px;
cursor: pointer;
}
.selectWrapper {
position: relative;
}

.selectWithChevron {
appearance: none;
padding-right: 30px;
}

.selectWrapper::after {
content: '\25BC';
position: absolute;
top: 50%;
right: 10px;
transform: translateY(-50%);
pointer-events: none;
}

.sidebar:after {
content: '';
Expand Down
46 changes: 27 additions & 19 deletions src/screens/MemberDetail/MemberDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,22 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
}, []);

const handleChange = async (
e: React.ChangeEvent<HTMLInputElement>,
e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>,
): Promise<void> => {
const { name, files } = e.target;
if (name === 'photo' && files && files[0]) {
const file = files[0];
const { name, value } = e.target;
if (
name === 'photo' &&
'files' in e.target &&
e.target.files &&
e.target.files[0]
) {
const file = e.target.files[0];
const base64 = await convertToBase64(file);
setFormState((prevState) => ({
...prevState,
image: base64 as string,
}));
} else {
const { value } = e.target;
setFormState((prevState) => ({
...prevState,
[name]: value,
Expand Down Expand Up @@ -351,6 +355,7 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
setFormState={setFormState}
fieldOptions={genderEnum}
fieldName="gender"
handleChange={handleChange}
/>
</Col>
<Col md={6}>
Expand Down Expand Up @@ -380,6 +385,7 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
setFormState={setFormState}
fieldOptions={educationGradeEnum}
fieldName="grade"
handleChange={handleChange}
/>
</Col>
<Col md={6}>
Expand All @@ -391,6 +397,7 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
setFormState={setFormState}
fieldOptions={employmentStatusEnum}
fieldName="empStatus"
handleChange={handleChange}
/>
</Col>
<Col md={6}>
Expand All @@ -402,6 +409,7 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
setFormState={setFormState}
fieldOptions={maritalStatusEnum}
fieldName="maritalStatus"
handleChange={handleChange}
/>
</Col>
</Row>
Expand Down Expand Up @@ -459,20 +467,6 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
onChange={handleChange}
/>
</Col>
<Col md={12}>
<label htmlFor="country" className="form-label">
{t('countryCode')}
</label>
<input
id="country"
value={formState.country}
className={`form-control ${styles.inputColor}`}
type="text"
name="country"
onChange={handleChange}
placeholder={t('countryCode')}
/>
</Col>
<Col md={6}>
<label htmlFor="city" className="form-label">
{t('city')}
Expand Down Expand Up @@ -500,6 +494,20 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
onChange={handleChange}
/>
</Col>
<Col md={12}>
<label htmlFor="country" className="form-label">
{t('countryCode')}
</label>
<input
id="country"
value={formState.country}
className={`form-control ${styles.inputColor}`}
type="text"
name="country"
onChange={handleChange}
placeholder={t('countryCode')}
/>
</Col>
</Row>
</Card.Body>
</Card>
Expand Down
6 changes: 5 additions & 1 deletion src/screens/UserPortal/Settings/Settings.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
font-size: 1.2rem;
font-weight: 600;
}

.scrollableCardBody{
height: 220px;
overflow-y: scroll;
}
.cardHeader {
padding: 1.25rem 1rem 1rem 1rem;
border-bottom: 1px solid var(--bs-gray-200);
Expand All @@ -37,6 +40,7 @@
padding: 1.25rem 1rem 1.5rem 1rem;
display: flex;
flex-direction: column;
overflow-y: scroll;
}

.cardLabel {
Expand Down
Loading

0 comments on commit 3263112

Please sign in to comment.