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

Ph #95

Open
wants to merge 47 commits into
base: develop
Choose a base branch
from
Open

Ph #95

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c6e7eee
Add optional github config submodule
amitchellunicef Feb 21, 2024
2c4b524
Add script to remove legacy translation keys
amitchellunicef Apr 9, 2024
56b2d41
Add new translation keys
amitchellunicef Apr 9, 2024
a8a0d9a
Add new emojis
amitchellunicef Apr 9, 2024
a5786a9
PH API changes
amitchellunicef Apr 9, 2024
b440d39
Make new PH keys optional
amitchellunicef Apr 9, 2024
3d00c04
Add new cms packages
amitchellunicef Apr 9, 2024
2c255b2
Add cms translations
amitchellunicef Feb 22, 2024
25f0a1e
Allow optional restriction of cms languages via submodule
amitchellunicef Apr 9, 2024
6c2a504
Alter database
amitchellunicef Apr 9, 2024
4db1f0b
Add missing schema name to SQL
amitchellunicef Apr 9, 2024
e996235
Remove unused api request
amitchellunicef Apr 10, 2024
977579d
PH core changes
amitchellunicef Apr 12, 2024
1efb424
PH Core mappers
amitchellunicef Apr 12, 2024
daa656c
Add new columns to sheet content generator
amitchellunicef Mar 4, 2024
b5c5c57
Dont specify helpCenter id in sql
amitchellunicef Mar 6, 2024
fa6f20b
Generate ts from CMS requests
amitchellunicef Apr 12, 2024
51945d4
Update .lock files
amitchellunicef Apr 15, 2024
7151732
Fix type inconsistencies
amitchellunicef Apr 15, 2024
13994c6
CMS changes
amitchellunicef Apr 15, 2024
00847a1
Add aws env
amitchellunicef Apr 15, 2024
f42241f
Add config folder to gitignore
amitchellunicef Apr 15, 2024
8bf003c
Remove content controller import
amitchellunicef Apr 15, 2024
b99669b
Prevent page break
amitchellunicef Apr 15, 2024
1b3b195
Update voiceOvers script with latest changes
amitchellunicef Apr 15, 2024
140fe07
Add isSelected prop to SubCategoryCard
amitchellunicef Apr 17, 2024
a48a03b
Add color prop to TextWithoutTranslation
amitchellunicef Apr 18, 2024
a6427e1
Add Icon prop types
amitchellunicef Apr 18, 2024
f8608cb
Add TextInput types
amitchellunicef Apr 18, 2024
bd1ffe8
Fix textInput style
amitchellunicef Apr 18, 2024
c2c8e46
Refactor ModalSearchBox & AskLocation
amitchellunicef Apr 19, 2024
6f7296c
Add comment
amitchellunicef Apr 20, 2024
c156cdf
Update types
amitchellunicef Apr 20, 2024
bc64ba2
Add age calculation services
amitchellunicef Apr 20, 2024
5390ef5
Refactor article screen age restriction & add html packages
amitchellunicef Apr 23, 2024
8b1c050
Add todo
amitchellunicef Apr 23, 2024
8f68fdd
Add todos
amitchellunicef Apr 23, 2024
3558764
Add todos
amitchellunicef Apr 23, 2024
04c09b8
Add warning haptic to Login
amitchellunicef Apr 23, 2024
a9b017c
Ignore expo
amitchellunicef Apr 25, 2024
749df38
HTML services for articles
amitchellunicef Apr 25, 2024
c57175e
Add Article type
amitchellunicef Apr 25, 2024
114f2af
Add extra day carousel card emojis
amitchellunicef Apr 25, 2024
68a383f
Add todo
amitchellunicef Apr 25, 2024
b6e5bf8
Add city to User type
amitchellunicef Apr 25, 2024
703e647
Add fuse search
amitchellunicef Apr 25, 2024
eec804d
Add city to signup initial state
amitchellunicef Apr 25, 2024
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ yarn-error.log
.obsidian
.gitmodules
/bin/modules/urls.sh
*.env
*.env
config
packages/app/.expo
1 change: 1 addition & 0 deletions bin/modules/paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ k8s_path=".k8s"
delete_account_path="packages/delete-account"

