Skip to content

Commit

Permalink
Add preferred contact mode for teams/committees
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljames-dj committed May 2, 2024
1 parent 0ae6062 commit 6e25cbe
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 5 deletions.
6 changes: 6 additions & 0 deletions app/models/groups_metadata_teams_committees.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
class GroupsMetadataTeamsCommittees < ApplicationRecord
has_one :user_group, as: :metadata

enum :preferred_contact_mode, {
no_public_way: "no_public_way",
email: "email",
contact_form: "contact_form",
}

def self.at_least_senior_member?(role)
[
RolesMetadataTeamsCommittees.statuses[:senior_member],
Expand Down
25 changes: 22 additions & 3 deletions app/webpacker/components/TeamsCommitteesCouncils/GroupPage.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import React from 'react';
import { Header } from 'semantic-ui-react';
import { Button, Header } from 'semantic-ui-react';
import EmailButton from '../EmailButton';
import { apiV0Urls } from '../../lib/requests/routes.js.erb';
import { apiV0Urls, contactRecipientUrl } from '../../lib/requests/routes.js.erb';
import I18n from '../../lib/i18n';
import useLoadedData from '../../lib/hooks/useLoadedData';
import Loading from '../Requests/Loading';
import Errored from '../Requests/Errored';
import RolesTable from './RolesTable';

function contactRecipientUrlForGroup(group) {
if (group.metadata.friendly_id === 'wrt') {
return contactRecipientUrl('results_team');
}
return contactRecipientUrl('communications_team');
}

export default function GroupPage({ group, canViewPastRoles }) {
const {
data: activeRoles,
Expand All @@ -26,7 +33,19 @@ export default function GroupPage({ group, canViewPastRoles }) {
return (
<>
<p>{I18n.t(`page.teams_committees_councils.groups_description.${group.metadata.friendly_id}`)}</p>
<EmailButton email={group.metadata.email} />
{
(
!group.metadata.preferred_contact_mode || group.metadata.preferred_contact_mode === 'email'
) && <EmailButton email={group.metadata.email} />
}
{
group.metadata.preferred_contact_mode === 'contact_form'
&& (
<Button href={contactRecipientUrlForGroup(group)}>
{I18n.t('page.teams_committees_councils.contact_button')}
</Button>
)
}
<RolesTable roleList={activeRoles} />
{canViewPastRoles && (
<>
Expand Down
2 changes: 2 additions & 0 deletions app/webpacker/lib/requests/routes.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ export const editUserAvatarUrl = (userId) => `<%= CGI.unescape(Rails.application

export const contactUrl = `<%= CGI.unescape(Rails.application.routes.url_helpers.contact_path) %>`

export const contactRecipientUrl = (contactRecipient) => `<%= CGI.unescape(Rails.application.routes.url_helpers.contact_path(contactRecipient: "${contactRecipient}")) %>`

export const apiV0Urls = {
users: {
me: {
Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ en:
teams_committees_councils:
title: "WCA Teams, Committees, and Councils"
description: "The WCA's teams and committees are an integral part of the organization and perform the day-to-day tasks that are required to keep it functioning. These committees are made up of WCA community members, including WCA Delegates and competitors. Each team has a leader, whose role is to ensure the proper functioning of the team and guide other team members. Councils are a special type of team that serve an advisory role to the WCA Board and are made up of community members, not WCA Staff members. When there are committee, team, or council openings, information about how to apply is posted on the front page."
contact_button: "Contact"
groups_name:
wat: "WCA Archive Team"
wct: "WCA Communication Team"
Expand Down Expand Up @@ -788,7 +789,7 @@ en:
wac: "The WAC is responsible for maintaining feedback and communication between the WCA Community and the WCA Staff. They maintain the WCA Forums and summarize surveys and attempt to increase reach across the worldwide community."
contacts:
title: "WCA Contact Form"
faq_note_html: 'Before making an inquiry, you may wish to take a look at our <a href="/faq">Frequently Asked Questions</a>! If you wish to contact a specific committee or team not listed here, you can find their contact information on <a href="/teams-committees-councils">this page</a>.'
faq_note_html: 'Before making an inquiry, you may wish to take a look at our <a href="/faq">Frequently Asked Questions</a>! If you wish to contact a specific committee or team not listed here, you can find their contact information on <a href="/teams-committees-councils">this page</a> (Some committee/team might have also opted out from contacting, you will not be able to contact them).'
form:
user_data:
name:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class AddPreferredContactModeToGroupsMetadataTeamsCommittees < ActiveRecord::Migration[7.1]
def change
add_column :groups_metadata_teams_committees, :preferred_contact_mode, :string, null: false
change_column_default :groups_metadata_teams_committees, :preferred_contact_mode, GroupsMetadataTeamsCommittees.preferred_contact_modes[:email]
UserGroup.teams_committees_group_wrt.metadata.update!(preferred_contact_mode: GroupsMetadataTeamsCommittees.preferred_contact_modes[:contact_form])
UserGroup.teams_committees_group_wct.metadata.update!(preferred_contact_mode: GroupsMetadataTeamsCommittees.preferred_contact_modes[:contact_form])
UserGroup.teams_committees_group_wcat.metadata.update!(preferred_contact_mode: GroupsMetadataTeamsCommittees.preferred_contact_modes[:no_public_way])
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_04_24_033200) do
ActiveRecord::Schema[7.1].define(version: 2024_05_02_013953) do
create_table "Competitions", id: { type: :string, limit: 32, default: "" }, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "name", limit: 50, default: "", null: false
t.string "cityName", limit: 50, default: "", null: false
Expand Down Expand Up @@ -737,6 +737,7 @@
t.string "friendly_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "preferred_contact_mode", default: "email", null: false
end

create_table "groups_metadata_translators", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
Expand Down
1 change: 1 addition & 0 deletions lib/database_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ def self.actions_to_column_sanitizers(columns_by_action)
id
email
friendly_id
preferred_contact_mode
created_at
updated_at
),
Expand Down

0 comments on commit 6e25cbe

Please sign in to comment.