Skip to content

Commit

Permalink
created the task versions screen (#1784)
Browse files Browse the repository at this point in the history
* created the task versions screen

* rendering the versions

* added the bottom sheet and functionalities to add/delete/update

* added translations

* fixed text when there is 1 version

* fixed typo

* fixed version name formatting issue, also fixed background in dark mode
  • Loading branch information
desperado1802 authored Nov 14, 2023
1 parent 5deb2c2 commit b088bc6
Show file tree
Hide file tree
Showing 16 changed files with 584 additions and 5 deletions.
11 changes: 11 additions & 0 deletions apps/mobile/app/i18n/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ const ar: Translations = {
korean: "Korean",
hebrew: "Hebrew",
},
versionScreen: {
mainTitle: "نسخ المهمة",
listOfVersions: "قائمة النسخ",
noActiveVersions: "لا توجد نسخ نشطة",
createNewVersionButton: "إنشاء نسخة جديدة",
createNewVersionText: "إنشاء نسخة جديدة",
versionNamePlaceholder: "اسم النسخة",
cancelButtonText: "إلغاء",
createButtonText: "إنشاء",
updateButtonText: "تحديث",
},
statusScreen: {
mainTitle: "Task Statuses",
statuses: "Statuses",
Expand Down
11 changes: 11 additions & 0 deletions apps/mobile/app/i18n/bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@ const bg = {
korean: "Korean",
hebrew: "Hebrew",
},
versionScreen: {
mainTitle: "Task Versions",
listOfVersions: "List of Versions",
noActiveVersions: "There are no active versions",
createNewVersionButton: "Create new version",
createNewVersionText: "Create New Version",
versionNamePlaceholder: "Version Name",
cancelButtonText: "Cancel",
createButtonText: "Create",
updateButtonText: "Update",
},
statusScreen: {
mainTitle: "Task Statuses",
listStatuses: "List of Statuses",
Expand Down
11 changes: 11 additions & 0 deletions apps/mobile/app/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,17 @@ const en = {
korean: "Korean",
hebrew: "Hebrew",
},
versionScreen: {
mainTitle: "Task Versions",
listOfVersions: "List of Versions",
noActiveVersions: "There are no active versions",
createNewVersionButton: "Create new version",
createNewVersionText: "Create New Version",
versionNamePlaceholder: "Version Name",
cancelButtonText: "Cancel",
createButtonText: "Create",
updateButtonText: "Update",
},
statusScreen: {
mainTitle: "Task Statuses",
statuses: "Statuses",
Expand Down
11 changes: 11 additions & 0 deletions apps/mobile/app/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@ const es = {
korean: "Korean",
hebrew: "Hebrew",
},
versionScreen: {
mainTitle: "Task Versions",
listOfVersions: "List of Versions",
noActiveVersions: "There are no active versions",
createNewVersionButton: "Create new version",
createNewVersionText: "Create New Version",
versionNamePlaceholder: "Version Name",
cancelButtonText: "Cancel",
createButtonText: "Create",
updateButtonText: "Update",
},
statusScreen: {
mainTitle: "Task Statuses",
listStatuses: "List of Statuses",
Expand Down
11 changes: 11 additions & 0 deletions apps/mobile/app/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,17 @@ const fr = {
korean: "Coréen",
hebrew: "Hébreu",
},
versionScreen: {
mainTitle: "Versions de la tâche",
listOfVersions: "Liste des versions",
noActiveVersions: "Aucune version active",
createNewVersionButton: "Créer une nouvelle version",
createNewVersionText: "Créer une nouvelle version",
versionNamePlaceholder: "Nom de la version",
cancelButtonText: "Annuler",
createButtonText: "Créer",
updateButtonText: "Mettre à jour",
},
statusScreen: {
mainTitle: "Task Statuses",
listStatuses: "List of Statuses",
Expand Down
11 changes: 11 additions & 0 deletions apps/mobile/app/i18n/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@ const he = {
korean: "Korean",
hebrew: "Hebrew",
},
versionScreen: {
mainTitle: "Task Versions",
listOfVersions: "List of Versions",
noActiveVersions: "There are no active versions",
createNewVersionButton: "Create new version",
createNewVersionText: "Create New Version",
versionNamePlaceholder: "Version Name",
cancelButtonText: "Cancel",
createButtonText: "Create",
updateButtonText: "Update",
},
statusScreen: {
mainTitle: "Task Statuses",
listStatuses: "List of Statuses",
Expand Down
11 changes: 11 additions & 0 deletions apps/mobile/app/i18n/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,17 @@ const ko: Translations = {
korean: "Korean",
hebrew: "Hebrew",
},
versionScreen: {
mainTitle: "작업 버전",
listOfVersions: "버전 목록",
noActiveVersions: "활성 버전이 없습니다",
createNewVersionButton: "새 버전 생성",
createNewVersionText: "새 버전 생성",
versionNamePlaceholder: "버전 이름",
cancelButtonText: "취소",
createButtonText: "생성",
updateButtonText: "업데이트",
},
statusScreen: {
mainTitle: "Task Statuses",
statuses: "Statuses",
Expand Down
11 changes: 11 additions & 0 deletions apps/mobile/app/i18n/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@ const ru = {
korean: "Korean",
hebrew: "Hebrew",
},
versionScreen: {
mainTitle: "Task Versions",
listOfVersions: "List of Versions",
noActiveVersions: "There are no active versions",
createNewVersionButton: "Create new version",
createNewVersionText: "Create New Version",
versionNamePlaceholder: "Version Name",
cancelButtonText: "Cancel",
createButtonText: "Create",
updateButtonText: "Update",
},
statusScreen: {
mainTitle: "Task Statuses",
listStatuses: "List of Statuses",
Expand Down
3 changes: 3 additions & 0 deletions apps/mobile/app/navigators/AuthenticatedNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
TaskPriorityScreen,
MembersSettingsScreen,
AuthenticatedTaskScreen,
TaskVersionScreen,
} from "../screens"

// HELPERS
Expand Down Expand Up @@ -60,6 +61,7 @@ export type AuthenticatedDrawerParamList = {
TaskSizeScreen: undefined
TaskStatus: undefined
TaskPriority: undefined
TaskVersion: undefined
MembersSettingsScreen: undefined
TaskScreen: { taskId: string }
}
Expand Down Expand Up @@ -252,6 +254,7 @@ export const AuthenticatedNavigator = observer(function AuthenticatedNavigator()
<drawer.Screen name="AuthenticatedTab" component={TabNavigator} />
<drawer.Screen name="TaskScreen" component={AuthenticatedTaskScreen} />
<drawer.Screen name="Setting" component={AuthenticatedSettingScreen} />
<drawer.Screen name="TaskVersion" component={TaskVersionScreen} />
<drawer.Screen name="TaskStatus" component={TaskStatusScreen} />
<drawer.Screen name="TaskLabelScreen" component={TaskLabelScreen} />
<drawer.Screen name="TaskSizeScreen" component={TaskSizeScreen} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useTaskStatus } from "../../../../services/hooks/features/useTaskStatus
import { useTaskPriority } from "../../../../services/hooks/features/useTaskPriority"
import { useTaskSizes } from "../../../../services/hooks/features/useTaskSizes"
import { useTaskLabels } from "../../../../services/hooks/features/useTaskLabels"
import { useTaskVersion } from "../../../../services/hooks/features/useTaskVersion"

interface ITeamSettingProps {
props: any
Expand All @@ -35,6 +36,7 @@ const TeamSettings: FC<ITeamSettingProps> = observer(({ props, onOpenBottomSheet
const { priorities } = useTaskPriority()
const { sizes } = useTaskSizes()
const { labels } = useTaskLabels()
const { versions } = useTaskVersion()

return (
<View style={[$contentContainer, { backgroundColor: colors.background, opacity: 0.9 }]}>
Expand All @@ -54,6 +56,13 @@ const TeamSettings: FC<ITeamSettingProps> = observer(({ props, onOpenBottomSheet
onPress={() => onOpenBottomSheet("Team Name", 4)}
/>
{isTeamManager ? <SwithTimeTracking /> : null}

Check warning on line 58 in apps/mobile/app/screens/Authenticated/SettingScreen/Team/index.tsx

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (Swith)
<SingleInfo
title={"Task Versions"}
value={`There ${versions?.total === 1 ? "is" : "are"} ${
versions?.total
} active ${versions?.total === 1 ? "version" : "versions"}`}
onPress={() => navigation.navigate("TaskVersion")}
/>
<SingleInfo
title={translate("settingScreen.teamSection.taskStatuses")}
value={`There are ${statuses?.total} active statuses`}
Expand All @@ -71,7 +80,7 @@ const TeamSettings: FC<ITeamSettingProps> = observer(({ props, onOpenBottomSheet
/>
<SingleInfo
title={translate("settingScreen.teamSection.taskLabel")}
value={`There ${labels?.total < 2 ? "is" : "are"} ${labels?.total} active ${
value={`There ${labels?.total === 1 ? "is" : "are"} ${labels?.total} active ${
labels?.total === 1 ? "label" : "labels"
}`}
onPress={() => navigation.navigate("TaskLabelScreen")}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/* eslint-disable react-native/no-color-literals */
/* eslint-disable react-native/no-inline-styles */
import React, { useEffect, useState } from "react"
import { View, Text, TouchableOpacity, TextInput, StyleSheet, Keyboard } from "react-native"
import { translate } from "../../../../i18n"
import { typography, useAppTheme } from "../../../../theme"

import {
ITaskVersionCreate,
ITaskVersionItemList,
} from "../../../../services/interfaces/ITaskVersion"

const TaskVersionForm = ({
isEdit,
onDismiss,
item,
onCreateVersion,
onUpdateVersion,
}: {
isEdit: boolean
onDismiss: () => unknown
item?: ITaskVersionItemList
onUpdateVersion: (id: string, data: ITaskVersionCreate) => unknown
onCreateVersion: (data: ITaskVersionCreate) => unknown
}) => {
const { colors, dark } = useAppTheme()
const [versionName, setVersionName] = useState<string>(null)

useEffect(() => {
if (isEdit) {
setVersionName(item.name)
} else {
setVersionName(null)
}
}, [item, isEdit])

const handleSubmit = async () => {
if (versionName.trim().length <= 0) {
return
}

if (isEdit) {
await onUpdateVersion(item?.id, {
name: versionName,
})
} else {
await onCreateVersion({
name: versionName,
color: "#FFFFFF",
})
}

setVersionName(null)
onDismiss()
}

return (
<View
style={{
backgroundColor: colors.background,
paddingHorizontal: 25,
paddingTop: 26,
paddingBottom: 40,
height: 452,
}}
>
<Text style={{ ...styles.formTitle, color: colors.primary }}>
{translate("settingScreen.versionScreen.createNewVersionText")}
</Text>
<TextInput
style={{ ...styles.versionNameInput, color: colors.primary }}
placeholderTextColor={"#7B8089"}
placeholder={translate("settingScreen.versionScreen.versionNamePlaceholder")}
defaultValue={versionName}
onChangeText={(text) => setVersionName(text)}
/>

<View style={styles.wrapButtons}>
<TouchableOpacity
style={styles.cancelBtn}
onPress={() => {
onDismiss()
Keyboard.dismiss()
}}
>
<Text style={styles.cancelTxt}>
{translate("settingScreen.versionScreen.cancelButtonText")}
</Text>
</TouchableOpacity>
<TouchableOpacity
style={{
...styles.createBtn,
backgroundColor: dark ? "#6755C9" : "#3826A6",
opacity: !versionName ? 0.2 : 1,
}}
onPress={() => {
if (versionName) {
handleSubmit().finally(() => Keyboard.dismiss())
}
}}
>
<Text style={styles.createTxt}>
{isEdit
? translate("settingScreen.versionScreen.updateButtonText")
: translate("settingScreen.versionScreen.createButtonText")}
</Text>
</TouchableOpacity>
</View>
</View>
)
}

export default TaskVersionForm

const styles = StyleSheet.create({
cancelBtn: {
alignItems: "center",
backgroundColor: "#E6E6E9",
borderRadius: 12,
height: 57,
justifyContent: "center",
width: "48%",
},
cancelTxt: {
color: "#1A1C1E",
fontFamily: typography.primary.semiBold,
fontSize: 18,
},
createBtn: {
alignItems: "center",
backgroundColor: "#3826A6",
borderRadius: 12,
height: 57,
justifyContent: "center",
width: "48%",
},
createTxt: {
color: "#FFF",
fontFamily: typography.primary.semiBold,
fontSize: 18,
},
formTitle: {
color: "#1A1C1E",
fontFamily: typography.primary.semiBold,
fontSize: 24,
},
versionNameInput: {
alignItems: "center",
borderColor: "#DCE4E8",
borderRadius: 12,
borderWidth: 1,
height: 57,
marginTop: 16,
paddingHorizontal: 18,
width: "100%",
},
wrapButtons: {
flexDirection: "row",
justifyContent: "space-between",
marginTop: 40,
width: "100%",
},
})
Loading

0 comments on commit b088bc6

Please sign in to comment.