# Optional
github_config_path=".github"
flower_path="packages/components/src/optional/Flower"
custom_components_path="packages/components/src/optional/CustomComponents"
1 change: 1 addition & 0 deletions bin/modules/pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ git submodule add $translations_url $translations_path
git submodule add $delete_account_url $delete_account_path

# Optional modules
[ -n "$github_config_url" ] && git submodule add $github_config_url $github_config_path
[ -n "$flower_url" ] && git submodule add $flower_url $flower_path
[ -n "$custom_components_url" ] && git submodule add $custom_components_url $custom_components_path

Expand Down
1 change: 1 addition & 0 deletions bin/modules/urls.sh.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ k8s_url="[email protected]:Oky-period-tracker/periodtracker_k8s-whitelabelled.git"
delete_account_url="[email protected]:Oky-period-tracker/periodtracker_delete_account-whitelabelled.git"

# Optional
# github_config_url=""
# flower_url="[email protected]:Oky-period-tracker/periodtracker_flower.git"
76 changes: 76 additions & 0 deletions generate-content-ts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import fs from 'fs'

import {
fromAvatarMessages,
fromDidYouKnows,
fromEncyclopedia,
fromHelpCenters,
fromQuizzes,
} from '@oky/core/src'
import { logger } from './logger'

/*
This is for generating content .ts files via the JSON returned from the cms endpoints
Send requests to the endpoints, copy paste the data into the file, ensure the locale value is correct.

Execute this via the terminal:
npx ts-node --transpile-only generate-content-ts.ts
*/

const locale = 'en'

// /mobile/articles/:locale
const encyclopediaRaw: any = []

// /mobile/quizzes/:locale
const quizzesRaw = []

// /mobile/didyouknows/:locale
const didYouKnowsRaw = []

// /mobile/help-center/:locale
const helpCentersRaw = []

// /mobile/avatar-messages/:locale
const avatarMessagesRaw = []

const { articles, categories, subCategories } = fromEncyclopedia({
encyclopediaResponse: encyclopediaRaw,
})
const { quizzes } = fromQuizzes(quizzesRaw)
const { didYouKnows } = fromDidYouKnows(didYouKnowsRaw)
const { helpCenters } = fromHelpCenters(helpCentersRaw)
const { avatarMessages } = fromAvatarMessages(avatarMessagesRaw)

// /mobile/privacy-policy/:locale
const privacyPolicy = []

// /mobile//terms-and-conditions/:locale
const termsAndConditions = []

// /mobile/about/:locale
const about = []

// /mobile/about-banner/:locale
const aboutBanner = ''

const fileContent = `
export const ${locale} = {
locale: '${locale}',
categories: ${JSON.stringify(categories)},
subCategories: ${JSON.stringify(subCategories)},
articles: ${JSON.stringify(articles)},
quizzes: ${JSON.stringify(quizzes)},
didYouKnows: ${JSON.stringify(didYouKnows)},
helpCenters: ${JSON.stringify(helpCenters)},
avatarMessages: ${JSON.stringify(avatarMessages)},
privacyPolicy: ${JSON.stringify(privacyPolicy)},
termsAndConditions: ${JSON.stringify(termsAndConditions)},
about: ${JSON.stringify(about)},
aboutBanner: '${aboutBanner}',
}
`

fs.writeFileSync(`${locale}.ts`, fileContent)

