Skip to content

Commit

Permalink
✨ Mutations in progress for webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Dec 4, 2023
1 parent 5ed296b commit 6ac4e6c
Show file tree
Hide file tree
Showing 17 changed files with 506 additions and 181 deletions.
40 changes: 39 additions & 1 deletion packages/api/scripts/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,45 @@ async function main() {
},
],
});*/
const entitiesData = [
{
id_entity: uuidv4(),
ressource_owner_id: 'contact',
},
{
id_entity: uuidv4(),
ressource_owner_id: 'task',
},
{
id_entity: uuidv4(),
ressource_owner_id: 'company',
},
{
id_entity: uuidv4(),
ressource_owner_id: 'note',
},
];
await prisma.entity.createMany({
data: entitiesData,
});

const attributesData = entitiesData.map((entity, index) => ({
id_attribute: uuidv4(),
status: 'defined',
ressource_owner_type: `contact`,
slug: `slug_${index + 1}`,
description: `Description for attribute ${index + 1}`,
data_type: `string`,
remote_id: ``,
source: ``,
id_entity: entity.id_entity,
scope: `user`,
}));

await prisma.attribute.createMany({
data: attributesData,
});
/*
// Seed the `jobs` table with 20 jobs
const apiKeysData = Array.from({ length: 4 }).map((_, index) => ({
id_api_key: uuidv4(),
Expand All @@ -117,7 +155,7 @@ async function main() {
}));
await prisma.api_keys.createMany({
data: apiKeysData,
});
});*/
}

main()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ export class FieldMappingController {
mapFieldToProvider(@Body() mapFieldToProviderDto: MapFieldToProviderDto) {
return this.fieldMappingService.mapFieldToProvider(mapFieldToProviderDto);
}
//TODO: /origin-custom-fields?provider=${provider}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class FieldMappingService {
source: '',
id_entity: id_entity,
scope: 'user', // [user | org] wide
id_consumer: '00000000-0000-0000-0000-000000000000', //default
//id_consumer: '00000000-0000-0000-0000-000000000000', //default
},
});

Expand Down
1 change: 1 addition & 0 deletions packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"react-day-picker": "^8.9.1",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-hot-toast": "^2.4.1",
"react-router-dom": "^6.20.0",
"recharts": "^2.10.1",
"tailwind-merge": "^2.0.0",
Expand Down
18 changes: 18 additions & 0 deletions packages/webapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,31 @@ import JobsPage from './components/jobs';
import ConnectionsPage from './components/connections';
import TaskPage from './components/jobs/JobsTable';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { Toaster } from 'react-hot-toast';

const queryClient = new QueryClient();

function App() {
return (
<QueryClientProvider client={queryClient}>
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
<Toaster
position="bottom-right"
reverseOrder={false}
gutter={8}
containerClassName=""
containerStyle={{}}
toastOptions={{
// Define default options
className: '',
duration: 3000,
style: {
background: '#0A0A0B',
color: '#fff',
border: "0.03rem solid white"
},
}}
/>
<Router>
<Routes>
<Route path="/" element={<DashboardPage />} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,39 @@ import {
} from "@/components/ui/popover"
import { PlusCircledIcon } from "@radix-ui/react-icons"
import { cn } from "@/lib/utils"
import React from "react"
import { useState } from "react"
import useLinkedUserMutation from "@/hooks/mutations/useLinkedUserMutation"

interface LinkedUserModalObj {
open: boolean;
import?: boolean;
}

const AddLinkedAccount = () => {
const [open, setOpen] = React.useState(false)
const [showNewLinkedUserDialog, setShowNewLinkedUserDialog] = React.useState<LinkedUserModalObj>({
const [open, setOpen] = useState(false)
const [showNewLinkedUserDialog, setShowNewLinkedUserDialog] = useState<LinkedUserModalObj>({
open: false,
import: false
})
const [linkedUserIdentifier, setLinkedUserIdentifier] = useState('');

const { mutate, isLoading, isError, error, isSuccess } = useLinkedUserMutation();

const handleOpenChange = (open: boolean) => {
setShowNewLinkedUserDialog(prevState => ({ ...prevState, open }));
};

const handleSubmit = (e) => {
e.preventDefault(); // Prevent default form submission
mutate({
linked_user_origin_id: linkedUserIdentifier,
alias: "acme.org",
id_project: "43b9d010-367c-45fa-b270-e0cf105a057d"
});
setShowNewLinkedUserDialog({open: false})
};



return (
<Dialog open={showNewLinkedUserDialog.open} onOpenChange={handleOpenChange}>
Expand Down Expand Up @@ -100,13 +116,19 @@ const AddLinkedAccount = () => {
{showNewLinkedUserDialog.import ? "You can upload a sheet of your existing linked users" : "Add a new linked user to your project"}
</DialogDescription>
</DialogHeader>
<form onSubmit={handleSubmit}>
<div>
<div className="space-y-4 py-2 pb-4">
{!showNewLinkedUserDialog.import ?
( <>
<div className="space-y-2">
<Label htmlFor="name">Linked User Origin Identifier</Label>
<Input id="name" placeholder="acme-inc-user-123" />
<Input
id="name"
placeholder="acme-inc-user-123"
value={linkedUserIdentifier}
onChange={(e) => setLinkedUserIdentifier(e.target.value)}
/>
</div>
</>
) :
Expand All @@ -125,6 +147,7 @@ const AddLinkedAccount = () => {
</Button>
<Button type="submit">{showNewLinkedUserDialog.import ? "Import" : "Create"}</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
)
Expand Down
Loading

0 comments on commit 6ac4e6c

Please sign in to comment.