From fc6c7cddcf211b88f6d64379ce931229d5f10765 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Lalicata Date: Thu, 11 Jul 2024 11:57:52 +0200 Subject: [PATCH] many changes to marketing (#93) --- .github/workflows/marketing-builddeploy.yml | 29 +--- .../workflows/support-center-builddeploy.yml | 44 +---- samples/marketing/azure.yaml | 5 + samples/marketing/infra/app/backend.bicep | 6 +- .../Write-MarketingEnvironmentVariables.ps1 | 27 +++ samples/marketing/run.ps1 | 2 +- samples/marketing/src/backend/Dockerfile | 4 +- .../marketing/src/backend/Marketing.csproj | 6 +- samples/marketing/src/backend/Marketing.sln | 12 -- samples/marketing/src/backend/Program.cs | 24 ++- .../marketing/src/frontend/.env.production | 1 - samples/marketing/src/frontend/.env.template | 2 +- samples/marketing/src/frontend/Dockerfile | 19 +-- .../marketing/src/frontend/package-lock.json | 157 +++++++++++------- samples/marketing/src/frontend/package.json | 5 +- .../frontend/src/app/forgot-password/page.tsx | 23 --- .../marketing/src/frontend/src/app/layout.tsx | 13 +- .../src/frontend/src/app/login/page.tsx | 23 --- .../src/frontend/src/app/marketing/page.tsx | 9 +- .../marketing/src/frontend/src/app/page.tsx | 4 - .../src/frontend/src/app/register/page.tsx | 23 --- .../src/components/auth-page/index.tsx | 14 -- .../frontend/src/components/header/index.tsx | 80 --------- .../src/components/themed-layout/index.tsx | 11 -- .../src/contexts/color-mode/index.tsx | 72 -------- .../src/frontend/src/interfaces/theme.d.ts | 15 -- .../auth-provider/auth-provider.server.ts | 21 --- .../providers/auth-provider/auth-provider.ts | 91 ---------- .../src/providers/auth-provider/index.ts | 2 - .../src/providers/data-provider/index.ts | 7 - 30 files changed, 168 insertions(+), 583 deletions(-) create mode 100644 samples/marketing/infra/azd-hooks/Write-MarketingEnvironmentVariables.ps1 delete mode 100644 samples/marketing/src/frontend/.env.production delete mode 100644 samples/marketing/src/frontend/src/app/forgot-password/page.tsx delete mode 100644 samples/marketing/src/frontend/src/app/login/page.tsx delete mode 100644 samples/marketing/src/frontend/src/app/register/page.tsx delete mode 100644 samples/marketing/src/frontend/src/components/auth-page/index.tsx delete mode 100644 samples/marketing/src/frontend/src/components/header/index.tsx delete mode 100644 samples/marketing/src/frontend/src/components/themed-layout/index.tsx delete mode 100644 samples/marketing/src/frontend/src/contexts/color-mode/index.tsx delete mode 100644 samples/marketing/src/frontend/src/interfaces/theme.d.ts delete mode 100644 samples/marketing/src/frontend/src/providers/auth-provider/auth-provider.server.ts delete mode 100644 samples/marketing/src/frontend/src/providers/auth-provider/auth-provider.ts delete mode 100644 samples/marketing/src/frontend/src/providers/auth-provider/index.ts delete mode 100644 samples/marketing/src/frontend/src/providers/data-provider/index.ts diff --git a/.github/workflows/marketing-builddeploy.yml b/.github/workflows/marketing-builddeploy.yml index a1868134..66b9f403 100644 --- a/.github/workflows/marketing-builddeploy.yml +++ b/.github/workflows/marketing-builddeploy.yml @@ -97,31 +97,10 @@ jobs: echo "::set-output name=azd-no-state-flag::" } - - name: Provision Infrastructure + - name: Provision Infrastructure and deploy application run: | - Write-Verbose "Provision infrastructure" -Verbose - azd provision ` + Write-Verbose "Provision infrastructure and deploying application" -Verbose + azd up ` --no-prompt ` --environment ${{ env.AZURE_ENV_NAME }} ` - ${{ steps.no-state.outputs.azd-no-state-flag }} - - # Make environment variables out of all outputs from bicep file - azd env get-values | % { - $name,$value = $_.Split('=') - - #Value is quoted, so remove quotes - $value = $value.Replace('"','') - - [System.Environment]::SetEnvironmentVariable($name,$value) - Write-Verbose "Variable '$name' set to '$value'" -Verbose - } - - Write-Verbose "Frontend .env file updated with backend endpoint" -Verbose - # Replace the backend endpoint in the frontend .env file - pushd src/frontend - Copy-Item -Path .env.template -Destination .env.production - (Get-Content .env.production) -replace '', $env:AZURE_BACKEND_URI | Set-Content .env.production - popd - - Write-Verbose "Building and deploying application" -Verbose - azd deploy --no-prompt --environment ${{ env.AZURE_ENV_NAME }} \ No newline at end of file + ${{ steps.no-state.outputs.azd-no-state-flag }} \ No newline at end of file diff --git a/.github/workflows/support-center-builddeploy.yml b/.github/workflows/support-center-builddeploy.yml index 2eaa0f0b..538de086 100644 --- a/.github/workflows/support-center-builddeploy.yml +++ b/.github/workflows/support-center-builddeploy.yml @@ -74,19 +74,6 @@ jobs: --federated-credential-provider "github" ` --tenant-id "$Env:AZURE_TENANT_ID" - # - name: Log in with Azure (Client Credentials) - # if: ${{ env.AZURE_CREDENTIALS != '' }} - # run: | - # $info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable; - # Write-Host "::add-mask::$($info.clientSecret)" - # azd auth login ` - # --client-id "$($info.clientId)" ` - # --client-secret "$($info.clientSecret)" ` - # --tenant-id "$($info.tenantId)" - # shell: pwsh - # env: - # AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} - - name: Set --no-state flag for azd id: no-state run: | @@ -98,31 +85,10 @@ jobs: echo "::set-output name=azd-no-state-flag::" } - - name: Provision Infrastructure + - name: Provision Infrastructure and deploy application run: | - Write-Verbose "Provision infrastructure" -Verbose - azd provision ` + Write-Verbose "Provision infrastructure and deploying application" -Verbose + azd up ` --no-prompt ` - --environment ${{ env.AZURE_ENV_NAME }}-sc ` - ${{ steps.no-state.outputs.azd-no-state-flag }} - - # Make environment variables out of all outputs from bicep file - azd env get-values | % { - $name,$value = $_.Split('=') - - #Value is quoted, so remove quotes - $value = $value.Replace('"','') - - Write-Verbose "Variable '$name' set to '$value'" -Verbose - [System.Environment]::SetEnvironmentVariable($name,$value) - } - - Write-Verbose "Frontend .env file updated with backend endpoint" -Verbose - # Replace the backend endpoint in the frontend .env file - pushd src/frontend - Copy-Item -Path .env.azureConfig -Destination .env - (Get-Content .env) -replace '', $env:AZURE_BACKEND_ENDPOINT | Set-Content .env - popd - - Write-Verbose "Building and deploying application" -Verbose - azd deploy --no-prompt --environment ${{ env.AZURE_ENV_NAME }}-sc \ No newline at end of file + --environment ${{ env.AZURE_ENV_NAME }} ` + ${{ steps.no-state.outputs.azd-no-state-flag }} \ No newline at end of file diff --git a/samples/marketing/azure.yaml b/samples/marketing/azure.yaml index 5f588857..22e9d646 100644 --- a/samples/marketing/azure.yaml +++ b/samples/marketing/azure.yaml @@ -3,6 +3,11 @@ name: marketing metadata: template: azd-init@1.8.2 +hooks: + postprovision: + interactive: false + shell: pwsh + run: infra/azd-hooks/Write-MarketingEnvironmentVariables.ps1 services: backend: project: "src/backend" diff --git a/samples/marketing/infra/app/backend.bicep b/samples/marketing/infra/app/backend.bicep index 8f36a473..94968ee9 100644 --- a/samples/marketing/infra/app/backend.bicep +++ b/samples/marketing/infra/app/backend.bicep @@ -58,7 +58,7 @@ module fetchLatestImage '../modules/fetch-container-image.bicep' = { } } -resource app 'Microsoft.App/containerApps@2023-05-02-preview' = { +resource app 'Microsoft.App/containerApps@2023-11-02-preview' = { name: name location: location tags: union(tags, {'azd-service-name': 'backend' }) @@ -75,9 +75,7 @@ resource app 'Microsoft.App/containerApps@2023-05-02-preview' = { targetPort: 5244 transport: 'auto' corsPolicy: { - allowedOrigins: union(allowedOrigins, [ - // define additional allowed origins here - ]) + allowedOrigins: allowedOrigins } } registries: [ diff --git a/samples/marketing/infra/azd-hooks/Write-MarketingEnvironmentVariables.ps1 b/samples/marketing/infra/azd-hooks/Write-MarketingEnvironmentVariables.ps1 new file mode 100644 index 00000000..2c193b05 --- /dev/null +++ b/samples/marketing/infra/azd-hooks/Write-MarketingEnvironmentVariables.ps1 @@ -0,0 +1,27 @@ + +# Make environment variables out of all outputs from bicep file +Write-Verbose "---Setting environment variables..." -Verbose + azd env get-values | % { + $name,$value = $_.Split('=') + + #Value is quoted, so remove quotes + $value = $value.Replace('"','') + + [System.Environment]::SetEnvironmentVariable($name,$value) + Write-Verbose "Variable '$name' set to '$value'" -Verbose + } +Write-Verbose "---Done setting environment variables" -Verbose + +$templateFileName = ".env.template" +$prodEnvFileName = ".env" + +# Replace the backend endpoint in the frontend .env file +Write-Verbose "---Updating '$prodEnvFileName' file updated with backend endpoint..." -Verbose + pushd src/frontend + if (-not (Test-Path -Path $templateFileName)) { + Write-Error "The file '$templateFileName' does not exist." + } + Copy-Item -Path $templateFileName -Destination $prodEnvFileName + (Get-Content $prodEnvFileName) -replace '', $env:AZURE_BACKEND_URI | Set-Content $prodEnvFileName + popd +Write-Verbose "---Done updating '$prodEnvFileName' file updated with backend endpoint..." -Verbose diff --git a/samples/marketing/run.ps1 b/samples/marketing/run.ps1 index 878d0045..66814244 100644 --- a/samples/marketing/run.ps1 +++ b/samples/marketing/run.ps1 @@ -5,7 +5,7 @@ if(Test-Path src/backend/appsettings.json) { Write-Verbose "appsettings.json created" -Verbose } -if((Get-Content .\src\backend\appsettings.local.template.json -Raw | Select-String "") -ne $null) { +if((Get-Content .\src\backend\appsettings.json -Raw | Select-String "") -ne $null) { Write-Error "Please update the appsettings.json file with the correct values" -ErrorAction Stop } diff --git a/samples/marketing/src/backend/Dockerfile b/samples/marketing/src/backend/Dockerfile index c5a50451..fec30f8d 100644 --- a/samples/marketing/src/backend/Dockerfile +++ b/samples/marketing/src/backend/Dockerfile @@ -7,14 +7,14 @@ EXPOSE 30000 ENV ASPNETCORE_URLS=http://+:5274 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build -ARG configuration=Release +ARG configuration=Debug COPY . . RUN dotnet restore "samples/marketing/src/backend/Marketing.csproj" WORKDIR "samples/marketing/src/backend" RUN dotnet build "Marketing.csproj" -c $configuration -o /app/build FROM build AS publish -ARG configuration=Release +ARG configuration=Debug RUN dotnet publish "Marketing.csproj" -c $configuration -o /app/publish FROM base AS final diff --git a/samples/marketing/src/backend/Marketing.csproj b/samples/marketing/src/backend/Marketing.csproj index b6ddb90f..36c6d09e 100644 --- a/samples/marketing/src/backend/Marketing.csproj +++ b/samples/marketing/src/backend/Marketing.csproj @@ -19,6 +19,8 @@ + + @@ -51,10 +53,6 @@ - - - - diff --git a/samples/marketing/src/backend/Marketing.sln b/samples/marketing/src/backend/Marketing.sln index 032e60cf..5efa3842 100644 --- a/samples/marketing/src/backend/Marketing.sln +++ b/samples/marketing/src/backend/Marketing.sln @@ -5,10 +5,6 @@ VisualStudioVersion = 17.5.002.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Marketing", "Marketing.csproj", "{491A6E2F-A0D0-4723-80A2-B0F60091E39D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AI.Agents.Orleans", "..\..\..\..\src\Microsoft.AI.Agents.Orleans\Microsoft.AI.Agents.Orleans.csproj", "{4C246005-605C-4F7F-8D67-839A5640587A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AI.Agents", "..\..\..\..\src\Microsoft.AI.Agents\Microsoft.AI.Agents.csproj", "{5CB1E5D6-33BF-4E09-BDE3-29F8A24F2158}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -19,14 +15,6 @@ Global {491A6E2F-A0D0-4723-80A2-B0F60091E39D}.Debug|Any CPU.Build.0 = Debug|Any CPU {491A6E2F-A0D0-4723-80A2-B0F60091E39D}.Release|Any CPU.ActiveCfg = Release|Any CPU {491A6E2F-A0D0-4723-80A2-B0F60091E39D}.Release|Any CPU.Build.0 = Release|Any CPU - {4C246005-605C-4F7F-8D67-839A5640587A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4C246005-605C-4F7F-8D67-839A5640587A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4C246005-605C-4F7F-8D67-839A5640587A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4C246005-605C-4F7F-8D67-839A5640587A}.Release|Any CPU.Build.0 = Release|Any CPU - {5CB1E5D6-33BF-4E09-BDE3-29F8A24F2158}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5CB1E5D6-33BF-4E09-BDE3-29F8A24F2158}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5CB1E5D6-33BF-4E09-BDE3-29F8A24F2158}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5CB1E5D6-33BF-4E09-BDE3-29F8A24F2158}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/samples/marketing/src/backend/Program.cs b/samples/marketing/src/backend/Program.cs index 5c4dc21f..f5c01fd8 100644 --- a/samples/marketing/src/backend/Program.cs +++ b/samples/marketing/src/backend/Program.cs @@ -23,21 +23,18 @@ builder.Services.AddSingleton(); -// Allow any CORS origin if in DEV -const string AllowDebugOriginPolicy = "AllowDebugOrigin"; -if (builder.Environment.IsDevelopment()) +// CORS is handled at the platform level (ex: Azure Container Apps) +const string AllowAllCorsOrigin = "AllowAllCorsOrigin"; +builder.Services.AddCors(options => { - builder.Services.AddCors(options => + options.AddPolicy(AllowAllCorsOrigin, builder => { - options.AddPolicy(AllowDebugOriginPolicy, builder => { - builder - .WithOrigins("http://localhost:3000") // client url - .AllowAnyHeader() - .AllowAnyMethod() - .AllowCredentials(); - }); + builder + .WithOrigins("http://localhost:3000", "https://*.azurecontainerapps.io") + .AllowAnyHeader() + .AllowAnyMethod(); }); -} +}); builder.Services.AddOptions() .Configure((settings, configuration) => @@ -72,8 +69,9 @@ var app = builder.Build(); +app.UseCors(AllowAllCorsOrigin); + app.UseRouting(); -app.UseCors(AllowDebugOriginPolicy); app.MapControllers(); app.UseSwagger(); diff --git a/samples/marketing/src/frontend/.env.production b/samples/marketing/src/frontend/.env.production deleted file mode 100644 index fe933ea9..00000000 --- a/samples/marketing/src/frontend/.env.production +++ /dev/null @@ -1 +0,0 @@ -NEXT_PUBLIC_BACKEND_URI=https://ca-backend-62owtplcwdwxk.agreeablepebble-b015526d.westeurope.azurecontainerapps.io diff --git a/samples/marketing/src/frontend/.env.template b/samples/marketing/src/frontend/.env.template index 8a194441..a08f5458 100644 --- a/samples/marketing/src/frontend/.env.template +++ b/samples/marketing/src/frontend/.env.template @@ -1 +1 @@ -REACT_APP_BACKEND_URI= \ No newline at end of file +NEXT_PUBLIC_BACKEND_URI= \ No newline at end of file diff --git a/samples/marketing/src/frontend/Dockerfile b/samples/marketing/src/frontend/Dockerfile index 8f708460..13752a40 100644 --- a/samples/marketing/src/frontend/Dockerfile +++ b/samples/marketing/src/frontend/Dockerfile @@ -1,11 +1,8 @@ FROM refinedev/node:18 AS base FROM base AS deps - RUN apk add --no-cache libc6-compat - COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./ - RUN \ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ elif [ -f package-lock.json ]; then npm ci; \ @@ -14,29 +11,21 @@ RUN \ fi FROM base AS builder - +ENV NEXT_TELEMETRY_DEBUG=1 COPY --from=deps /app/refine/node_modules ./node_modules - COPY . . RUN npm run build FROM base AS runner - -ENV NODE_ENV production - +ENV NODE_ENV=production COPY --from=builder /app/refine/public ./public - RUN mkdir .next RUN chown refine:nodejs .next - COPY --from=builder --chown=refine:nodejs /app/refine/.next/standalone ./ COPY --from=builder --chown=refine:nodejs /app/refine/.next/static ./.next/static USER refine - EXPOSE 3000 - -ENV PORT 3000 -ENV HOSTNAME "0.0.0.0" - +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" CMD ["node", "server.js"] \ No newline at end of file diff --git a/samples/marketing/src/frontend/package-lock.json b/samples/marketing/src/frontend/package-lock.json index c281c7f9..b6dd3862 100644 --- a/samples/marketing/src/frontend/package-lock.json +++ b/samples/marketing/src/frontend/package-lock.json @@ -25,10 +25,11 @@ "@refinedev/react-hook-form": "^4.8.14", "@refinedev/simple-rest": "^5.0.1", "js-cookie": "^3.0.5", - "next": "14.1.0", + "next": "^14.2.5", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-flippy": "^1.1.0" + "react-flippy": "^1.1.0", + "uuidv4": "^6.2.13" }, "devDependencies": { "@types/js-cookie": "^3.0.6", @@ -1237,9 +1238,9 @@ } }, "node_modules/@microsoft/signalr/node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "engines": { "node": ">=8.3.0" }, @@ -1567,9 +1568,9 @@ } }, "node_modules/@next/env": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@next/env/-/env-14.1.0.tgz", - "integrity": "sha512-Py8zIo+02ht82brwwhTg36iogzFqGLPXlRGKQw5s+qP/kMNc4MAyDeEwBKDijk6zTIbegEgu8Qy7C1LboslQAw==" + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.5.tgz", + "integrity": "sha512-/zZGkrTOsraVfYjGP8uM0p6r0BDT6xWpkjdVbcz66PJVSpwXX3yNiRycxAuDfBKGWBrZBXRuK/YVlkNgxHGwmA==" }, "node_modules/@next/eslint-plugin-next": { "version": "14.1.0", @@ -1581,9 +1582,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.1.0.tgz", - "integrity": "sha512-nUDn7TOGcIeyQni6lZHfzNoo9S0euXnu0jhsbMOmMJUBfgsnESdjN97kM7cBqQxZa8L/bM9om/S5/1dzCrW6wQ==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.5.tgz", + "integrity": "sha512-/9zVxJ+K9lrzSGli1///ujyRfon/ZneeZ+v4ptpiPoOU+GKZnm8Wj8ELWU1Pm7GHltYRBklmXMTUqM/DqQ99FQ==", "cpu": [ "arm64" ], @@ -1596,9 +1597,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.1.0.tgz", - "integrity": "sha512-1jgudN5haWxiAl3O1ljUS2GfupPmcftu2RYJqZiMJmmbBT5M1XDffjUtRUzP4W3cBHsrvkfOFdQ71hAreNQP6g==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.5.tgz", + "integrity": "sha512-vXHOPCwfDe9qLDuq7U1OYM2wUY+KQ4Ex6ozwsKxp26BlJ6XXbHleOUldenM67JRyBfVjv371oneEvYd3H2gNSA==", "cpu": [ "x64" ], @@ -1611,9 +1612,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.1.0.tgz", - "integrity": "sha512-RHo7Tcj+jllXUbK7xk2NyIDod3YcCPDZxj1WLIYxd709BQ7WuRYl3OWUNG+WUfqeQBds6kvZYlc42NJJTNi4tQ==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.5.tgz", + "integrity": "sha512-vlhB8wI+lj8q1ExFW8lbWutA4M2ZazQNvMWuEDqZcuJJc78iUnLdPPunBPX8rC4IgT6lIx/adB+Cwrl99MzNaA==", "cpu": [ "arm64" ], @@ -1626,9 +1627,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.1.0.tgz", - "integrity": "sha512-v6kP8sHYxjO8RwHmWMJSq7VZP2nYCkRVQ0qolh2l6xroe9QjbgV8siTbduED4u0hlk0+tjS6/Tuy4n5XCp+l6g==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.5.tgz", + "integrity": "sha512-NpDB9NUR2t0hXzJJwQSGu1IAOYybsfeB+LxpGsXrRIb7QOrYmidJz3shzY8cM6+rO4Aojuef0N/PEaX18pi9OA==", "cpu": [ "arm64" ], @@ -1641,9 +1642,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.1.0.tgz", - "integrity": "sha512-zJ2pnoFYB1F4vmEVlb/eSe+VH679zT1VdXlZKX+pE66grOgjmKJHKacf82g/sWE4MQ4Rk2FMBCRnX+l6/TVYzQ==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.5.tgz", + "integrity": "sha512-8XFikMSxWleYNryWIjiCX+gU201YS+erTUidKdyOVYi5qUQo/gRxv/3N1oZFCgqpesN6FPeqGM72Zve+nReVXQ==", "cpu": [ "x64" ], @@ -1656,9 +1657,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.1.0.tgz", - "integrity": "sha512-rbaIYFt2X9YZBSbH/CwGAjbBG2/MrACCVu2X0+kSykHzHnYH5FjHxwXLkcoJ10cX0aWCEynpu+rP76x0914atg==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.5.tgz", + "integrity": "sha512-6QLwi7RaYiQDcRDSU/os40r5o06b5ue7Jsk5JgdRBGGp8l37RZEh9JsLSM8QF0YDsgcosSeHjglgqi25+m04IQ==", "cpu": [ "x64" ], @@ -1671,9 +1672,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.1.0.tgz", - "integrity": "sha512-o1N5TsYc8f/HpGt39OUQpQ9AKIGApd3QLueu7hXk//2xq5Z9OxmV6sQfNp8C7qYmiOlHYODOGqNNa0e9jvchGQ==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.5.tgz", + "integrity": "sha512-1GpG2VhbspO+aYoMOQPQiqc/tG3LzmsdBH0LhnDS3JrtDx2QmzXe0B6mSZZiN3Bq7IOMXxv1nlsjzoS1+9mzZw==", "cpu": [ "arm64" ], @@ -1686,9 +1687,9 @@ } }, "node_modules/@next/swc-win32-ia32-msvc": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.1.0.tgz", - "integrity": "sha512-XXIuB1DBRCFwNO6EEzCTMHT5pauwaSj4SWs7CYnME57eaReAKBXCnkUE80p/pAZcewm7hs+vGvNqDPacEXHVkw==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.5.tgz", + "integrity": "sha512-Igh9ZlxwvCDsu6438FXlQTHlRno4gFpJzqPjSIBZooD22tKeI4fE/YMRoHVJHmrQ2P5YL1DoZ0qaOKkbeFWeMg==", "cpu": [ "ia32" ], @@ -1701,9 +1702,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.1.0.tgz", - "integrity": "sha512-9WEbVRRAqJ3YFVqEZIxUqkiO8l1nool1LmNxygr5HWF8AcSYsEpneUDhmjUVJEzO2A04+oPtZdombzzPPkTtgg==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.5.tgz", + "integrity": "sha512-tEQ7oinq1/CjSG9uSTerca3v4AZ+dFa+4Yu6ihaG8Ud8ddqLQgFGcnwYls13H5X5CPDPZJdYxyeMui6muOLd4g==", "cpu": [ "x64" ], @@ -2256,11 +2257,17 @@ "url": "https://github.com/sindresorhus/is?sponsor=1" } }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==" + }, "node_modules/@swc/helpers": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.2.tgz", - "integrity": "sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.5.tgz", + "integrity": "sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==", "dependencies": { + "@swc/counter": "^0.1.3", "tslib": "^2.4.0" } }, @@ -2446,6 +2453,11 @@ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.10.tgz", "integrity": "sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==" }, + "node_modules/@types/uuid": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==" + }, "node_modules/@typescript-eslint/parser": { "version": "5.48.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.48.0.tgz", @@ -3117,11 +3129,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -4957,9 +4969,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -7312,12 +7324,12 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" }, "node_modules/next": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/next/-/next-14.1.0.tgz", - "integrity": "sha512-wlzrsbfeSU48YQBjZhDzOwhWhGsy+uQycR8bHAOt1LY1bn3zZEcDyHQOEoN3aWzQ8LHCAJ1nqrWCc9XF2+O45Q==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/next/-/next-14.2.5.tgz", + "integrity": "sha512-0f8aRfBVL+mpzfBjYfQuLWh2WyAwtJXCRfkPF4UJ5qd2YwrHczsrSzXU4tRMV0OAxR8ZJZWPFn6uhSC56UTsLA==", "dependencies": { - "@next/env": "14.1.0", - "@swc/helpers": "0.5.2", + "@next/env": "14.2.5", + "@swc/helpers": "0.5.5", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001579", "graceful-fs": "^4.2.11", @@ -7331,18 +7343,19 @@ "node": ">=18.17.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "14.1.0", - "@next/swc-darwin-x64": "14.1.0", - "@next/swc-linux-arm64-gnu": "14.1.0", - "@next/swc-linux-arm64-musl": "14.1.0", - "@next/swc-linux-x64-gnu": "14.1.0", - "@next/swc-linux-x64-musl": "14.1.0", - "@next/swc-win32-arm64-msvc": "14.1.0", - "@next/swc-win32-ia32-msvc": "14.1.0", - "@next/swc-win32-x64-msvc": "14.1.0" + "@next/swc-darwin-arm64": "14.2.5", + "@next/swc-darwin-x64": "14.2.5", + "@next/swc-linux-arm64-gnu": "14.2.5", + "@next/swc-linux-arm64-musl": "14.2.5", + "@next/swc-linux-x64-gnu": "14.2.5", + "@next/swc-linux-x64-musl": "14.2.5", + "@next/swc-win32-arm64-msvc": "14.2.5", + "@next/swc-win32-ia32-msvc": "14.2.5", + "@next/swc-win32-x64-msvc": "14.2.5" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", + "@playwright/test": "^1.41.2", "react": "^18.2.0", "react-dom": "^18.2.0", "sass": "^1.3.0" @@ -7351,6 +7364,9 @@ "@opentelemetry/api": { "optional": true }, + "@playwright/test": { + "optional": true + }, "sass": { "optional": true } @@ -10043,6 +10059,23 @@ "node": ">= 0.4.0" } }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/uuidv4": { + "version": "6.2.13", + "resolved": "https://registry.npmjs.org/uuidv4/-/uuidv4-6.2.13.tgz", + "integrity": "sha512-AXyzMjazYB3ovL3q051VLH06Ixj//Knx7QnUSi1T//Ie3io6CpsPu9nVMOx5MoLWh6xV0B9J0hIaxungxXUbPQ==", + "dependencies": { + "@types/uuid": "8.3.4", + "uuid": "8.3.2" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -10299,9 +10332,9 @@ } }, "node_modules/ws": { - "version": "8.17.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz", - "integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "engines": { "node": ">=10.0.0" }, diff --git a/samples/marketing/src/frontend/package.json b/samples/marketing/src/frontend/package.json index 49b2bf6c..442e85eb 100644 --- a/samples/marketing/src/frontend/package.json +++ b/samples/marketing/src/frontend/package.json @@ -30,10 +30,11 @@ "@refinedev/react-hook-form": "^4.8.14", "@refinedev/simple-rest": "^5.0.1", "js-cookie": "^3.0.5", - "next": "14.1.0", + "next": "^14.2.5", "react": "^18.0.0", "react-dom": "^18.0.0", - "react-flippy": "^1.1.0" + "react-flippy": "^1.1.0", + "uuidv4": "^6.2.13" }, "devDependencies": { "@types/js-cookie": "^3.0.6", diff --git a/samples/marketing/src/frontend/src/app/forgot-password/page.tsx b/samples/marketing/src/frontend/src/app/forgot-password/page.tsx deleted file mode 100644 index 72d4dbc0..00000000 --- a/samples/marketing/src/frontend/src/app/forgot-password/page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { AuthPage } from "@components/auth-page"; -import { authProviderServer } from "@providers/auth-provider"; -import { redirect } from "next/navigation"; - -export default async function ForgotPassword() { - const data = await getData(); - - if (data.authenticated) { - redirect(data?.redirectTo || "/"); - } - - return ; -} - -async function getData() { - const { authenticated, redirectTo, error } = await authProviderServer.check(); - - return { - authenticated, - redirectTo, - error, - }; -} diff --git a/samples/marketing/src/frontend/src/app/layout.tsx b/samples/marketing/src/frontend/src/app/layout.tsx index bb833458..2430d22d 100644 --- a/samples/marketing/src/frontend/src/app/layout.tsx +++ b/samples/marketing/src/frontend/src/app/layout.tsx @@ -7,11 +7,7 @@ import { Metadata } from "next"; import { cookies } from "next/headers"; import React, { Suspense } from "react"; -import { ColorModeContextProvider } from "@contexts/color-mode"; -import { authProvider } from "@providers/auth-provider"; -import { dataProvider } from "@providers/data-provider"; - -export const metadata: Metadata = { + export const metadata: Metadata = { title: "Refine", description: "Generated by create refine app", icons: { @@ -24,23 +20,17 @@ export default function RootLayout({ }: Readonly<{ children: React.ReactNode; }>) { - const cookieStore = cookies(); - const theme = cookieStore.get("theme"); - const defaultMode = theme?.value === "dark" ? "dark" : "light"; return ( - - diff --git a/samples/marketing/src/frontend/src/app/login/page.tsx b/samples/marketing/src/frontend/src/app/login/page.tsx deleted file mode 100644 index cfe99c57..00000000 --- a/samples/marketing/src/frontend/src/app/login/page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { AuthPage } from "@components/auth-page"; -import { authProviderServer } from "@providers/auth-provider"; -import { redirect } from "next/navigation"; - -export default async function Login() { - const data = await getData(); - - if (data.authenticated) { - redirect(data?.redirectTo || "/"); - } - - return ; -} - -async function getData() { - const { authenticated, redirectTo, error } = await authProviderServer.check(); - - return { - authenticated, - redirectTo, - error, - }; -} diff --git a/samples/marketing/src/frontend/src/app/marketing/page.tsx b/samples/marketing/src/frontend/src/app/marketing/page.tsx index e4c6bb7e..e4b1c3f6 100644 --- a/samples/marketing/src/frontend/src/app/marketing/page.tsx +++ b/samples/marketing/src/frontend/src/app/marketing/page.tsx @@ -19,6 +19,8 @@ import CommunityManager from './community-manager/community-manager'; import { Container, Grid } from '@mui/material'; import { HubConnectionBuilder, HubConnection, LogLevel } from '@microsoft/signalr'; +import { v4 as uuidv4 } from 'uuid'; + type SignalRMessage = { userId: string; message: string; @@ -41,14 +43,13 @@ export default function Marketing() { backgroundSize: 'cover', height: '100vh', }); - + + const [userId, setUserId] = React.useState(uuidv4()); const [connection, setConnection] = React.useState(); - - const userId = 'Carlos'; - //Chat component state const [messages, setMessages] = React.useState<{ sender: string; text: any; }[]>([]); //Community manager state + const [ article, setArticle ] = useState(''); const [ imgUrl, setImgUrl ] = useState(''); const [ communityManagerOpen, setCommunityManagerOpen ] = useState(false); diff --git a/samples/marketing/src/frontend/src/app/page.tsx b/samples/marketing/src/frontend/src/app/page.tsx index 46505446..fc510374 100644 --- a/samples/marketing/src/frontend/src/app/page.tsx +++ b/samples/marketing/src/frontend/src/app/page.tsx @@ -1,16 +1,12 @@ "use client"; import { Suspense } from "react"; - -import { Authenticated } from "@refinedev/core"; import { NavigateToResource } from "@refinedev/nextjs-router"; export default function IndexPage() { return ( - - ); } diff --git a/samples/marketing/src/frontend/src/app/register/page.tsx b/samples/marketing/src/frontend/src/app/register/page.tsx deleted file mode 100644 index bf26b7c1..00000000 --- a/samples/marketing/src/frontend/src/app/register/page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { AuthPage } from "@components/auth-page"; -import { authProviderServer } from "@providers/auth-provider"; -import { redirect } from "next/navigation"; - -export default async function Register() { - const data = await getData(); - - if (data.authenticated) { - redirect(data?.redirectTo || "/"); - } - - return ; -} - -async function getData() { - const { authenticated, redirectTo, error } = await authProviderServer.check(); - - return { - authenticated, - redirectTo, - error, - }; -} diff --git a/samples/marketing/src/frontend/src/components/auth-page/index.tsx b/samples/marketing/src/frontend/src/components/auth-page/index.tsx deleted file mode 100644 index 76e46cce..00000000 --- a/samples/marketing/src/frontend/src/components/auth-page/index.tsx +++ /dev/null @@ -1,14 +0,0 @@ -"use client"; -import type { AuthPageProps } from "@refinedev/core"; -import { AuthPage as AuthPageBase } from "@refinedev/mui"; - -export const AuthPage = (props: AuthPageProps) => { - return ( - - ); -}; diff --git a/samples/marketing/src/frontend/src/components/header/index.tsx b/samples/marketing/src/frontend/src/components/header/index.tsx deleted file mode 100644 index ad6c003a..00000000 --- a/samples/marketing/src/frontend/src/components/header/index.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { ColorModeContext } from "@contexts/color-mode"; -import DarkModeOutlined from "@mui/icons-material/DarkModeOutlined"; -import LightModeOutlined from "@mui/icons-material/LightModeOutlined"; -import AppBar from "@mui/material/AppBar"; -import Avatar from "@mui/material/Avatar"; -import IconButton from "@mui/material/IconButton"; -import Stack from "@mui/material/Stack"; -import Toolbar from "@mui/material/Toolbar"; -import Typography from "@mui/material/Typography"; -import { useGetIdentity } from "@refinedev/core"; -import { HamburgerMenu, RefineThemedLayoutV2HeaderProps } from "@refinedev/mui"; -import React, { useContext } from "react"; - -type IUser = { - id: number; - name: string; - avatar: string; -}; - -export const Header: React.FC = ({ - sticky = true, -}) => { - const { mode, setMode } = useContext(ColorModeContext); - - const { data: user } = useGetIdentity(); - - return ( - - - - - - { - setMode(); - }} - > - {mode === "dark" ? : } - - - {(user?.avatar || user?.name) && ( - - {user?.name && ( - - {user?.name} - - )} - - - )} - - - - - ); -}; diff --git a/samples/marketing/src/frontend/src/components/themed-layout/index.tsx b/samples/marketing/src/frontend/src/components/themed-layout/index.tsx deleted file mode 100644 index bed03486..00000000 --- a/samples/marketing/src/frontend/src/components/themed-layout/index.tsx +++ /dev/null @@ -1,11 +0,0 @@ -"use client"; - -import { Header } from "@components/header"; -import { ThemedLayoutV2 } from "@refinedev/mui"; -import React from "react"; - -export const ThemedLayout = ({ children }: React.PropsWithChildren) => { - return ( -
}>{children} - ); -}; diff --git a/samples/marketing/src/frontend/src/contexts/color-mode/index.tsx b/samples/marketing/src/frontend/src/contexts/color-mode/index.tsx deleted file mode 100644 index f064de7b..00000000 --- a/samples/marketing/src/frontend/src/contexts/color-mode/index.tsx +++ /dev/null @@ -1,72 +0,0 @@ -"use client"; - -import CssBaseline from "@mui/material/CssBaseline"; -import GlobalStyles from "@mui/material/GlobalStyles"; -import { ThemeProvider } from "@mui/material/styles"; -import useMediaQuery from "@mui/material/useMediaQuery"; -import { RefineThemes } from "@refinedev/mui"; -import Cookies from "js-cookie"; -import React, { - PropsWithChildren, - createContext, - useEffect, - useState, -} from "react"; - -type ColorModeContextType = { - mode: string; - setMode: () => void; -}; - -export const ColorModeContext = createContext( - {} as ColorModeContextType -); - -type ColorModeContextProviderProps = { - defaultMode?: string; -}; - -export const ColorModeContextProvider: React.FC< - PropsWithChildren -> = ({ children, defaultMode }) => { - const [isMounted, setIsMounted] = useState(false); - const [mode, setMode] = useState(defaultMode || "light"); - - useEffect(() => { - setIsMounted(true); - }, []); - - const systemTheme = useMediaQuery(`(prefers-color-scheme: dark)`); - - useEffect(() => { - if (isMounted) { - const theme = Cookies.get("theme") || (systemTheme ? "dark" : "light"); - setMode(theme); - } - }, [isMounted, systemTheme]); - - const toggleTheme = () => { - const nextTheme = mode === "light" ? "dark" : "light"; - - setMode(nextTheme); - Cookies.set("theme", nextTheme); - }; - - return ( - - - - - {children} - - - ); -}; diff --git a/samples/marketing/src/frontend/src/interfaces/theme.d.ts b/samples/marketing/src/frontend/src/interfaces/theme.d.ts deleted file mode 100644 index 9819aac1..00000000 --- a/samples/marketing/src/frontend/src/interfaces/theme.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import "@refinedev/mui"; - -export interface CustomTheme { - // Add custom variables here like below: - // status: { - // danger: string; - // }; -} - -declare module "@refinedev/mui" { - interface Theme extends import("@refinedev/mui").Theme, CustomTheme {} - interface ThemeOptions - extends import("@refinedev/mui").ThemeOptions, - CustomTheme {} -} diff --git a/samples/marketing/src/frontend/src/providers/auth-provider/auth-provider.server.ts b/samples/marketing/src/frontend/src/providers/auth-provider/auth-provider.server.ts deleted file mode 100644 index 5f1f9743..00000000 --- a/samples/marketing/src/frontend/src/providers/auth-provider/auth-provider.server.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { AuthBindings } from "@refinedev/core"; -import { cookies } from "next/headers"; - -export const authProviderServer: Pick = { - check: async () => { - const cookieStore = cookies(); - const auth = cookieStore.get("auth"); - - if (auth) { - return { - authenticated: true, - }; - } - - return { - authenticated: false, - logout: true, - redirectTo: "/login", - }; - }, -}; diff --git a/samples/marketing/src/frontend/src/providers/auth-provider/auth-provider.ts b/samples/marketing/src/frontend/src/providers/auth-provider/auth-provider.ts deleted file mode 100644 index 2f626b2b..00000000 --- a/samples/marketing/src/frontend/src/providers/auth-provider/auth-provider.ts +++ /dev/null @@ -1,91 +0,0 @@ -"use client"; - -import { AuthBindings } from "@refinedev/core"; -import Cookies from "js-cookie"; - -const mockUsers = [ - { - name: "John Doe", - email: "johndoe@mail.com", - roles: ["admin"], - avatar: "https://i.pravatar.cc/150?img=1", - }, - { - name: "Jane Doe", - email: "janedoe@mail.com", - roles: ["editor"], - avatar: "https://i.pravatar.cc/150?img=1", - }, -]; - -export const authProvider: AuthBindings = { - login: async ({ email, username, password, remember }) => { - // Suppose we actually send a request to the back end here. - const user = mockUsers[0]; - - if (user) { - Cookies.set("auth", JSON.stringify(user), { - expires: 30, // 30 days - path: "/", - }); - return { - success: true, - redirectTo: "/", - }; - } - - return { - success: false, - error: { - name: "LoginError", - message: "Invalid username or password", - }, - }; - }, - logout: async () => { - Cookies.remove("auth", { path: "/" }); - return { - success: true, - redirectTo: "/login", - }; - }, - check: async () => { - const auth = Cookies.get("auth"); - if (auth) { - return { - authenticated: true, - }; - } - - return { - authenticated: false, - logout: true, - redirectTo: "/login", - }; - }, - getPermissions: async () => { - const auth = Cookies.get("auth"); - if (auth) { - const parsedUser = JSON.parse(auth); - return parsedUser.roles; - } - return null; - }, - getIdentity: async () => { - const auth = Cookies.get("auth"); - if (auth) { - const parsedUser = JSON.parse(auth); - return parsedUser; - } - return null; - }, - onError: async (error) => { - if (error.response?.status === 401) { - return { - logout: true, - }; - } - - return { error }; - }, -}; diff --git a/samples/marketing/src/frontend/src/providers/auth-provider/index.ts b/samples/marketing/src/frontend/src/providers/auth-provider/index.ts deleted file mode 100644 index 6734cd53..00000000 --- a/samples/marketing/src/frontend/src/providers/auth-provider/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./auth-provider"; -export * from "./auth-provider.server"; diff --git a/samples/marketing/src/frontend/src/providers/data-provider/index.ts b/samples/marketing/src/frontend/src/providers/data-provider/index.ts deleted file mode 100644 index a049c0e1..00000000 --- a/samples/marketing/src/frontend/src/providers/data-provider/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -"use client"; - -import dataProviderSimpleRest from "@refinedev/simple-rest"; - -const API_URL = "https://api.fake-rest.refine.dev"; - -export const dataProvider = dataProviderSimpleRest(API_URL);