logger(`Successfully generated file: ${locale}.ts`)
3 changes: 1 addition & 2 deletions generateSQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const columnNames = {
'lang',
],
did_you_know: ['id', 'title', 'content', 'isAgeRestricted', 'live', 'lang'],
help_center: ['id', 'title', 'caption', 'contactOne', 'contactTwo', 'address', 'website', 'lang'],
help_center: ['title', 'caption', 'contactOne', 'contactTwo', 'address', 'website', 'lang'],
avatar_messages: ['id', 'content', 'live', 'lang'],
privacy_policy: ['json_dump', 'timestamp', 'lang'],
terms_and_conditions: ['json_dump', 'timestamp', 'lang'],
Expand Down Expand Up @@ -204,7 +204,6 @@ const getDidYouKnows = (content: StaticContent) => {
const getHelpCenters = (content: StaticContent) => {
return content.helpCenters.map((entry) => {
return [
entry.id,
entry.title,
entry.caption,
entry.contactOne,
Expand Down
18 changes: 14 additions & 4 deletions packages/api/src/application/oky/OkyUserApplicationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class OkyUserApplicationService {
accommodationRequirement,
religion,
encyclopediaVersion,
city,
}: SignupCommand) {
const id = preferredId || (await this.okyUserRepository.nextIdentity())
if (await this.okyUserRepository.byId(id)) {
Expand Down Expand Up @@ -79,6 +80,7 @@ export class OkyUserApplicationService {
accommodationRequirement,
religion,
encyclopediaVersion,
city,
})
return this.okyUserRepository.save(user)
}
Expand Down Expand Up @@ -132,6 +134,12 @@ export class OkyUserApplicationService {
location,
gender,
secretQuestion,
genderIdentity,
accommodationRequirement,
religion,
encyclopediaVersion,
city,
isProfileUpdateSkipped,
}: EditInfoCommand) {
const user = await this.okyUserRepository.byId(userId)
if (!user) {
Expand All @@ -144,10 +152,12 @@ export class OkyUserApplicationService {
location,
gender,
secretQuestion,
genderIdentity: user.getGenderIdentity(),
accommodationRequirement: user.getAccommodationRequirement(),
religion: user.getReligion(),
encyclopediaVersion: user.getEncyclopediaVersion(),
genderIdentity,
accommodationRequirement,
religion,
encyclopediaVersion,
city,
isProfileUpdateSkipped,
})

return this.okyUserRepository.save(user)
Expand Down
6 changes: 6 additions & 0 deletions packages/api/src/application/oky/commands/EditInfoCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ export interface EditInfoCommand {
gender: 'Male' | 'Female' | 'Other'
location: string
secretQuestion: string
genderIdentity?: string
accommodationRequirement?: string
religion?: string
encyclopediaVersion?: string
city?: string
isProfileUpdateSkipped?: boolean
}
1 change: 1 addition & 0 deletions packages/api/src/application/oky/commands/SignupCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export interface SignupCommand {
accommodationRequirement?: string
religion?: string
encyclopediaVersion?: string
city?: string
}
37 changes: 35 additions & 2 deletions packages/api/src/domain/oky/OkyUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ interface OkyUserProps {
accommodationRequirement?: string
religion?: string
encyclopediaVersion?: string
city?: string
isProfileUpdateSkipped?: boolean
}

@Entity()
Expand All @@ -41,10 +43,14 @@ export class OkyUser {
@Column({ name: 'location' })
private location: string

@Column({ name: 'country', default: '00', nullable: true })
@Column({
name: 'country',
default: 'PH', // @TODO:PH default kept in submodule?
nullable: true,
})
private country: string

@Column({ name: 'province', default: '0', nullable: true })
@Column({ name: 'province', default: '', nullable: true })
private province: string

@Column((type) => HashedPassword)
Expand Down Expand Up @@ -77,6 +83,12 @@ export class OkyUser {
@Column({ name: 'encyclopediaVersion' })
private encyclopediaVersion: string

@Column({ name: 'city', default: '', nullable: true })
private city: string

@Column({ name: 'isProfileUpdateSkipped', default: false, nullable: true })
private isProfileUpdateSkipped: boolean

private constructor(props?: OkyUserProps) {
if (props !== undefined) {
const {
Expand All @@ -94,6 +106,8 @@ export class OkyUser {
accommodationRequirement,
religion,
encyclopediaVersion,
city,
isProfileUpdateSkipped,
} = props

this.id = id
Expand All @@ -111,6 +125,8 @@ export class OkyUser {
this.accommodationRequirement = accommodationRequirement
this.religion = religion
this.encyclopediaVersion = encyclopediaVersion
this.city = city
this.isProfileUpdateSkipped = isProfileUpdateSkipped
}
}

Expand All @@ -131,6 +147,7 @@ export class OkyUser {
accommodationRequirement,
religion,
encyclopediaVersion,
city,
}: {
id: string
name: string
Expand All @@ -149,6 +166,7 @@ export class OkyUser {
accommodationRequirement?: string
religion?: string
encyclopediaVersion?: string
city?: string
}): Promise<OkyUser> {
if (!id) {
throw new Error(`The user id must be provided`)
Expand Down Expand Up @@ -178,6 +196,7 @@ export class OkyUser {
accommodationRequirement,
religion,
encyclopediaVersion,
city,
})
}

Expand All @@ -198,6 +217,8 @@ export class OkyUser {
accommodationRequirement,
religion,
encyclopediaVersion,
isProfileUpdateSkipped,
city,
}: {
name: string
dateOfBirth: Date
Expand All @@ -209,6 +230,8 @@ export class OkyUser {
accommodationRequirement?: string
religion?: string
encyclopediaVersion?: string
city?: string
isProfileUpdateSkipped?: boolean
}) {
if (!name) {
throw new Error(`The user name must be provided`)
Expand All @@ -224,6 +247,8 @@ export class OkyUser {
this.accommodationRequirement = accommodationRequirement
this.religion = religion
this.encyclopediaVersion = encyclopediaVersion
this.city = city
this.isProfileUpdateSkipped = isProfileUpdateSkipped
}

public async editSecretAnswer(previousSecretAnswer: string, nextSecretAnswer: string) {
Expand Down Expand Up @@ -306,4 +331,12 @@ export class OkyUser {
public getEncyclopediaVersion() {
return this.encyclopediaVersion
}

public getCity() {
return this.city
}

public getIsProfileUpdateSkipped() {
return this.isProfileUpdateSkipped
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class AccountController {
accommodationRequirement,
religion,
encyclopediaVersion,
city,
}: SignupRequest,
) {
if (country === null || country === '00') {
Expand All @@ -79,6 +80,7 @@ export class AccountController {
accommodationRequirement,
religion,
encyclopediaVersion,
city,
})

return this.signTokenResponse(user)
Expand Down Expand Up @@ -149,14 +151,35 @@ export class AccountController {
@CurrentUser({ required: true }) userId: string,
@Body() request: EditInfoRequest,
) {
const { name, gender, dateOfBirth, location, secretQuestion } = request
const {
name,
gender,
dateOfBirth,
secretQuestion,
location,
genderIdentity,
accommodationRequirement,
religion,
encyclopediaVersion,
city,
} = request
let isProfileUpdateSkipped = false
if (!city) {
isProfileUpdateSkipped = true
}
await this.okyUserApplicationService.editInfo({
userId,
name,
gender,
dateOfBirth: new Date(dateOfBirth),
location,
secretQuestion,
genderIdentity,
accommodationRequirement,
religion,
encyclopediaVersion,
city,
isProfileUpdateSkipped,
})

return { userId }
Expand Down Expand Up @@ -201,6 +224,12 @@ export class AccountController {
secretQuestion: user.getMemorableQuestion(),
secretAnswer: user.getHashedMemorableAnswer(),
dateSignedUp: user.getDateSignedUp(),
genderIdentity: user.getGenderIdentity(),
accommodationRequirement: user.getAccommodationRequirement(),
religion: user.getReligion(),
encyclopediaVersion: user.getEncyclopediaVersion(),
city: user.getCity(),
isProfileUpdateSkipped: user.getIsProfileUpdateSkipped(),
}

const appToken = jwt.sign(userDescriptor, env.app.secret, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export class EditInfoRequest {
@IsIn(['Male', 'Female', 'Other'])
public readonly gender: 'Male' | 'Female' | 'Other'

public readonly genderIdentity?: string

public readonly accommodationRequirement?: string

public readonly religion?: string

public readonly encyclopediaVersion?: string

public readonly city?: string

@IsNotEmpty()
public readonly location: string

Expand Down
Loading