Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add notification section #567

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ questions on the channel #project-skillz in the Zenika's Slack.
# Table of contents

1. [Skillz web app](#skillzwebapp)
1. [Requirements](#requirements)
2. [Quick Start](#quickstart)
1. [Docker](#docker)
2. [Install dependencies](#dependencies)
3. [Create an .env file](#.env)
4. [Run postgres and hasura locally with docker](#postgres)
5. [Run the hasura migrations](#hasuramigrations)
6. [Develop with hasura](#devhasura)
7. [Launch the app](#launch)
8. [Generate local seeds](#localseeds)
3. [Tests](#tests)
1. [E2E with Cypress](#e2e)
2. [Management rules](#managementrules)
1. [Requirements](#requirements)
2. [Quick Start](#quickstart)
1. [Docker](#docker)
2. [Install dependencies](#dependencies)
3. [Create an .env file](#.env)
4. [Run postgres and hasura locally with docker](#postgres)
5. [Run the hasura migrations](#hasuramigrations)
6. [Develop with hasura](#devhasura)
7. [Launch the app](#launch)
8. [Generate local seeds](#localseeds)
3. [Tests](#tests)
1. [E2E with Cypress](#e2e)
2. [Management rules](#managementrules)
2. [Skillz Slack bot](#slackbot)
1. [Documentation](#documentation)
2. [Development](#development)
1. [Configuration](#configuration)
2. [Versionning](#versionning)
1. [Documentation](#documentation)
2. [Development](#development)
1. [Configuration](#configuration)
2. [Versionning](#versionning)
3. [Github](#github)
1. [Actions](#actions)
1. [Update referentials](#update-referentials)
2. [Dependabot](#dependabot)
1. [Actions](#actions)
1. [Update referentials](#update-referentials)
2. [Dependabot](#dependabot)

# Skillz web app <a name="skillzwebapp"></a>

Expand Down
4 changes: 4 additions & 0 deletions doc/rg.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
### MG_TUTORIAL_MODE

> If the user has no skill in base, the tutorial mode will be automatically set as true

### MG_NOTIFICATIONS

> If admin approve a skill added by a user, the user receive a notification
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> If admin approve a skill added by a user, the user receive a notification
> If admin approves a skill added by a user, the user receives a notification

typo

49 changes: 46 additions & 3 deletions hasura/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@
check: {}
columns:
- categoryId
- creator
- id
- verified
- name
- verified
select_permissions:
- role: world
permission:
columns:
- categoryId
- creator
- description
- id
- name
Expand Down Expand Up @@ -523,6 +525,47 @@
- agency
filter: {}
allow_aggregations: true
- table:
name: UserNotifications
schema: public
object_relationships:
- name: skill
using:
manual_configuration:
column_mapping:
skill_id: id
insertion_order: null
remote_table:
name: Skill
schema: public
insert_permissions:
- role: world
permission:
check: {}
columns:
- admin_email
- checked
- created_at
- skill_id
- user_email
select_permissions:
- role: world
permission:
columns:
- admin_email
- checked
- created_at
- id
- skill_id
- user_email
filter: {}
update_permissions:
- role: world
permission:
columns:
- checked
filter: {}
check: null
- table:
name: UserSkillDesire
schema: public
Expand Down Expand Up @@ -583,7 +626,7 @@
definition:
enable_manual: false
insert:
columns: '*'
columns: "*"
retry_conf:
interval_sec: 30
num_retries: 5
Expand Down Expand Up @@ -645,7 +688,7 @@
definition:
enable_manual: false
insert:
columns: '*'
columns: "*"
retry_conf:
interval_sec: 30
num_retries: 5
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE "public"."UserNotifications";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE "public"."UserNotifications" ("id" uuid NOT NULL, "checked" boolean NOT NULL, "user_email" text NOT NULL, PRIMARY KEY ("id") , UNIQUE ("id"));COMMENT ON TABLE "public"."UserNotifications" IS E'Skill verified - last skills';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."UserNotifications" add column "created_at" date
-- not null default now();
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."UserNotifications" add column "created_at" date
not null default now();
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."UserNotifications" add column "skill_id" uuid
-- not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."UserNotifications" add column "skill_id" uuid
not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."UserNotifications" add column "notification_type" text
-- not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."UserNotifications" add column "notification_type" text
not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment on table "public"."UserNotifications" is NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment on table "public"."UserNotifications" is NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."UserNotifications" add column "admin_email" text
-- not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."UserNotifications" add column "admin_email" text
not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."Skill" add column "creator" text
-- null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."Skill" add column "creator" text
null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."UserNotifications" add column "notification_id" uuid
-- not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."UserNotifications" add column "notification_id" uuid
not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "public"."UserNotifications" ALTER COLUMN "id" drop default;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."UserNotifications" alter column "id" set default gen_random_uuid();
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."UserNotifications" alter column "notification_type" drop not null;
alter table "public"."UserNotifications" add column "notification_type" text;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."UserNotifications" drop column "notification_type" cascade;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."UserNotifications" alter column "notification_id" drop not null;
alter table "public"."UserNotifications" add column "notification_id" uuid;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."UserNotifications" drop column "notification_id" cascade;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."UserNotifications" add column "notification_id" integer
-- not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."UserNotifications" add column "notification_id" integer
not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."Notifications" rename to "UserNotifications";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."UserNotifications" rename to "Notifications";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."UserNotifications" rename to "Notifications";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."Notifications" rename to "UserNotifications";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."UserNotifications" alter column "notification_id" drop not null;
alter table "public"."UserNotifications" add column "notification_id" int4;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."UserNotifications" drop column "notification_id" cascade;
7 changes: 7 additions & 0 deletions i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default {
profile: "Profile",
language: "Language",
darkMode: "Dark mode",
notifications: "Notifications",
logout: "Logout",
tutorial: "Tutorial mode",
botNotifications: "Slack bot notifications",
Expand Down Expand Up @@ -123,6 +124,12 @@ export default {
},
},
},
notification: {
notificationText:
"Admin adminMail has approved your skill skillName as new Skillz's skills.",
new: "New",
notificationTypeAccepted: "One of your skill has been accepted",
},
loading: {
loadingText: "Loading...",
},
Expand Down
7 changes: 7 additions & 0 deletions i18n/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default {
profile: "Profil",
language: "Langue",
darkMode: "Mode sombre",
notifications: "Notifications",
logout: "Se déconnecter",
tutorial: "Mode tutoriel",
botNotifications: "Notifications du bot Slack",
Expand Down Expand Up @@ -122,6 +123,12 @@ export default {
},
},
},
notification: {
notificationText:
"L'administrateur adminMail a approuvé votre compétence skillName comme nouvelle compétence Skillz",
new: "Nouveau",
notificationTypeAccepted: "Une de tes compétence a été acceptée",
},
Comment on lines +126 to +131
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird to have the you "singular" and "plurial" on the same page.

loading: {
loadingText: "Chargement...",
},
Expand Down
14 changes: 8 additions & 6 deletions src/components/organisms/AddSkilListSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { useMutation, useQuery } from "@apollo/client";
import { useContext, useState } from "react";
import { useMediaQuery } from "react-responsive";
import {
InsertSkillMutationMutation,
SearchSkillsVerifiedQuery,
Skill,
InsertSkillMutation,
} from "../../generated/graphql";
import { INSERT_SKILL_MUTATION } from "../../graphql/mutations/skills";
import { INSERT_SKILL } from "../../graphql/mutations/skills";
import { displayNotification } from "../../utils/displayNotification";
import { i18nContext } from "../../utils/i18nContext";
import Button from "../atoms/Button";
Expand All @@ -17,6 +17,7 @@ import { getTutorialStep } from "../../constants/demo";
import { TutorialModeContext } from "../../utils/tutorialMode";
import { SEARCH_SKILLS_VERIFIED } from "../../graphql/queries/skills";
import { config } from "../../env";
import { useAuth0 } from "@auth0/auth0-react";
import { useRouter } from "next/router";

const AddSkillListSelector = ({
Expand All @@ -41,6 +42,7 @@ const AddSkillListSelector = ({
const tutorialModeValue = useContext(TutorialModeContext);
const { push } = useRouter();
const searchPageLink = `${config.nextPublicBaseUrl}/search`;
const { user } = useAuth0();

const closeModal = () => {
setOpenSkillDetails(false);
Expand All @@ -61,15 +63,15 @@ const AddSkillListSelector = ({
/*
* MUTATIONS
*/
const [insertSkill] = useMutation<InsertSkillMutationMutation>(
INSERT_SKILL_MUTATION
);
const [insertSkill] = useMutation<InsertSkillMutation>(INSERT_SKILL);

const addSkillButtonClick = async () => {
if (!categoryId || !search || search === "") {
return;
}
await insertSkill({ variables: { name: search, categoryId } })
await insertSkill({
variables: { name: search, categoryId, creator: user?.email },
})
.then((response) => {
if (!response.data.insert_Skill?.returning) {
return;
Expand Down
21 changes: 16 additions & 5 deletions src/components/organisms/EditSkillAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import Loading from "../molecules/Loading";
import SkillDescription from "../molecules/SkillDescription";
import Topics from "../molecules/Topics";
import ErrorPage from "../templates/ErrorPage";
import { INSERT_NOTIFICATION } from "../../graphql/mutations/notifications";
import { useAuth0 } from "@auth0/auth0-react";

type EditSkillAdminProps = {
skillId: string;
Expand All @@ -35,7 +37,7 @@ type EditSkillAdminProps = {
const EditSkillAdmin = ({ skillId }: EditSkillAdminProps) => {
const { t } = useContext(i18nContext);
const router = useRouter();

const { user } = useAuth0();
/*
* QUERIES
*/
Expand Down Expand Up @@ -64,6 +66,10 @@ const EditSkillAdmin = ({ skillId }: EditSkillAdminProps) => {
const [editSkill] = useMutation<EditSkillMutation>(EDIT_SKILL);
const [insertTopic] = useMutation(ADD_SKILL_TO_TOPIC);
const [deleteTopic] = useMutation(DELETE_SKILL_TO_TOPIC);
const [insertNotification] = useMutation(INSERT_NOTIFICATION);
const [updateVerifiedSkill] = useMutation<SetVerifiedSkillMutationMutationFn>(
UPDATE_SKILL_VERIFIED_MUTATION
);

const addTopic = (topic: TopicItem) => {
insertTopic({
Expand All @@ -80,15 +86,20 @@ const EditSkillAdmin = ({ skillId }: EditSkillAdminProps) => {
});
};

const [updateVerifiedSkill] = useMutation<SetVerifiedSkillMutationMutationFn>(
UPDATE_SKILL_VERIFIED_MUTATION
);

//### MG_NOTIFICATIONS
const updateVerifiedSkillButtonClick = async () => {
updateVerifiedSkill({
variables: { skillId: skillId, verified: true },
})
.then(() => {
insertNotification({
variables: {
userEmail: skillSelected?.Skill[0].creator,
skillId: skillId,
adminEmail: user?.email,
checked: false,
},
});
router.reload();
})
.catch(() => {
Expand Down
Loading