Skip to content

Commit

Permalink
Renamed Private Organisation to userRegistrationRequired (PalisadoesF…
Browse files Browse the repository at this point in the history
…oundation#1384)

* Rename isPublic to userRegistrationRequired

* Convert Private Orgs to userRegistrationRequired Orgs

* Fixes failed test
  • Loading branch information
aialok authored Jan 13, 2024
1 parent ef2ad96 commit 16de771
Show file tree
Hide file tree
Showing 21 changed files with 83 additions and 68 deletions.
4 changes: 2 additions & 2 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"createSampleOrganization": "Create Sample Organization",
"description": "Description",
"location": "Location",
"isPublic": "Is Public",
"userRegistrationRequired": "User Registration Required",
"visibleInSearch": "Visible In Search",
"displayImage": "Display Image",
"enterName": "Enter Name",
Expand Down Expand Up @@ -486,7 +486,7 @@
"description": "Description",
"location": "Location",
"displayImage": "Display Image",
"isPublic": "Public",
"userRegistrationRequired": "User Registration Required",
"isVisibleInSearch": "Visible in Search",
"saveChanges": "Save Changes",
"enterNameOrganization": "Enter Organization Name",
Expand Down
4 changes: 2 additions & 2 deletions public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"createSampleOrganization": "Créer une organisation d'exemple",
"description": "La description",
"location": "Emplacement",
"isPublic": "Est publique",
"userRegistrationRequired": "enregistrement requis",
"visibleInSearch": "Visible dans la recherche",
"displayImage": "Afficher l'image",
"enterName": "Entrez le nom",
Expand Down Expand Up @@ -484,7 +484,7 @@
"description": "La description",
"location": "emplacement",
"displayImage": "Afficher l'image",
"isPublic": "Public",
"userRegistrationRequired": "enregistrement requis",
"isVisibleInSearch": "Visible dans la recherche",
"saveChanges": "Sauvegarder les modifications",
"enterNameOrganization": "Entrez le nom de l'organisation",
Expand Down
4 changes: 2 additions & 2 deletions public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"createSampleOrganization": " सैंपल संगठन बनाएं",
"description": "विवरण",
"location": "स्थान",
"isPublic": "सार्वजनिक है",
"userRegistrationRequired": "उपयोगकर्ता पंजीकरण आवश्यक",
"visibleInSearch": "खोज में दृश्यमान",
"displayImage": "प्रदर्शन छवि",
"enterName": "नाम दर्ज करें",
Expand Down Expand Up @@ -483,7 +483,7 @@
"description": "विवरण",
"location": "जगह",
"displayImage": "प्रदर्शन छवि",
"isPublic": "सार्वजनिक",
"userRegistrationRequired": "उपयोगकर्ता पंजीकरण आवश्यक",
"isVisibleInSearch": "खोज में दिखाए जा सकते हैं",
"saveChanges": "परिवर्तनों को सुरक्षित करें",
"cancel": "रद्द करना",
Expand Down
4 changes: 2 additions & 2 deletions public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"createSampleOrganization": "Crear organización de muestra",
"description": "Descripción",
"location": "Ubicación",
"isPublic": "Es público",
"userRegistrationRequired": "Registro de usuario requerido",
"visibleInSearch": "Visible en la búsqueda",
"displayImage": "Mostrar imagen",
"enterName": "Ingrese su nombre",
Expand Down Expand Up @@ -483,7 +483,7 @@
"description": "Descripción",
"location": "ubicación",
"displayImage": "Mostrar imagen",
"isPublic": "Público",
"userRegistrationRequired": "Registro de usuario requerido",
"isVisibleInSearch": "Visible en la búsqueda",
"saveChanges": "Guardar cambios",
"cancel": "Cancelar",
Expand Down
4 changes: 2 additions & 2 deletions public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"createSampleOrganization": "创建示范组织",
"description": "描述",
"location": "地點",
"isPublic": "是否公開",
"isPubluserRegistrationRequiredic": "需要用户注册",
"visibleInSearch": "在搜索中可見",
"displayImage": "顯示圖像",
"enterName": "输入名字",
Expand Down Expand Up @@ -483,7 +483,7 @@
"description": "描述",
"location": "地點",
"displayImage": "顯示圖像",
"isPublic": "公开",
"userRegistrationRequired": "需要用户注册",
"isVisibleInSearch": "在搜索中可见",
"saveChanges": "保存更改",
"cancel": "取消",
Expand Down
10 changes: 5 additions & 5 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ type Organization {
creator: User!
description: String!
image: String
isPublic: Boolean!
userRegistrationRequired: Boolean!
location: String
members: [User]
membershipRequests: [MembershipRequest]
Expand All @@ -566,7 +566,7 @@ type OrganizationInfoNode {
creator: User!
description: String!
image: String
isPublic: Boolean!
userRegistrationRequired: Boolean!
name: String!
visibleInSearch: Boolean!
}
Expand All @@ -576,7 +576,7 @@ input OrganizationInput {
attendees: String
description: String!
image: String
isPublic: Boolean!
userRegistrationRequired: Boolean!
location: String
name: String!
visibleInSearch: Boolean!
Expand Down Expand Up @@ -614,7 +614,7 @@ input OrganizationWhereInput {
id_not: ID
id_not_in: [ID!]
id_starts_with: ID
isPublic: Boolean
userRegistrationRequired: Boolean
name: String
name_contains: String
name_in: [String!]
Expand Down Expand Up @@ -949,7 +949,7 @@ input UpdateEventProjectInput {

input UpdateOrganizationInput {
description: String
isPublic: Boolean
userRegistrationRequired: Boolean
location: String
name: String
visibleInSearch: Boolean
Expand Down
8 changes: 4 additions & 4 deletions src/GraphQl/Mutations/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const UPDATE_ORGANIZATION_MUTATION = gql`
$name: String
$description: String
$location: String
$isPublic: Boolean
$userRegistrationRequired: Boolean
$visibleInSearch: Boolean
$file: String
) {
Expand All @@ -59,7 +59,7 @@ export const UPDATE_ORGANIZATION_MUTATION = gql`
data: {
name: $name
description: $description
isPublic: $isPublic
userRegistrationRequired: $userRegistrationRequired
visibleInSearch: $visibleInSearch
location: $location
}
Expand Down Expand Up @@ -185,7 +185,7 @@ export const CREATE_ORGANIZATION_MUTATION = gql`
$location: String!
$name: String!
$visibleInSearch: Boolean!
$isPublic: Boolean!
$userRegistrationRequired: Boolean!
$image: String
) {
createOrganization(
Expand All @@ -194,7 +194,7 @@ export const CREATE_ORGANIZATION_MUTATION = gql`
location: $location
name: $name
visibleInSearch: $visibleInSearch
isPublic: $isPublic
userRegistrationRequired: $userRegistrationRequired
}
file: $image
) {
Expand Down
4 changes: 2 additions & 2 deletions src/GraphQl/Queries/Queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const ORGANIZATIONS_LIST = gql`
name
description
location
isPublic
userRegistrationRequired
visibleInSearch
members {
_id
Expand Down Expand Up @@ -646,7 +646,7 @@ export const USER_ORGANIZATION_CONNECTION = gql`
name
image
description
isPublic
userRegistrationRequired
creator {
firstName
lastName
Expand Down
2 changes: 1 addition & 1 deletion src/components/Advertisements/Advertisements.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const ORGANIZATIONS_LIST_MOCK = {
},
name: 'name',
description: 'description',
isPublic: true,
userRegistrationRequired: true,

visibleInSearch: true,
location: 'location',
Expand Down
4 changes: 2 additions & 2 deletions src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const MOCKS = [
name: 'Test Organization',
description: 'Testing this organization',
location: 'Gotham, DC',
isPublic: true,
userRegistrationRequired: true,
visibleInSearch: true,
members: [
{
Expand Down Expand Up @@ -143,7 +143,7 @@ const MOCKS_WITH_IMAGE = [
name: 'Test Organization',
description: 'Testing this organization',
location: 'Gotham, DC',
isPublic: true,
userRegistrationRequired: true,
visibleInSearch: true,
members: [
{
Expand Down
21 changes: 12 additions & 9 deletions src/components/OrgUpdate/OrgUpdate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Testing Organization Update', () => {
description: 'This is a updated description',
location: 'This is updated location',
displayImage: new File(['hello'], 'hello.png', { type: 'image/png' }),
isPublic: false,
userRegistrationRequired: false,
isVisible: true,
};

Expand All @@ -54,21 +54,22 @@ describe('Testing Organization Update', () => {
expect(screen.getByText('Description')).toBeInTheDocument();
expect(screen.getByText('Location')).toBeInTheDocument();
expect(screen.getByText('Display Image:')).toBeInTheDocument();
expect(screen.getByText('Public:')).toBeInTheDocument();
expect(screen.getByText(/Registration/)).toBeInTheDocument();
expect(screen.getByText('Visible in Search:')).toBeInTheDocument();

// Get the input fields, and btns
const name = screen.getByPlaceholderText(/Enter Organization Name/i);
const des = screen.getByPlaceholderText(/Description/i);
const location = screen.getByPlaceholderText(/Location/i);
const isPublic = screen.getByPlaceholderText(/Public/i);
const userRegistrationRequired =
screen.getByPlaceholderText(/Registration/i);
const isVisible = screen.getByPlaceholderText(/Visible/i);

// Checking if form fields got updated according to the mock data
expect(name).toHaveValue('Palisadoes');
expect(des).toHaveValue('Equitable Access to STEM Education Jobs');
expect(location).toHaveValue('Jamaica');
expect(isPublic).toBeChecked();
expect(userRegistrationRequired).toBeChecked();
expect(isVisible).not.toBeChecked();
});

Expand All @@ -90,7 +91,8 @@ describe('Testing Organization Update', () => {
const des = screen.getByPlaceholderText(/Description/i);
const location = screen.getByPlaceholderText(/Location/i);
const displayImage = screen.getByPlaceholderText(/Display Image/i);
const isPublic = screen.getByPlaceholderText(/Public/i);
const userRegistrationRequired =
screen.getByPlaceholderText(/Registration/i);
const isVisible = screen.getByPlaceholderText(/Visible/i);
const saveChangesBtn = screen.getByText(/Save Changes/i);

Expand All @@ -104,7 +106,7 @@ describe('Testing Organization Update', () => {
userEvent.type(des, formData.description);
userEvent.type(location, formData.location);
userEvent.upload(displayImage, formData.displayImage);
userEvent.click(isPublic);
userEvent.click(userRegistrationRequired);
userEvent.click(isVisible);

await wait();
Expand All @@ -115,7 +117,7 @@ describe('Testing Organization Update', () => {
expect(des).toHaveValue(formData.description);
expect(location).toHaveValue(formData.location);
expect(displayImage).toBeTruthy();
expect(isPublic).not.toBeChecked();
expect(userRegistrationRequired).not.toBeChecked();
expect(isVisible).toBeChecked();
});

Expand Down Expand Up @@ -151,7 +153,8 @@ describe('Testing Organization Update', () => {
const des = screen.getByPlaceholderText(/Description/i);
const location = screen.getByPlaceholderText(/Location/i);
const displayImage = screen.getByPlaceholderText(/Display Image/i);
const isPublic = screen.getByPlaceholderText(/Public/i);
const userRegistrationRequired =
screen.getByPlaceholderText(/Registration/i);
const isVisible = screen.getByPlaceholderText(/Visible/i);
const saveChangesBtn = screen.getByText(/Save Changes/i);

Expand All @@ -165,7 +168,7 @@ describe('Testing Organization Update', () => {
userEvent.type(des, formData.description);
userEvent.type(location, formData.location);
userEvent.upload(displayImage, formData.displayImage);
userEvent.click(isPublic);
userEvent.click(userRegistrationRequired);
userEvent.click(isVisible);

await wait();
Expand Down
23 changes: 16 additions & 7 deletions src/components/OrgUpdate/OrgUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element {
orgImage: null,
});

const [publicchecked, setPublicChecked] = React.useState(false);
const [userRegistrationRequiredChecked, setuserRegistrationRequiredChecked] =
React.useState(false);
const [visiblechecked, setVisibleChecked] = React.useState(false);

const [login] = useMutation(UPDATE_ORGANIZATION_MUTATION);
Expand Down Expand Up @@ -69,7 +70,9 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element {
orgDescrip: data.organizations[0].description,
location: data.organizations[0].location,
});
setPublicChecked(data.organizations[0].isPublic);
setuserRegistrationRequiredChecked(
data.organizations[0].userRegistrationRequired
);
setVisibleChecked(data.organizations[0].visibleInSearch);
}
return () => {
Expand All @@ -85,7 +88,7 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element {
name: formState.orgName,
description: formState.orgDescrip,
location: formState.location,
isPublic: publicchecked,
userRegistrationRequired: userRegistrationRequiredChecked,
visibleInSearch: visiblechecked,
file: formState.orgImage,
},
Expand Down Expand Up @@ -165,11 +168,17 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element {
/>
<Row>
<Col sm={6} className="d-flex mb-3">
<Form.Label className="me-3">{t('isPublic')}:</Form.Label>
<Form.Label className="me-3">
{t('userRegistrationRequired')}:
</Form.Label>
<Form.Switch
placeholder={t('isPublic')}
checked={publicchecked}
onChange={(): void => setPublicChecked(!publicchecked)}
placeholder={t('userRegistrationRequired')}
checked={userRegistrationRequiredChecked}
onChange={(): void =>
setuserRegistrationRequiredChecked(
!userRegistrationRequiredChecked
)
}
/>
</Col>
<Col sm={6} className="d-flex mb-3">
Expand Down
10 changes: 5 additions & 5 deletions src/components/OrgUpdate/OrgUpdateMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const MOCKS = [
name: 'Palisadoes',
description: 'Equitable Access to STEM Education Jobs',
location: 'Jamaica',
isPublic: true,
userRegistrationRequired: true,
visibleInSearch: false,
creator: {
firstName: 'John',
Expand Down Expand Up @@ -60,7 +60,7 @@ export const MOCKS = [
description: 'This is an updated test organization',
location: 'Updated location',
image: new File(['hello'], 'hello.png', { type: 'image/png' }),
isPublic: true,
userRegistrationRequired: true,
visibleInSearch: false,
},
},
Expand All @@ -71,7 +71,7 @@ export const MOCKS = [
name: 'Updated Organization',
description: 'This is an updated test organization',
location: 'Updated location',
isPublic: true,
userRegistrationRequired: true,
visibleInSearch: false,
},
},
Expand Down Expand Up @@ -104,7 +104,7 @@ export const MOCKS_ERROR_UPDATE_ORGLIST = [
name: 'Palisadoes',
description: 'Equitable Access to STEM Education Jobs',
location: 'Jamaica',
isPublic: true,
userRegistrationRequired: true,
visibleInSearch: false,
creator: {
firstName: 'John',
Expand Down Expand Up @@ -148,7 +148,7 @@ export const MOCKS_ERROR_UPDATE_ORGLIST = [
description: 'This is an updated test organization',
location: 'Updated location',
image: new File(['hello'], 'hello.png', { type: 'image/png' }),
isPublic: true,
userRegistrationRequired: true,
visibleInSearch: false,
},
},
Expand Down
Loading

0 comments on commit 16de771

Please sign in to comment.