From a3acfcf9137e410b0c17c7c511f008dd98046bab Mon Sep 17 00:00:00 2001 From: Luke Watts Date: Mon, 23 Jan 2023 21:17:26 +0100 Subject: [PATCH 1/3] chore: remove unused events --- src/mocks/events.mock.tsx | 96 -------------------------------- src/mocks/howto.mock.tsx | 100 ---------------------------------- src/mocks/location.mock.tsx | 78 -------------------------- src/stores/Maps/maps.store.ts | 3 +- 4 files changed, 1 insertion(+), 276 deletions(-) delete mode 100644 src/mocks/events.mock.tsx delete mode 100644 src/mocks/howto.mock.tsx delete mode 100644 src/mocks/location.mock.tsx diff --git a/src/mocks/events.mock.tsx b/src/mocks/events.mock.tsx deleted file mode 100644 index dde33b07c3..0000000000 --- a/src/mocks/events.mock.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import type { IEventFilters, IEvent } from 'src/models/events.models' -import { MOCK_DB_META } from './db.mock' -import { MOCK_LOCATION } from './location.mock' - -const d = new Date() -export const EVENT_FILTERS: IEventFilters = { - dateFrom: d, - dateTo: new Date(d.getFullYear() + 1, d.getMonth(), d.getDay()), - location: '', - project: '', - type: 'All', -} - -export const EVENT_PROJECTS = [ - { label: 'All Projects', value: '' }, - { label: 'Precious Plastic', value: 'precious-plastic' }, - { label: 'Project Kamp', value: 'project-kamp' }, - { label: 'Story Hopper', value: 'story-hopper' }, -] - -export const EVENT_LOCATIONS = [ - { label: 'Everywhere', value: '' }, - { label: 'Netherlands', value: 'NL' }, -] - -export const EVENT_TYPES = [ - 'All', - 'Workshops', - 'Community Meetups', - 'Exhibitions', - 'Open Workspace', - 'Talks', - 'Clean Ups', - 'Everything Else', -] - -export const TIMEFRAMES = [ - { value: 'weekend', label: 'This Weekend' }, - { value: 'week', label: 'This Week' }, - { value: 'month', label: 'This Month' }, - { value: 'year', label: 'This Year' }, -] - -export const EVENTS: IEvent[] = [ - { - title: 'Open Workspace and Free Lunch - Eindhoven', - location: MOCK_LOCATION(1), - ...MOCK_DB_META('event1'), - date: new Date('Friday, January 2, 2015 12:59 AM').toISOString(), - slug: 'open-workshop-and-free-lunch---brighton', - tags: {}, - isDigital: true, - url: 'http://fakeurl.com', - _createdBy: 'exampleUser', - moderation: 'awaiting-moderation', - }, - { - title: 'Beach Clean in Brighton', - location: MOCK_LOCATION(2), - ...MOCK_DB_META('event2'), - date: new Date('Friday, January 2, 2015 12:59 AM').toISOString(), - slug: 'open-workshop-and-free-lunch---brighton', - tags: {}, - isDigital: false, - url: 'http://fakeurl.com', - _createdBy: 'exampleUser', - moderation: 'rejected', - }, - { - title: 'Beach Clean in Tel Aviv', - location: MOCK_LOCATION(2), - ...MOCK_DB_META('event2'), - date: new Date('Friday, January 2, 2015 12:59 AM').toISOString(), - slug: 'open-workshop-and-free-lunch---brighton', - tags: {}, - isDigital: false, - url: 'http://fakeurl.com', - _createdBy: 'exampleUser', - moderation: 'accepted', - }, -] - -export const MONTHS = [ - 'January', - 'February', - 'March', - 'April', - 'May', - 'June', - 'July', - 'August', - 'September', - 'October', - 'November', - 'December', -] diff --git a/src/mocks/howto.mock.tsx b/src/mocks/howto.mock.tsx deleted file mode 100644 index fdafafe123..0000000000 --- a/src/mocks/howto.mock.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import type { IHowto } from '../models/howto.models' -import type { IUploadedFileMeta } from 'src/stores/storage' -import { MOCK_DB_META } from './db.mock' - -const exampleUploadImage: IUploadedFileMeta = { - downloadUrl: 'http://placekitten.com/g/400/250', - fullPath: '', - name: '250.jpg', - size: 11035, - timeCreated: '', - updated: '', - type: 'image/jpg', -} - -export const HOWTO_MOCK: IHowto[] = [ - { - cover_image: exampleUploadImage, - title: 'How-To 1', - slug: 'how-to-1', - description: 'this is a great description 1', - difficulty_level: 'Hard', - time: '30 hours', - steps: [ - { - images: [], - text: 'this text is wonderful oh my god', - title: 'My super step1 title', - }, - { - images: [exampleUploadImage, exampleUploadImage], - text: 'this text is wonderful oh my god', - title: 'My super step2 title', - }, - ], - tags: {}, - files: [], - mentions: [], - ...MOCK_DB_META('howTo1'), - _createdBy: 'ExampleUser', - moderation: 'draft', - creatorCountry: 'nl', - previousSlugs: [], - }, - { - cover_image: exampleUploadImage, - title: 'How-to 2', - slug: 'how-to-2', - description: 'this is a great description 2', - difficulty_level: 'Hard', - time: '30 hours', - steps: [ - { - images: [exampleUploadImage, exampleUploadImage], - text: 'this text is wonderful oh my god', - title: 'My super step1 title', - }, - { - images: [exampleUploadImage], - text: 'this text is wonderful oh my god', - title: 'My super step2 title', - }, - ], - tags: {}, - files: [], - mentions: [], - ...MOCK_DB_META('howTo2'), - _createdBy: 'ExampleUser', - moderation: 'awaiting-moderation', - creatorCountry: 'fr', - previousSlugs: [], - }, - { - cover_image: exampleUploadImage, - title: 'How-to 3', - slug: 'how-to-3', - description: 'this is a great description 3', - difficulty_level: 'Hard', - time: '30 days', - steps: [ - { - images: [exampleUploadImage], - text: 'this text is wonderful oh my god', - title: 'My super step1 title', - }, - { - images: [exampleUploadImage], - text: 'this text is wonderful oh my god', - title: 'My super step2 title', - }, - ], - tags: {}, - files: [], - mentions: [], - ...MOCK_DB_META('howTo3'), - _createdBy: 'ExampleUser', - moderation: 'accepted', - creatorCountry: 'es', - previousSlugs: [], - }, -] diff --git a/src/mocks/location.mock.tsx b/src/mocks/location.mock.tsx deleted file mode 100644 index a4170ee1b5..0000000000 --- a/src/mocks/location.mock.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import type { ILocation } from 'src/models/common.models' - -/** - * Generate mock location data matching algolia places format - * @param i Optional - provide a specific location index - * 1:Twickenham, 2:Eindhoven, 3:Brighton, 4:Paris, 5:Madrid - */ -export const MOCK_LOCATION = (i?: number) => { - // pick random location from list below - return i - ? LOCATIONS[i] - : LOCATIONS[Math.floor(Math.random() * LOCATIONS.length)] -} - -// Example outputs generated at: https://community.algolia.com/places/ -const LOCATIONS: ILocation[] = [ - { - name: 'Twickenham', - administrative: 'England', - country: 'United Kingdom', - countryCode: 'gb', - latlng: { - lat: 51.4468, - lng: -0.328339, - }, - postcode: 'TW1 3RZ', - value: - 'Twickenham, London Borough of Richmond upon Thames, England, United Kingdom', - }, - { - name: 'Eindhoven', - administrative: 'Noord-Brabant', - country: 'The Netherlands', - countryCode: 'nl', - latlng: { - lat: 51.4393, - lng: 5.47863, - }, - postcode: '5611', - value: 'Eindhoven, Noord-Brabant, The Netherlands', - }, - { - name: 'Brighton', - administrative: 'England', - country: 'United Kingdom', - countryCode: 'gb', - latlng: { - lat: 50.8419, - lng: -0.12791, - }, - postcode: 'BN2', - value: 'Brighton, England, United Kingdom', - }, - { - name: 'Paris', - administrative: 'Île-de-France', - country: 'France', - countryCode: 'fr', - latlng: { - lat: 48.8546, - lng: 2.34771, - }, - postcode: '75000', - value: 'Paris, Île-de-France, France', - }, - { - name: 'Madrid', - administrative: 'Comunidad de Madrid', - country: 'Spain', - countryCode: 'es', - latlng: { - lat: 40.4167, - lng: -3.70358, - }, - postcode: '28001', - value: 'Madrid, Comunidad de Madrid, Spain', - }, -] diff --git a/src/stores/Maps/maps.store.ts b/src/stores/Maps/maps.store.ts index 86b50a9d33..f6f65a7d7f 100644 --- a/src/stores/Maps/maps.store.ts +++ b/src/stores/Maps/maps.store.ts @@ -25,7 +25,6 @@ import { filterMapPinsByType } from './filter' // NOTE - toggle below variable to use larger mock dataset const IS_MOCK = false -const MOCK_PINS = generatePins(250) const COLLECTION_NAME: IDBEndpoint = 'mappins' export class MapsStore extends ModuleStore { mapPins$: Subscription @@ -67,7 +66,7 @@ export class MapsStore extends ModuleStore { return { ...p, verified: this.userStore.verifiedUsers[p._id] === true } }) if (IS_MOCK) { - pins = MOCK_PINS + pins = generatePins(250) } this.mapPins = pins this.filteredPins = this.mapPins From a722459da63badb5d88cb59f2fdf58ca343d38a9 Mon Sep 17 00:00:00 2001 From: Luke Watts Date: Mon, 23 Jan 2023 21:40:05 +0100 Subject: [PATCH 2/3] chore: remove unused mocks --- src/mocks/_template.mock.tsx | 39 -- src/mocks/projects.mock.tsx | 14 - src/mocks/research.mocks.tsx | 96 ----- src/mocks/user.mock.tsx | 19 - src/mocks/user_pp.mock.tsx | 389 ------------------ .../formSections/Collection.section.tsx | 50 ++- .../formSections/Expertise.section.tsx | 20 +- .../formSections/Workspace.section.tsx | 41 +- 8 files changed, 107 insertions(+), 561 deletions(-) delete mode 100644 src/mocks/_template.mock.tsx delete mode 100644 src/mocks/projects.mock.tsx delete mode 100644 src/mocks/research.mocks.tsx delete mode 100644 src/mocks/user.mock.tsx delete mode 100644 src/mocks/user_pp.mock.tsx diff --git a/src/mocks/_template.mock.tsx b/src/mocks/_template.mock.tsx deleted file mode 100644 index 7fbce6484a..0000000000 --- a/src/mocks/_template.mock.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import type { ITemplateData } from 'src/models/_template.model' -import { MOCK_USER } from './user.mock' - -export const TemplateMock: ITemplateData[] = [ - { - id: 1, - message: { message: 'hello', read: true, type: 'short' }, - _createdBy: MOCK_USER.userName, - _created: new Date(), - _modified: new Date(), - }, - { - id: 2, - message: { message: 'ahoyhoy', read: false, type: 'short' }, - _created: new Date(), - _modified: new Date(), - }, -] - -/************************************************************************************* -General Q & A - -Q. What are mocks? -These are simply dummy datasets for use in development. They often mimic data that -would be populated from the main database - -Q. What does ITemplateData[] mean? -We have defined the shape of our data using ITemplateData model. The extra [] simply -means we expect an array of items all matching that data structure -(for more info see https://www.typescriptlang.org/docs/handbook/basic-types.html) - -Q. Isn't the data incomplete? -No, _createdBy is an optional field (denoted by ? in the model) - - -Anything else you want to know? Add it to a git issue and so we can make the -template even more useful - -**************************************************************************************/ diff --git a/src/mocks/projects.mock.tsx b/src/mocks/projects.mock.tsx deleted file mode 100644 index 6f4166f9de..0000000000 --- a/src/mocks/projects.mock.tsx +++ /dev/null @@ -1,14 +0,0 @@ -export const PROJECTS_MOCKS = [ - { - label: 'Project Kamp', - value: 'project-kamp', - }, - { - label: 'Precious Plastic', - value: 'precious-plastic', - }, - { - label: 'Story Hooper', - value: 'story-hooper', - }, -] diff --git a/src/mocks/research.mocks.tsx b/src/mocks/research.mocks.tsx deleted file mode 100644 index 7fa9d5ff3b..0000000000 --- a/src/mocks/research.mocks.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import type { IResearch } from '../models/research.models' -import { MOCK_DB_META } from './db.mock' - -export const MOCK_RESEARCH_ITEMS: IResearch.ItemDB[] = [ - { - ...MOCK_DB_META(), - moderation: 'accepted', - title: 'Make a big 244 x 122 sheetpress?', - description: 'We want to see whether we can make a big sheetpress', - slug: 'make-a-big-244-x-122-sheetpress', - tags: { 'Plastic Hero': true, 'Another tag': true }, - updates: [ - { - ...MOCK_DB_META(), - title: 'Research Online', - description: 'We looked into some online reach that you can find', - images: [], - }, - ], - _createdBy: 'Precious Plastic Malesia', - }, - { - ...MOCK_DB_META(), - moderation: 'accepted', - title: 'Run the injection machine on Solar?', - description: 'Run the injection machine on Solar?', - slug: 'run-the-injection-machine-on-solar', - tags: { 'Plastic Hero': true, any: true }, - updates: [ - { - ...MOCK_DB_META(), - title: 'Research Online', - description: 'We looked into some online reach that you can find', - images: [], - }, - ], - _createdBy: 'Zelenew', - }, -] - -export const MOCK_UPDATES: IResearch.Update[] = [ - { - title: 'Trying a small version', - description: `Ad minus expedita quibusdam. Amet quia recusandae quia sequi. Molestiae adipisci officia rerum officia. Itaque eveniet natus dolores et at quae non hic. Qui odio consequatur id quia quam. - Consequuntur possimus dolorem dignissimos beatae saepe. Ipsam nemo eos magnam sed. Recusandae modi eum dolorem autem voluptas dolor est.`, - images: [ - { - fullPath: 'uploads/howtos/KEhA3Ei4NSmdQgShl9Vp/IMG_20170909_173730.jpg', - updated: '2020-10-05T09:53:31.625Z', - name: 'IMG_20170909_173730.jpg', - contentType: 'image/jpeg', - size: 255946, - type: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2Fhowtos%2FKEhA3Ei4NSmdQgShl9Vp%2FIMG_20170909_173730.jpg?alt=media&token=2464cb94-ed53-4853-acac-9626b8fec079', - timeCreated: '2020-10-05T09:53:31.625Z', - }, - { - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2Fhowtos%2FKEhA3Ei4NSmdQgShl9Vp%2FD2rZFtOX4AAY8cv.jpg?alt=media&token=0c3645ee-8551-4247-b5df-d03529a55f57', - updated: '2020-10-05T09:53:30.263Z', - name: 'D2rZFtOX4AAY8cv.jpg', - type: 'image/jpeg', - contentType: 'image/jpeg', - timeCreated: '2020-10-05T09:53:30.263Z', - size: 248912, - fullPath: 'uploads/howtos/KEhA3Ei4NSmdQgShl9Vp/D2rZFtOX4AAY8cv.jpg', - }, - ], - }, - { - title: 'Melt the HDPE', - description: `Ad minus expedita quibusdam. Amet quia recusandae quia sequi. Molestiae adipisci officia rerum officia. Itaque eveniet natus dolores et at quae non hic. Qui odio consequatur id quia quam. - Consequuntur possimus dolorem dignissimos beatae saepe. Ipsam nemo eos magnam sed. Recusandae modi eum dolorem autem voluptas dolor est.`, - images: [ - { - fullPath: 'uploads/howtos/KEhA3Ei4NSmdQgShl9Vp/IMG_20170909_173730.jpg', - updated: '2020-10-05T09:53:31.625Z', - name: 'IMG_20170909_173730.jpg', - contentType: 'image/jpeg', - size: 255946, - type: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2Fhowtos%2FKEhA3Ei4NSmdQgShl9Vp%2FIMG_20170909_173730.jpg?alt=media&token=2464cb94-ed53-4853-acac-9626b8fec079', - timeCreated: '2020-10-05T09:53:31.625Z', - }, - ], - }, - { - title: 'Build a kitchen and workspace in a container', - description: `Ad minus expedita quibusdam. Amet quia recusandae quia sequi. Molestiae adipisci officia rerum officia. Itaque eveniet natus dolores et at quae non hic. Qui odio consequatur id quia quam. - Consequuntur possimus dolorem dignissimos beatae saepe.`, - images: [], - videoUrl: 'https://www.youtube.com/watch?v=bjU7QKcEUFY', - }, -] diff --git a/src/mocks/user.mock.tsx b/src/mocks/user.mock.tsx deleted file mode 100644 index dc2d2ce5cb..0000000000 --- a/src/mocks/user.mock.tsx +++ /dev/null @@ -1,19 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention*/ -import type { IUser } from 'src/models/user.models' -import { MOCK_DB_META } from './db.mock' - -export const MOCK_USER: IUser = { - verified: true, - badges: { verified: true }, - userName: 'chris-m-clarke', - displayName: 'chris-m-clarke', - moderation: 'accepted', - ...MOCK_DB_META(), - _authID: '123', - DHSite_id: 70134, - DHSite_mention_name: 'chris-m-clarke', - country: '', - coverImages: [], - links: [], - votedUsefulHowtos: {}, -} diff --git a/src/mocks/user_pp.mock.tsx b/src/mocks/user_pp.mock.tsx deleted file mode 100644 index bfad4a1a53..0000000000 --- a/src/mocks/user_pp.mock.tsx +++ /dev/null @@ -1,389 +0,0 @@ -import type { - IUserPP, - IWorkspaceType, - IPlasticType, - IMAchineBuilderXp, -} from 'src/models/user_pp.models' -import { MOCK_DB_META } from './db.mock' -import { MOCK_USER } from './user.mock' - -// assets plasticType -import Pet from 'src/assets/images/plastic-types/pet.svg' -import PP from 'src/assets/images/plastic-types/pp.svg' -import PS from 'src/assets/images/plastic-types/ps.svg' -import Hdpe from 'src/assets/images/plastic-types/hdpe.svg' -import Ldpe from 'src/assets/images/plastic-types/ldpe.svg' -import Other from 'src/assets/images/plastic-types/other.svg' -import Pvc from 'src/assets/images/plastic-types/pvc.svg' - -// assets profileType -// Verified - -// assets workspaceType -import Extrusion from 'src/assets/images/workspace-focus/extrusion.png' -import Injection from 'src/assets/images/workspace-focus/injection.png' -import Mix from 'src/assets/images/workspace-focus/mix.png' -import Sheetpress from 'src/assets/images/workspace-focus/sheetpress.png' -import Shredder from 'src/assets/images/workspace-focus/shredder.png' -import { ProfileType } from 'src/modules/profile/types' - -export const MOCK_USER_WORKSPACE: IUserPP = { - ...MOCK_USER, - userName: 'workspace-username', - about: - "Description of user profile, it's a nice workspace where we build products out of recycled plastic", - profileType: ProfileType.WORKSPACE, - workspaceType: 'extrusion', - coverImages: [ - { - contentType: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2FhowtosV1%2FcWngQOnxxD3r3oI8TKx8%2FScreen%20Shot%202019-03-16%20at%2020.40.36.png?alt=media&token=51ac3516-064c-4f1d-ac2b-4460ee9f3500', - fullPath: - 'uploads/howtosV1/cWngQOnxxD3r3oI8TKx8/Screen Shot 2019-03-16 at 20.40.36.png', - name: 'Screen Shot 2019-03-16 at 20.40.36.png', - size: 209068, - timeCreated: '2019-05-08T12:28:27.318Z', - type: 'image/jpeg', - updated: '2019-05-08T12:28:27.318Z', - }, - { - contentType: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2FhowtosV1%2FcWngQOnxxD3r3oI8TKx8%2FScreen%20Shot%202019-03-16%20at%2020.40.36.png?alt=media&token=51ac3516-064c-4f1d-ac2b-4460ee9f3500', - fullPath: - 'uploads/howtosV1/cWngQOnxxD3r3oI8TKx8/Screen Shot 2019-03-16 at 20.40.36.png', - name: 'Screen Shot 2019-03-16 at 20.40.36.png', - size: 209068, - timeCreated: '2019-05-08T12:28:27.318Z', - type: 'image/jpeg', - updated: '2019-05-08T12:28:27.318Z', - }, - ], - links: [ - { - label: 'instagram', - url: 'https://www.instagram.com/realpreciousplastic/', - }, - { - label: 'facebook', - url: 'https://www.facebook.com/preciousplastic/', - }, - ], - mapPinDescription: 'This is a description to display on the map user card', - isExpert: true, - isV4Member: false, - openingHours: [], - collectedPlasticTypes: [], - machineBuilderXp: [], -} -export const MOCK_USER_COLLECTION: IUserPP = { - verified: true, - badges: { verified: true }, - userName: 'collection-username', - about: 'We are collecting plastic in city center', - ...MOCK_DB_META(), - _authID: '123', - country: 'Netherlands', - profileType: ProfileType.COLLECTION_POINT, - moderation: 'accepted', - displayName: 'collection-username', - coverImages: [ - { - contentType: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2FhowtosV1%2FcWngQOnxxD3r3oI8TKx8%2FScreen%20Shot%202019-03-16%20at%2020.40.36.png?alt=media&token=51ac3516-064c-4f1d-ac2b-4460ee9f3500', - fullPath: - 'uploads/howtosV1/cWngQOnxxD3r3oI8TKx8/Screen Shot 2019-03-16 at 20.40.36.png', - name: 'Screen Shot 2019-03-16 at 20.40.36.png', - size: 209068, - timeCreated: '2019-05-08T12:28:27.318Z', - type: 'image/jpeg', - updated: '2019-05-08T12:28:27.318Z', - }, - { - contentType: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2FhowtosV1%2FcWngQOnxxD3r3oI8TKx8%2FScreen%20Shot%202019-03-16%20at%2020.40.36.png?alt=media&token=51ac3516-064c-4f1d-ac2b-4460ee9f3500', - fullPath: - 'uploads/howtosV1/cWngQOnxxD3r3oI8TKx8/Screen Shot 2019-03-16 at 20.40.36.png', - name: 'Screen Shot 2019-03-16 at 20.40.36.png', - size: 209068, - timeCreated: '2019-05-08T12:28:27.318Z', - type: 'image/jpeg', - updated: '2019-05-08T12:28:27.318Z', - }, - ], - links: [ - { - label: 'instagram', - url: 'https://www.instagram.com/realpreciousplastic/', - }, - { - label: 'facebook', - url: 'https://www.facebook.com/preciousplastic/', - }, - ], - mapPinDescription: 'Collecting plastic', - isExpert: false, - isV4Member: true, - openingHours: [], - collectedPlasticTypes: [], - machineBuilderXp: [], - votedUsefulHowtos: {}, -} -export const MOCK_USER_MEMBER: IUserPP = { - verified: true, - badges: { verified: false }, - userName: 'member-username', - about: "I'm just a member of this community that share knowledge", - ...MOCK_DB_META(), - _authID: '123', - country: 'Netherlands', - profileType: ProfileType.MEMBER, - moderation: 'accepted', - displayName: 'member-username', - coverImages: [ - { - contentType: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2FhowtosV1%2FcWngQOnxxD3r3oI8TKx8%2FScreen%20Shot%202019-03-16%20at%2020.40.36.png?alt=media&token=51ac3516-064c-4f1d-ac2b-4460ee9f3500', - fullPath: - 'uploads/howtosV1/cWngQOnxxD3r3oI8TKx8/Screen Shot 2019-03-16 at 20.40.36.png', - name: 'Screen Shot 2019-03-16 at 20.40.36.png', - size: 209068, - timeCreated: '2019-05-08T12:28:27.318Z', - type: 'image/jpeg', - updated: '2019-05-08T12:28:27.318Z', - }, - { - contentType: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2FhowtosV1%2FcWngQOnxxD3r3oI8TKx8%2FScreen%20Shot%202019-03-16%20at%2020.40.36.png?alt=media&token=51ac3516-064c-4f1d-ac2b-4460ee9f3500', - fullPath: - 'uploads/howtosV1/cWngQOnxxD3r3oI8TKx8/Screen Shot 2019-03-16 at 20.40.36.png', - name: 'Screen Shot 2019-03-16 at 20.40.36.png', - size: 209068, - timeCreated: '2019-05-08T12:28:27.318Z', - type: 'image/jpeg', - updated: '2019-05-08T12:28:27.318Z', - }, - ], - links: [ - { - label: 'instagram', - url: 'https://www.instagram.com/realpreciousplastic/', - }, - { - label: 'facebook', - url: 'https://www.facebook.com/preciousplastic/', - }, - ], - isExpert: false, - isV4Member: false, - openingHours: [], - collectedPlasticTypes: [], - machineBuilderXp: [], - votedUsefulHowtos: {}, -} -export const MOCK_USER_COMMUNITY: IUserPP = { - verified: true, - badges: { verified: true }, - userName: 'community-username', - about: 'We are building a local community to fight plastic waste', - ...MOCK_DB_META(), - _authID: '123', - country: 'Kenya', - profileType: ProfileType.COMMUNITY_BUILDER, - moderation: 'accepted', - displayName: 'community-username', - coverImages: [ - { - contentType: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2FhowtosV1%2FcWngQOnxxD3r3oI8TKx8%2FScreen%20Shot%202019-03-16%20at%2020.40.36.png?alt=media&token=51ac3516-064c-4f1d-ac2b-4460ee9f3500', - fullPath: - 'uploads/howtosV1/cWngQOnxxD3r3oI8TKx8/Screen Shot 2019-03-16 at 20.40.36.png', - name: 'Screen Shot 2019-03-16 at 20.40.36.png', - size: 209068, - timeCreated: '2019-05-08T12:28:27.318Z', - type: 'image/jpeg', - updated: '2019-05-08T12:28:27.318Z', - }, - { - contentType: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2FhowtosV1%2FcWngQOnxxD3r3oI8TKx8%2FScreen%20Shot%202019-03-16%20at%2020.40.36.png?alt=media&token=51ac3516-064c-4f1d-ac2b-4460ee9f3500', - fullPath: - 'uploads/howtosV1/cWngQOnxxD3r3oI8TKx8/Screen Shot 2019-03-16 at 20.40.36.png', - name: 'Screen Shot 2019-03-16 at 20.40.36.png', - size: 209068, - timeCreated: '2019-05-08T12:28:27.318Z', - type: 'image/jpeg', - updated: '2019-05-08T12:28:27.318Z', - }, - ], - links: [ - { - label: 'instagram', - url: 'https://www.instagram.com/realpreciousplastic/', - }, - { - label: 'facebook', - url: 'https://www.facebook.com/preciousplastic/', - }, - ], - workspaceType: 'mix', - mapPinDescription: null, - isExpert: false, - isV4Member: true, - openingHours: [], - collectedPlasticTypes: [], - machineBuilderXp: [], - votedUsefulHowtos: {}, -} -export const MOCK_USER_MACHINE: IUserPP = { - verified: true, - badges: { verified: true }, - userName: 'community-username', - about: 'We are building machine to recycle plastic', - ...MOCK_DB_META(), - _authID: '123', - country: 'USA', - profileType: ProfileType.MACHINE_BUILDER, - moderation: 'accepted', - displayName: 'collection-username', - coverImages: [ - { - contentType: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2FhowtosV1%2FcWngQOnxxD3r3oI8TKx8%2FScreen%20Shot%202019-03-16%20at%2020.40.36.png?alt=media&token=51ac3516-064c-4f1d-ac2b-4460ee9f3500', - fullPath: - 'uploads/howtosV1/cWngQOnxxD3r3oI8TKx8/Screen Shot 2019-03-16 at 20.40.36.png', - name: 'Screen Shot 2019-03-16 at 20.40.36.png', - size: 209068, - timeCreated: '2019-05-08T12:28:27.318Z', - type: 'image/jpeg', - updated: '2019-05-08T12:28:27.318Z', - }, - { - contentType: 'image/jpeg', - downloadUrl: - 'https://firebasestorage.googleapis.com/v0/b/precious-plastics-v4-dev.appspot.com/o/uploads%2FhowtosV1%2FcWngQOnxxD3r3oI8TKx8%2FScreen%20Shot%202019-03-16%20at%2020.40.36.png?alt=media&token=51ac3516-064c-4f1d-ac2b-4460ee9f3500', - fullPath: - 'uploads/howtosV1/cWngQOnxxD3r3oI8TKx8/Screen Shot 2019-03-16 at 20.40.36.png', - name: 'Screen Shot 2019-03-16 at 20.40.36.png', - size: 209068, - timeCreated: '2019-05-08T12:28:27.318Z', - type: 'image/jpeg', - updated: '2019-05-08T12:28:27.318Z', - }, - ], - links: [ - { - label: 'instagram', - url: 'https://www.instagram.com/realpreciousplastic/', - }, - { - label: 'facebook', - url: 'https://www.facebook.com/preciousplastic/', - }, - ], - workspaceType: 'mix', - mapPinDescription: null, - isExpert: true, - isV4Member: false, - openingHours: [], - collectedPlasticTypes: [], - machineBuilderXp: [], - votedUsefulHowtos: {}, -} - -export const PLASTIC_TYPES: IPlasticType[] = [ - { - label: 'pet', - number: '1', - imageSrc: Pet, - }, - { - label: 'hdpe', - number: '2', - imageSrc: Hdpe, - }, - { - label: 'pvc', - number: '3', - imageSrc: Pvc, - }, - { - label: 'ldpe', - number: '4', - imageSrc: Ldpe, - }, - { - label: 'pp', - number: '5', - imageSrc: PP, - }, - { - label: 'ps', - number: '6', - imageSrc: PS, - }, - { - label: 'other', - number: '7', - imageSrc: Other, - }, -] - -export const MACHINE_BUILDER_XP: IMAchineBuilderXp[] = [ - { - label: 'electronics', - }, - { - label: 'machining', - }, - { - label: 'welding', - }, - { - label: 'assembling', - }, - { - label: 'mould-making', - }, -] - -export const WORKSPACE_TYPES: IWorkspaceType[] = [ - { - label: 'shredder', - textLabel: 'Shredder', - subText: 'Shredding plastic waste into flakes', - imageSrc: Shredder, - }, - { - label: 'sheetpress', - textLabel: 'Sheetpress', - subText: 'Making recycled plastic sheets', - imageSrc: Sheetpress, - }, - { - label: 'extrusion', - textLabel: 'Extrusion', - subText: 'Extruding plastic into beams or products', - imageSrc: Extrusion, - }, - { - label: 'injection', - textLabel: 'Injection', - subText: 'Making small productions of goods', - imageSrc: Injection, - }, - { - label: 'mix', - textLabel: 'Mix', - subText: 'Running a workspace with multiple machines and goals', - imageSrc: Mix, - }, -] diff --git a/src/pages/Settings/content/formSections/Collection.section.tsx b/src/pages/Settings/content/formSections/Collection.section.tsx index 83ff15d523..ea32593cb7 100644 --- a/src/pages/Settings/content/formSections/Collection.section.tsx +++ b/src/pages/Settings/content/formSections/Collection.section.tsx @@ -1,14 +1,22 @@ import * as React from 'react' +import type { IUserPP } from 'src/models/user_pp.models' +import type { IPlasticType } from 'src/models' import { Flex, Heading, Box, Text } from 'theme-ui' import { FlexSectionContainer } from './elements' import { OpeningHoursPicker } from './Fields/OpeningHoursPicker.field' +import Pet from 'src/assets/images/plastic-types/pet.svg' +import PP from 'src/assets/images/plastic-types/pp.svg' +import PS from 'src/assets/images/plastic-types/ps.svg' +import Hdpe from 'src/assets/images/plastic-types/hdpe.svg' +import Ldpe from 'src/assets/images/plastic-types/ldpe.svg' +import Other from 'src/assets/images/plastic-types/other.svg' +import Pvc from 'src/assets/images/plastic-types/pvc.svg' + import { FieldArray } from 'react-final-form-arrays' import { Button } from 'oa-components' import { CustomCheckbox } from './Fields/CustomCheckbox.field' -import { PLASTIC_TYPES } from 'src/mocks/user_pp.mock' -import type { IUserPP } from 'src/models/user_pp.models' import theme from 'src/themes/styled.theme' interface IProps { @@ -123,3 +131,41 @@ export class CollectionSection extends React.Component { ) } } + +const PLASTIC_TYPES: IPlasticType[] = [ + { + label: 'pet', + number: '1', + imageSrc: Pet, + }, + { + label: 'hdpe', + number: '2', + imageSrc: Hdpe, + }, + { + label: 'pvc', + number: '3', + imageSrc: Pvc, + }, + { + label: 'ldpe', + number: '4', + imageSrc: Ldpe, + }, + { + label: 'pp', + number: '5', + imageSrc: PP, + }, + { + label: 'ps', + number: '6', + imageSrc: PS, + }, + { + label: 'other', + number: '7', + imageSrc: Other, + }, +] diff --git a/src/pages/Settings/content/formSections/Expertise.section.tsx b/src/pages/Settings/content/formSections/Expertise.section.tsx index 0f18d9334e..96110b6789 100644 --- a/src/pages/Settings/content/formSections/Expertise.section.tsx +++ b/src/pages/Settings/content/formSections/Expertise.section.tsx @@ -3,14 +3,32 @@ import * as React from 'react' import { Flex, Heading, Box, Text } from 'theme-ui' import { FlexSectionContainer } from './elements' import { FieldArray } from 'react-final-form-arrays' -import { MACHINE_BUILDER_XP } from 'src/mocks/user_pp.mock' import { CustomCheckbox } from './Fields/CustomCheckbox.field' import theme from 'src/themes/styled.theme' +import type { IMAchineBuilderXp } from 'src/models' interface IProps { required: boolean } +const MACHINE_BUILDER_XP: IMAchineBuilderXp[] = [ + { + label: 'electronics', + }, + { + label: 'machining', + }, + { + label: 'welding', + }, + { + label: 'assembling', + }, + { + label: 'mould-making', + }, +] + export class ExpertiseSection extends React.Component { constructor(props: any) { super(props) diff --git a/src/pages/Settings/content/formSections/Workspace.section.tsx b/src/pages/Settings/content/formSections/Workspace.section.tsx index 91080c4a36..6bac67f50d 100644 --- a/src/pages/Settings/content/formSections/Workspace.section.tsx +++ b/src/pages/Settings/content/formSections/Workspace.section.tsx @@ -2,11 +2,50 @@ import * as React from 'react' import { Flex, Heading, Box, Text } from 'theme-ui' import { FlexSectionContainer } from './elements' -import { WORKSPACE_TYPES } from 'src/mocks/user_pp.mock' import { CustomRadioField } from './Fields/CustomRadio.field' import { required } from 'src/utils/validators' import theme from 'src/themes/styled.theme' import { Field } from 'react-final-form' +import type { IWorkspaceType } from 'src/models' + +import Extrusion from 'src/assets/images/workspace-focus/extrusion.png' +import Injection from 'src/assets/images/workspace-focus/injection.png' +import Mix from 'src/assets/images/workspace-focus/mix.png' +import Sheetpress from 'src/assets/images/workspace-focus/sheetpress.png' +import Shredder from 'src/assets/images/workspace-focus/shredder.png' + +const WORKSPACE_TYPES: IWorkspaceType[] = [ + { + label: 'shredder', + textLabel: 'Shredder', + subText: 'Shredding plastic waste into flakes', + imageSrc: Shredder, + }, + { + label: 'sheetpress', + textLabel: 'Sheetpress', + subText: 'Making recycled plastic sheets', + imageSrc: Sheetpress, + }, + { + label: 'extrusion', + textLabel: 'Extrusion', + subText: 'Extruding plastic into beams or products', + imageSrc: Extrusion, + }, + { + label: 'injection', + textLabel: 'Injection', + subText: 'Making small productions of goods', + imageSrc: Injection, + }, + { + label: 'mix', + textLabel: 'Mix', + subText: 'Running a workspace with multiple machines and goals', + imageSrc: Mix, + }, +] export class WorkspaceSection extends React.Component { render() { From d0230396f6d0d3cd67b95ed36e782d9b39809402 Mon Sep 17 00:00:00 2001 From: Luke Watts Date: Wed, 25 Jan 2023 21:24:32 +0100 Subject: [PATCH 3/3] chore: move map store helpers closer to call site These helper methods are only used within the map.store and should be moved closer to make the code structure easier to reason with. --- src/mocks/db.mock.tsx | 22 ------------------ .../Maps/generatePins.tsx} | 23 ++++++++++++++++++- src/stores/Maps/maps.store.ts | 2 +- 3 files changed, 23 insertions(+), 24 deletions(-) delete mode 100644 src/mocks/db.mock.tsx rename src/{mocks/maps.mock.tsx => stores/Maps/generatePins.tsx} (70%) diff --git a/src/mocks/db.mock.tsx b/src/mocks/db.mock.tsx deleted file mode 100644 index 754ab7bca5..0000000000 --- a/src/mocks/db.mock.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import type { DBDoc } from 'src/models/common.models' -import { randomID } from 'src/utils/helpers' - -// helper methods used in generation of mock db data -export const MOCK_DB_META = (id?: string) => { - const d1 = randomDate(new Date(2012, 0, 1), new Date()) - const d2 = randomDate(d1, new Date()) - const meta: DBDoc = { - _created: d1.toISOString(), - _modified: d2.toISOString(), - _deleted: false, - _id: id ? id : randomID(), - } - return meta -} - -// generate a random date between start and end -function randomDate(start: Date, end: Date) { - return new Date( - start.getTime() + Math.random() * (end.getTime() - start.getTime()), - ) -} diff --git a/src/mocks/maps.mock.tsx b/src/stores/Maps/generatePins.tsx similarity index 70% rename from src/mocks/maps.mock.tsx rename to src/stores/Maps/generatePins.tsx index 00324796cd..2db8a10a73 100644 --- a/src/mocks/maps.mock.tsx +++ b/src/stores/Maps/generatePins.tsx @@ -1,8 +1,29 @@ import { loremIpsum } from 'lorem-ipsum' import type { IMapPin, IMapPinDetail } from 'src/models/maps.models' -import { MOCK_DB_META } from './db.mock' +import type { DBDoc } from 'src/models/common.models' +import { randomID } from 'src/utils/helpers' import { MAP_GROUPINGS } from 'src/stores/Maps/maps.groupings' +// helper methods used in generation of mock db data +const MOCK_DB_META = (id?: string) => { + const d1 = randomDate(new Date(2012, 0, 1), new Date()) + const d2 = randomDate(d1, new Date()) + const meta: DBDoc = { + _created: d1.toISOString(), + _modified: d2.toISOString(), + _deleted: false, + _id: id ? id : randomID(), + } + return meta +} + +// generate a random date between start and end +function randomDate(start: Date, end: Date) { + return new Date( + start.getTime() + Math.random() * (end.getTime() - start.getTime()), + ) +} + export const generatePins = (count: number): Array => { const filters = MAP_GROUPINGS const newPins = [] as Array diff --git a/src/stores/Maps/maps.store.ts b/src/stores/Maps/maps.store.ts index f6f65a7d7f..8b4e60362a 100644 --- a/src/stores/Maps/maps.store.ts +++ b/src/stores/Maps/maps.store.ts @@ -12,7 +12,7 @@ import type { Subscription } from 'rxjs' import { ModuleStore } from '../common/module.store' import { getUserAvatar } from '../User/user.store' import { MAP_GROUPINGS } from './maps.groupings' -import { generatePins, generatePinDetails } from 'src/mocks/maps.mock' +import { generatePins, generatePinDetails } from 'src/stores/Maps/generatePins' import type { IUserPP } from 'src/models/user_pp.models' import type { IUploadedFileMeta } from '../storage' import {