Skip to content

Commit

Permalink
Merge branch '3924-research-remix-backend' of https://github.com/gora…
Browse files Browse the repository at this point in the history
…tt12/community-platform into 3924-research-remix-backend
  • Loading branch information
goratt12 committed Nov 5, 2024
2 parents c79155b + 335a5b9 commit 671be5f
Show file tree
Hide file tree
Showing 103 changed files with 2,110 additions and 2,708 deletions.
17 changes: 15 additions & 2 deletions functions/src/userUpdates/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { profileTags } from 'oa-shared'
import { allCommunityProfileTags } from 'oa-shared'

import { CONFIG } from '../config/config'
import { valuesAreDeepEqual } from '../Utils'

import type { ISelectedTags, ITag, IUserDB } from 'oa-shared'

const projectName = () => {
const productionOptions = {
onearmyworld: 'precious-plastic',
'fixing-fashion-prod': 'fixing-fashion',
'project-kamp-community': 'project-kamp',
}

return productionOptions[CONFIG.service.project_id] || 'precious-plastic'
}

export const hasDetailsChanged = (
prevUser: IUserDB,
user: IUserDB,
Expand Down Expand Up @@ -87,8 +98,10 @@ export const getFirstCoverImage = (coverImages: IUserDB['coverImages']) => {
// For ease, duplicated from src/utils/getValidTags.ts
export const getValidTags = (tagIds: ISelectedTags) => {
const selectedTagIds = Object.keys(tagIds).filter((id) => tagIds[id] === true)
const projectTags = allCommunityProfileTags[projectName()]

const tags: ITag[] = selectedTagIds
.map((id) => profileTags.find(({ _id }) => id === _id))
.map((id) => projectTags.find(({ _id }) => id === _id))
.filter((tag): tag is ITag => !!tag)
.filter(({ _deleted }) => _deleted !== true)

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 4 additions & 2 deletions packages/components/src/FollowButton/FollowButton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMemo } from 'react'
import { useNavigate } from '@remix-run/react'

import { Button } from '../Button/Button'
Expand All @@ -15,14 +16,15 @@ export interface IProps {
export const FollowButton = (props: IProps) => {
const { hasUserSubscribed, isLoggedIn, onFollowClick, sx } = props
const navigate = useNavigate()
const uuid = useMemo(() => (Math.random() * 16).toString(), [])

return (
<>
<Button
type="button"
data-testid={isLoggedIn ? 'follow-button' : 'follow-redirect'}
data-cy={isLoggedIn ? 'follow-button' : 'follow-redirect'}
data-tooltip-id="login-follow"
data-tooltip-id={uuid}
data-tooltip-content={isLoggedIn ? '' : 'Login to follow'}
icon="thunderbolt"
variant="outline"
Expand All @@ -36,7 +38,7 @@ export const FollowButton = (props: IProps) => {
>
{hasUserSubscribed ? 'Following' : 'Follow'}
</Button>
<Tooltip id="login-follow" />
<Tooltip id={uuid} />
</>
)
}
22 changes: 11 additions & 11 deletions packages/components/src/MapFilterList/MapFilterList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,59 @@ export default {
// Copied from src/pages/Maps/Content/MapView/allMapFilterOptions.ts
const availableFilters: MapFilterOptionsList = [
{
_id: 'workspace',
filterType: 'profileType',
label: 'Workspace',
slug: 'workspace',
},
{
_id: 'machine-builder',
filterType: 'profileType',
label: 'Machine Builder',
slug: 'machine-builder',
},
{
_id: 'community-builder',
filterType: 'profileType',
label: 'Community Point',
slug: 'community-builder',
},
{
_id: 'collection-point',
filterType: 'profileType',
label: 'Collection Point',
slug: 'collection-point',
},
{
_id: 'space',
filterType: 'profileType',
label: 'Space',
slug: 'space',
},
{
_id: 'member',
filterType: 'profileType',
label: 'Want to get started',
slug: 'member',
},
{
_id: 'shredder',
filterType: 'workspaceType',
label: 'Shredder',
slug: 'shredder',
},
{
_id: 'sheetpress',
filterType: 'workspaceType',
label: 'Sheetpress',
slug: 'sheetpress',
},
{
_id: 'extrusion',
filterType: 'workspaceType',
label: 'Extrusion',
slug: 'extrusion',
},
{
_id: 'injection',
filterType: 'workspaceType',
label: 'Injection',
slug: 'injection',
},
{
_id: 'mix',
filterType: 'workspaceType',
label: 'Mix',
slug: 'mix',
},
]

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/MapFilterList/MapFilterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const MapFilterList = (props: IProps) => {
>
<MemberBadge
size={30}
profileType={typeFilter.slug as ProfileTypeName}
profileType={typeFilter._id as ProfileTypeName}
/>
<Text variant="quiet" sx={{ fontSize: 1 }}>
{typeFilter.label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ export default {
const availableFilters = [
{
label: 'Workspace',
slug: 'workspace' as ProfileTypeName,
_id: 'workspace' as ProfileTypeName,
filterType: 'ProfileType',
},
{
label: 'Machine Builder',
slug: 'machine-builder' as ProfileTypeName,
_id: 'machine-builder' as ProfileTypeName,
filterType: 'ProfileType',
},
{
label: 'Collection Point',
slug: 'collection-point' as ProfileTypeName,
_id: 'collection-point' as ProfileTypeName,
filterType: 'ProfileType',
},
{
label: 'Want to get started',
slug: 'member' as ProfileTypeName,
_id: 'member' as ProfileTypeName,
filterType: 'ProfileType',
},
]
Expand All @@ -42,7 +42,7 @@ export const Basic: StoryFn<typeof MapFilterProfileTypeCardList> = () => {

const onFilterChange = (option: MapFilterOption) => {
const isFilterPresent = !!availableFilters.find(
(pinFilter) => pinFilter.slug == option.slug,
(pinFilter) => pinFilter._id == option._id,
)
if (isFilterPresent) {
return setActiveFilters((filter) =>
Expand All @@ -68,7 +68,7 @@ export const OnlyOne: StoryFn<typeof MapFilterProfileTypeCardList> = () => {

const onFilterChange = (option: MapFilterOption) => {
const isFilterPresent = !!availableFilters.find(
(pinFilter) => pinFilter.slug == option.slug,
(pinFilter) => pinFilter._id == option._id,
)
if (isFilterPresent) {
return setActiveFilters((filter) =>
Expand All @@ -95,7 +95,7 @@ export const OnlyTwo: StoryFn<typeof MapFilterProfileTypeCardList> = () => {

const onFilterChange = (option: MapFilterOption) => {
const isFilterPresent = !!availableFilters.find(
(pinFilter) => pinFilter.slug == option.slug,
(pinFilter) => pinFilter._id == option._id,
)
if (isFilterPresent) {
return setActiveFilters((filter) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const MapFilterProfileTypeCardList = (props: IProps) => {
>
<MemberBadge
size={30}
profileType={typeFilter.slug as ProfileTypeName}
profileType={typeFilter._id as ProfileTypeName}
/>
<br />
<Text variant="quiet" sx={{ fontSize: 1 }}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react'
import { useMemo, useState } from 'react'
import { useNavigate } from '@remix-run/react'
import { Text, useThemeUI } from 'theme-ui'

Expand All @@ -18,6 +18,7 @@ export interface IProps {
export const UsefulStatsButton = (props: IProps) => {
const { theme } = useThemeUI() as any
const navigate = useNavigate()
const uuid = useMemo(() => (Math.random() * 16).toString(), [])

const [disabled, setDisabled] = useState<boolean>()

Expand All @@ -35,7 +36,7 @@ export const UsefulStatsButton = (props: IProps) => {
<>
<Button
type="button"
data-tooltip-id="login-vote"
data-tooltip-id={uuid}
data-tooltip-content={props.isLoggedIn ? '' : 'Login to add your vote'}
data-cy={props.isLoggedIn ? 'vote-useful' : 'vote-useful-redirect'}
onClick={() =>
Expand Down Expand Up @@ -73,7 +74,7 @@ export const UsefulStatsButton = (props: IProps) => {
{props.hasUserVotedUseful ? 'Marked as useful' : 'Mark as useful'}
</Text>
</Button>
<Tooltip id="login-vote" />
<Tooltip id={uuid} />
</>
)
}
2 changes: 1 addition & 1 deletion packages/cypress/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CYPRESS_KEY=62585f33-d688-47b7-acb3-6d1dca832065
VITE_SITE_NAME=Precious Plastic
VITE_SITE_VARIANT=test-ci
VITE_PLATFORM_THEME=precious-plastic
VITE_THEME=precious-plastic
5 changes: 3 additions & 2 deletions packages/cypress/src/integration/questions/write.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { MOCK_DATA } from '../../data'
import { generateAlphaNumeric } from '../../utils/TestUtils'

const questions = Object.values(MOCK_DATA.questions)
const item = questions[0]

describe('[Question]', () => {
describe('[Create a question]', () => {
const initialRandomId = crypto.randomUUID().slice(0, 8)
const initialRandomId = generateAlphaNumeric(8).toLowerCase()
const initialTitle = initialRandomId + ' Health cost of plastic?'
const initialExpectedSlug = initialRandomId + '-health-cost-of-plastic'
const initialQuestionDescription =
"Hello! I'm wondering how people feel about the health concerns about working with melting plastic and being in environments with microplastics. I have been working with recycling plastic (hdpe) for two years now, shredding and injection molding and haven't had any bad consequences yet. But with the low knowledge around micro plastics and its effects on the human body, and many concerns and hypotheses I have been a bit concerned lately.So I would like to ask the people in this community how you are feeling about it, and if you have experienced any issues with the microplastics or gases yet, if so how long have you been working with it? And what extra steps do you take to be protected from it? I use a gas mask with dust filters"
const category = 'exhibition'
const tag1 = 'product'
const tag2 = 'workshop'
const updatedRandomId = crypto.randomUUID().slice(0, 8)
const updatedRandomId = generateAlphaNumeric(8).toLowerCase()
const updatedTitle = updatedRandomId + ' Real health cost of plastic?'
const updatedExpectedSlug = updatedRandomId + '-real-health-cost-of-plastic'
const updatedQuestionDescription = `${initialQuestionDescription} and super awesome goggles`
Expand Down
5 changes: 3 additions & 2 deletions packages/cypress/src/integration/research/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { faker } from '@faker-js/faker'

import { RESEARCH_TITLE_MIN_LENGTH } from '../../../../../src/pages/Research/constants'
import {
generateAlphaNumeric,
generateNewUserDetails,
setIsPreciousPlastic,
} from '../../utils/TestUtils'
Expand Down Expand Up @@ -154,7 +155,7 @@ describe('[Research]', () => {
})

it('[Any PP user]', () => {
const randomId = crypto.randomUUID().slice(0, 8)
const randomId = generateAlphaNumeric(8).toLowerCase()
const title = randomId + ' PP plastic stuff'
const expectSlug = randomId + '-pp-plastic-stuff'
const description = 'Bespoke research topic'
Expand Down Expand Up @@ -255,7 +256,7 @@ describe('[Research]', () => {

describe('[Displays draft updates for Author]', () => {
it('[By Authenticated]', () => {
const randomId = crypto.randomUUID().slice(0, 8)
const randomId = generateAlphaNumeric(8).toLowerCase()
const updateTitle = `${randomId} Create a research update`
const updateDescription = 'This is the description for the update.'
const updateVideoUrl = 'http://youtube.com/watch?v=sbcWY7t-JX8'
Expand Down
Loading

0 comments on commit 671be5f

Please sign in to comment.