Skip to content

Commit

Permalink
Fix project name validation
Browse files Browse the repository at this point in the history
  • Loading branch information
puranban committed Aug 15, 2024
1 parent 037a19f commit a1e3186
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions firebase/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,14 @@ exports.addProjectTopicKey = functions.https.onRequest(async (_, res) => {
res.status(404).send('No projects found');
}

if (!isEmptyProject && data) {
if (data) {
const newProjectData: {[key: string]: string} = {};

Object.keys(data).forEach((id) => {
if (data[id]?.projectTopic) {
const newProjectTopicKey = formatProjectTopic(data[id].projectTopic);
const projectData = data[id];

if (projectData.name) {
const newProjectTopicKey = formatProjectTopic(projectData.name);
newProjectData[`v2/projects/${id}/projectTopicKey`] = newProjectTopicKey;
}
});
Expand Down
8 changes: 4 additions & 4 deletions manager-dashboard/app/views/NewProject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function NewProject(props: Props) {
visibility,
filter,
filterText,
projectTopic,
name,
...valuesToCopy
} = finalValues;

Expand Down Expand Up @@ -331,8 +331,8 @@ function NewProject(props: Props) {
// NOTE: All the user don't have permission to access draft project
// FIXME: The firebase rules need to be changed to perform this on draft project
const database = getDatabase();
const projectTopicKeyLowercase = (projectTopic?.trim())?.toLowerCase() as string;
const projectTopicKey = formatProjectTopic(projectTopicKeyLowercase);
// const projectTopicKeyLowercase = (name?.trim())?.toLowerCase() as string;
const projectTopicKey = formatProjectTopic(name);
const projectRef = databaseRef(database, 'v2/projects/');

const prevProjectNameQuery = query(
Expand Down Expand Up @@ -369,7 +369,7 @@ function NewProject(props: Props) {

const uploadData = {
...valuesToCopy,
projectTopic,
name,
projectTopicKey,
filter: finalFilter,
image: downloadUrl,
Expand Down

0 comments on commit a1e3186

Please sign in to comment.