Skip to content

Commit

Permalink
Add guid creation in client side
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihkabakk committed May 12, 2022
1 parent 78e005b commit e34194c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
20 changes: 17 additions & 3 deletions client-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions client-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^2.0.4",
"typescript": "^4.4.3",
"uuid": "^8.3.2",
"web-vitals": "^1.1.2"
},
"scripts": {
Expand All @@ -42,5 +43,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/uuid": "^8.3.4"
}
}
5 changes: 4 additions & 1 deletion client-app/src/app/layout/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Container } from 'semantic-ui-react';
import { Activity } from '../models/activity';
import NavBar from './NavBar';
import ActivityDashboard from '../../features/activities/dashboard/ActivityDashboard';
import { v4 as uuid } from 'uuid';

function App() {
const [activities, setActivities] = useState<Activity[]>([]);
Expand All @@ -28,7 +29,9 @@ function App() {
}

const handleCreateOrEditActivity = (activity: Activity) => {
activity.id ? setActivities([...activities.filter(a => a.id !== activity.id), activity]) : setActivities([...activities, activity]);
activity.id
? setActivities([...activities.filter(a => a.id !== activity.id), activity])
: setActivities([...activities, { ...activity, id: uuid() }]);
setEditMode(false);
setSelectedActivity(activity);
}
Expand Down

0 comments on commit e34194c

Please sign in to comment.