From 4995c02cceab6c0172b0ec3fdc12f0c22514d586 Mon Sep 17 00:00:00 2001 From: TereseBo Date: Thu, 28 Mar 2024 12:43:39 +0100 Subject: [PATCH 1/2] updated name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 74cf3b2..787a31d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "nextjs-clerk-starter", + "name": "newweaver", "version": "0.1.0", "private": true, "scripts": { From 365058ced0af42cb167fbce85e2b4f03735f19f0 Mon Sep 17 00:00:00 2001 From: TereseBo Date: Thu, 28 Mar 2024 13:01:20 +0100 Subject: [PATCH 2/2] Structural overhaul of db and file handling folder structure --- .../draft/draftoptions/DbOptions.tsx | 4 ++-- .../draft/draftoptions/DraftSelection.tsx | 4 ++-- .../draft/draftoptions/FileOptions.tsx | 4 ++-- .../dbhandler/DbLoadWeave.tsx | 4 ++-- .../dbhandler/DbSaveWeave.tsx | 10 +++++----- .../dbhandler/DraftPreview.tsx | 20 +++++++++---------- .../dbhandler/draftpreview.scss | 0 .../filehandler/Downloadweave.tsx | 2 +- .../filehandler/Uploadweave.tsx | 2 +- .../filehandler/uploadweave.scss | 0 .../Weavetemplate.ts | 0 .../get/collectTieup.ts | 0 .../get/collectWarp.ts | 0 .../get/collectWeft.ts | 0 .../get/createWeaveObject.ts | 0 .../set/readTieup.ts | 0 .../set/readWarp.ts | 0 .../set/readWeaveObject.ts | 0 .../set/readWeft.ts | 0 .../functions => weaveObjHandler}/utils.ts | 0 app/resources/contexts/weavecontext.tsx | 4 ++-- package.json | 2 +- 22 files changed, 28 insertions(+), 28 deletions(-) rename app/components/draft/{ => draftoptions}/dbhandler/DbLoadWeave.tsx (90%) rename app/components/draft/{ => draftoptions}/dbhandler/DbSaveWeave.tsx (78%) rename app/components/draft/{ => draftoptions}/dbhandler/DraftPreview.tsx (84%) rename app/components/draft/{ => draftoptions}/dbhandler/draftpreview.scss (100%) rename app/components/draft/{ => draftoptions}/filehandler/Downloadweave.tsx (90%) rename app/components/draft/{ => draftoptions}/filehandler/Uploadweave.tsx (96%) rename app/components/draft/{ => draftoptions}/filehandler/uploadweave.scss (100%) rename app/components/draft/{filehandler/functions => weaveObjHandler}/Weavetemplate.ts (100%) rename app/components/draft/{filehandler/functions => weaveObjHandler}/get/collectTieup.ts (100%) rename app/components/draft/{filehandler/functions => weaveObjHandler}/get/collectWarp.ts (100%) rename app/components/draft/{filehandler/functions => weaveObjHandler}/get/collectWeft.ts (100%) rename app/components/draft/{filehandler/functions => weaveObjHandler}/get/createWeaveObject.ts (100%) rename app/components/draft/{filehandler/functions => weaveObjHandler}/set/readTieup.ts (100%) rename app/components/draft/{filehandler/functions => weaveObjHandler}/set/readWarp.ts (100%) rename app/components/draft/{filehandler/functions => weaveObjHandler}/set/readWeaveObject.ts (100%) rename app/components/draft/{filehandler/functions => weaveObjHandler}/set/readWeft.ts (100%) rename app/components/draft/{filehandler/functions => weaveObjHandler}/utils.ts (100%) diff --git a/app/components/draft/draftoptions/DbOptions.tsx b/app/components/draft/draftoptions/DbOptions.tsx index 21bbfee..997269c 100644 --- a/app/components/draft/draftoptions/DbOptions.tsx +++ b/app/components/draft/draftoptions/DbOptions.tsx @@ -1,5 +1,5 @@ -import { DbLoadWeave } from '@/app/components/draft/dbhandler/DbLoadWeave' -import { DbSaveWeave } from '@/app/components/draft/dbhandler/DbSaveWeave' +import { DbLoadWeave } from '@/app/components/draft/draftoptions/dbhandler/DbLoadWeave' +import { DbSaveWeave } from '@/app/components/draft/draftoptions/dbhandler/DbSaveWeave' export function DbOptions() { return ( diff --git a/app/components/draft/draftoptions/DraftSelection.tsx b/app/components/draft/draftoptions/DraftSelection.tsx index eb7a895..6d97071 100644 --- a/app/components/draft/draftoptions/DraftSelection.tsx +++ b/app/components/draft/draftoptions/DraftSelection.tsx @@ -1,9 +1,9 @@ //This component renders a list of drafts from the DB, including a generated preview. import './draftselection.scss' //The styling is heavy on this component in order to render as desired -import { useContext} from 'react' +import { useContext } from 'react' -import { DraftPreview } from '@/app/components/draft/dbhandler/DraftPreview' +import { DraftPreview } from '@/app/components/draft/draftoptions/dbhandler/DraftPreview' import { WeaveContext } from '@/app/resources/contexts/weavecontext' import { DraftList } from '@/app/resources/types/dbdocuments' diff --git a/app/components/draft/draftoptions/FileOptions.tsx b/app/components/draft/draftoptions/FileOptions.tsx index 11421a4..45e4dab 100644 --- a/app/components/draft/draftoptions/FileOptions.tsx +++ b/app/components/draft/draftoptions/FileOptions.tsx @@ -1,5 +1,5 @@ -import { Downloadweave } from '@/app/components/draft/filehandler/Downloadweave' -import { Uploadweave } from '@/app/components/draft/filehandler/Uploadweave' +import { Downloadweave } from '@/app/components/draft/draftoptions/filehandler/Downloadweave' +import { Uploadweave } from '@/app/components/draft/draftoptions/filehandler/Uploadweave' export function FileOptions() { return ( diff --git a/app/components/draft/dbhandler/DbLoadWeave.tsx b/app/components/draft/draftoptions/dbhandler/DbLoadWeave.tsx similarity index 90% rename from app/components/draft/dbhandler/DbLoadWeave.tsx rename to app/components/draft/draftoptions/dbhandler/DbLoadWeave.tsx index 2beb3fc..c14e55c 100644 --- a/app/components/draft/dbhandler/DbLoadWeave.tsx +++ b/app/components/draft/draftoptions/dbhandler/DbLoadWeave.tsx @@ -5,7 +5,7 @@ import { useAuth } from '@clerk/nextjs' import { DraftList } from '@/app/resources/types/dbdocuments' -import { DraftSelection } from '../draftoptions/DraftSelection' +import { DraftSelection } from '../DraftSelection' export function DbLoadWeave() { @@ -37,7 +37,7 @@ export function DbLoadWeave() { return ( <> - {visibleDraftList ? : null} + {visibleDraftList ? : null} diff --git a/app/components/draft/dbhandler/DbSaveWeave.tsx b/app/components/draft/draftoptions/dbhandler/DbSaveWeave.tsx similarity index 78% rename from app/components/draft/dbhandler/DbSaveWeave.tsx rename to app/components/draft/draftoptions/dbhandler/DbSaveWeave.tsx index 07ba69d..1d882c5 100644 --- a/app/components/draft/dbhandler/DbSaveWeave.tsx +++ b/app/components/draft/draftoptions/dbhandler/DbSaveWeave.tsx @@ -3,13 +3,13 @@ import { useContext } from 'react' import { useAuth } from '@clerk/nextjs' -import { createWeaveObject } from '@/app/components/draft/filehandler/functions/get/createWeaveObject' +import { createWeaveObject } from '@/app/components/draft/weaveObjHandler/get/createWeaveObject' import { WeaveContext } from '@/app/resources/contexts/weavecontext' export function DbSaveWeave() { const { treadleGrid, tieUpGrid, warpGrid } = useContext(WeaveContext) as WeaveContextType -//TODO: Add validation to ensure empty draft is not saved + //TODO: Add validation to ensure empty draft is not saved const { userId } = useAuth() @@ -27,9 +27,9 @@ export function DbSaveWeave() { }).then(function (response) { console.log(response) if (response.status == 201) { - console.log('sucsess', response) - }else{ - alert('Ops, the draft could not be saved') + alert('Draft saved!') + } else { + alert('Ops, the draft could not be saved') } }) } diff --git a/app/components/draft/dbhandler/DraftPreview.tsx b/app/components/draft/draftoptions/dbhandler/DraftPreview.tsx similarity index 84% rename from app/components/draft/dbhandler/DraftPreview.tsx rename to app/components/draft/draftoptions/dbhandler/DraftPreview.tsx index 76ff79a..3ecca2f 100644 --- a/app/components/draft/dbhandler/DraftPreview.tsx +++ b/app/components/draft/draftoptions/dbhandler/DraftPreview.tsx @@ -4,23 +4,23 @@ import './draftpreview.scss'; import { useEffect, useState } from 'react' import { Grid } from '@/app/components/draft/draft/Grid' -import { readWeaveObject } from '@/app/components/draft/filehandler/functions/set/readWeaveObject' +import { readWeaveObject } from '@/app/components/draft/weaveObjHandler/set/readWeaveObject' -export function DraftPreview(params:{weaveObj:WeaveObject}) { - - const [previewGrid, setPreviewGrid] = useState(new Array(10).fill(new Array(10).fill('', 0))) - const {weaveObj}=params +export function DraftPreview(params: { weaveObj: WeaveObject }) { + + const [previewGrid, setPreviewGrid] = useState(new Array(10).fill(new Array(10).fill('', 0))) + const { weaveObj } = params useEffect(() => { //Create grids for reading the weave¨ - let shafts= weaveObj.shafts.count || 0 + let shafts = weaveObj.shafts.count || 0 let newGrids = readWeaveObject(params.weaveObj) //Trim since preview cant contain the full width - let shortTreadleGrid= newGrids.treadleGrid.slice(-11,-1) - let shortWarpGrid= newGrids.warpGrid.map(row=>{return row.slice(-11,-1)}) - let tieUpGrid=newGrids.tieupGrid + let shortTreadleGrid = newGrids.treadleGrid.slice(-11, -1) + let shortWarpGrid = newGrids.warpGrid.map(row => { return row.slice(-11, -1) }) + let tieUpGrid = newGrids.tieupGrid //Returns the color if present for the beat function getWeftColor(y: number) { @@ -112,7 +112,7 @@ export function DraftPreview(params:{weaveObj:WeaveObject}) { return (
- +
) diff --git a/app/components/draft/dbhandler/draftpreview.scss b/app/components/draft/draftoptions/dbhandler/draftpreview.scss similarity index 100% rename from app/components/draft/dbhandler/draftpreview.scss rename to app/components/draft/draftoptions/dbhandler/draftpreview.scss diff --git a/app/components/draft/filehandler/Downloadweave.tsx b/app/components/draft/draftoptions/filehandler/Downloadweave.tsx similarity index 90% rename from app/components/draft/filehandler/Downloadweave.tsx rename to app/components/draft/draftoptions/filehandler/Downloadweave.tsx index a54fb0f..2cc0ec3 100644 --- a/app/components/draft/filehandler/Downloadweave.tsx +++ b/app/components/draft/draftoptions/filehandler/Downloadweave.tsx @@ -3,7 +3,7 @@ import Link from 'next/link' import { WeaveContext } from '@/app/resources/contexts/weavecontext' -import { createWeaveObject } from './functions/get/createWeaveObject' +import { createWeaveObject } from '../../weaveObjHandler/get/createWeaveObject' export function Downloadweave() { const { treadleGrid, tieUpGrid, warpGrid } = useContext(WeaveContext) as WeaveContextType diff --git a/app/components/draft/filehandler/Uploadweave.tsx b/app/components/draft/draftoptions/filehandler/Uploadweave.tsx similarity index 96% rename from app/components/draft/filehandler/Uploadweave.tsx rename to app/components/draft/draftoptions/filehandler/Uploadweave.tsx index 1d50d67..36ae217 100644 --- a/app/components/draft/filehandler/Uploadweave.tsx +++ b/app/components/draft/draftoptions/filehandler/Uploadweave.tsx @@ -6,7 +6,7 @@ import { useContext, useState } from 'react' import { WeaveContext } from '@/app/resources/contexts/weavecontext' import { toggleBool } from '@/app/resources/functions/toggleBool' -import { readWeaveObject } from './functions/set/readWeaveObject' +import { readWeaveObject } from '../../weaveObjHandler/set/readWeaveObject' export function Uploadweave() { const { updateGrid } = useContext(WeaveContext) as WeaveContextType diff --git a/app/components/draft/filehandler/uploadweave.scss b/app/components/draft/draftoptions/filehandler/uploadweave.scss similarity index 100% rename from app/components/draft/filehandler/uploadweave.scss rename to app/components/draft/draftoptions/filehandler/uploadweave.scss diff --git a/app/components/draft/filehandler/functions/Weavetemplate.ts b/app/components/draft/weaveObjHandler/Weavetemplate.ts similarity index 100% rename from app/components/draft/filehandler/functions/Weavetemplate.ts rename to app/components/draft/weaveObjHandler/Weavetemplate.ts diff --git a/app/components/draft/filehandler/functions/get/collectTieup.ts b/app/components/draft/weaveObjHandler/get/collectTieup.ts similarity index 100% rename from app/components/draft/filehandler/functions/get/collectTieup.ts rename to app/components/draft/weaveObjHandler/get/collectTieup.ts diff --git a/app/components/draft/filehandler/functions/get/collectWarp.ts b/app/components/draft/weaveObjHandler/get/collectWarp.ts similarity index 100% rename from app/components/draft/filehandler/functions/get/collectWarp.ts rename to app/components/draft/weaveObjHandler/get/collectWarp.ts diff --git a/app/components/draft/filehandler/functions/get/collectWeft.ts b/app/components/draft/weaveObjHandler/get/collectWeft.ts similarity index 100% rename from app/components/draft/filehandler/functions/get/collectWeft.ts rename to app/components/draft/weaveObjHandler/get/collectWeft.ts diff --git a/app/components/draft/filehandler/functions/get/createWeaveObject.ts b/app/components/draft/weaveObjHandler/get/createWeaveObject.ts similarity index 100% rename from app/components/draft/filehandler/functions/get/createWeaveObject.ts rename to app/components/draft/weaveObjHandler/get/createWeaveObject.ts diff --git a/app/components/draft/filehandler/functions/set/readTieup.ts b/app/components/draft/weaveObjHandler/set/readTieup.ts similarity index 100% rename from app/components/draft/filehandler/functions/set/readTieup.ts rename to app/components/draft/weaveObjHandler/set/readTieup.ts diff --git a/app/components/draft/filehandler/functions/set/readWarp.ts b/app/components/draft/weaveObjHandler/set/readWarp.ts similarity index 100% rename from app/components/draft/filehandler/functions/set/readWarp.ts rename to app/components/draft/weaveObjHandler/set/readWarp.ts diff --git a/app/components/draft/filehandler/functions/set/readWeaveObject.ts b/app/components/draft/weaveObjHandler/set/readWeaveObject.ts similarity index 100% rename from app/components/draft/filehandler/functions/set/readWeaveObject.ts rename to app/components/draft/weaveObjHandler/set/readWeaveObject.ts diff --git a/app/components/draft/filehandler/functions/set/readWeft.ts b/app/components/draft/weaveObjHandler/set/readWeft.ts similarity index 100% rename from app/components/draft/filehandler/functions/set/readWeft.ts rename to app/components/draft/weaveObjHandler/set/readWeft.ts diff --git a/app/components/draft/filehandler/functions/utils.ts b/app/components/draft/weaveObjHandler/utils.ts similarity index 100% rename from app/components/draft/filehandler/functions/utils.ts rename to app/components/draft/weaveObjHandler/utils.ts diff --git a/app/resources/contexts/weavecontext.tsx b/app/resources/contexts/weavecontext.tsx index 7f93034..f15f1a2 100644 --- a/app/resources/contexts/weavecontext.tsx +++ b/app/resources/contexts/weavecontext.tsx @@ -2,7 +2,7 @@ //dependencies import { createContext, useEffect, useState } from 'react' -import { readWeaveObject } from '@/app/components/draft/filehandler/functions/set/readWeaveObject' +import { readWeaveObject } from '@/app/components/draft/weaveObjHandler/set/readWeaveObject' import { defaultColor, defaultDraftHeight, defaultDraftWidth, defaultShafts, defaultTreadles } from '@/app/resources/constants/weaveDefaults' import { resizeGrid } from '@/app/resources/functions/resizeGrid' //exports @@ -120,7 +120,7 @@ export function WeaveProvider({ children }: { children: React.ReactElement | Rea updateGrid('tieup', newGrids.tieupGrid) updateGrid('warp', newGrids.warpGrid) updateGrid('weft', newGrids.treadleGrid) -} + } //Changes content of grid-array depending on cell-id function updateCell(cellId: string) { diff --git a/package.json b/package.json index 787a31d..74cf3b2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "newweaver", + "name": "nextjs-clerk-starter", "version": "0.1.0", "private": true, "scripts": {